Skip to content
Snippets Groups Projects
Verified Commit b64aaa5d authored by David Hoese's avatar David Hoese
Browse files

Add record to shapefile test case for valid time to be returned

parent 3906c65d
No related branches found
No related tags found
No related merge requests found
......@@ -6,11 +6,11 @@ debug() {
error() {
echo >&2 "ERROR: $@"
exit 1
}
if [[ $# -ne 2 ]]; then
error "Usage: ./test_mapserver_image.sh <image_url> <image_tag>"
exit 1
fi
image_url=$1
......@@ -25,6 +25,8 @@ POSTGRES_USER="postgres"
POSTGRES_PASSWORD="1234"
NETWORK_NAME=`basename "$0"`
NETWORK_NAME=${NETWORK_NAME/.sh/}
C01_GTIFF_NAME="GOES-16_ABI_RadF_C01_20220302_194032_GOES-West.tif"
C01_ISOTIME="2022-03-02T19:40:32"
base_tmp_dir="__TOBECREATED__"
setup_test() {
......@@ -45,6 +47,7 @@ teardown_test() {
}
graceful_exit() {
debug "FAIL"
debug "Graceful exit"
teardown_test
}
......@@ -53,8 +56,23 @@ add_shapefile_content() {
debug "Creating fake shapefile directory for C01"
docker exec test mkdir -p /data/tiles/g16/abi/radf/C01
debug "Creating fake shapefile file for C01"
# TODO: Turn this into a function call it for the earlier test and add a wms_times request
docker exec test python3 -c "import fiona; fiona.open('/data/tiles/g16/abi/radf/C01/C01.shp', 'w', driver='ESRI Shapefile', schema={'geometry': 'Polygon', 'properties': {'location': 'str', 'time': 'str:19'}})"
docker exec -i test python3 <<EOF
import fiona
from shapely.geometry import mapping, box
s_file = fiona.open('/data/tiles/g16/abi/radf/C01/C01.shp',
'w',
driver='ESRI Shapefile',
schema={'geometry': 'Polygon', 'properties': {'location': 'str', 'time': 'str:19'}})
bbox = mapping(box(-50000, -50000, 50000, 50000))
s_file.write({
"geometry": bbox,
"properties": {
"location": "/data/tiles/g16/abi/radf/${C01_GTIFF_NAME}",
"time": "${C01_ISOTIME}",
},
})
EOF
}
add_postgres_content() {
......@@ -67,6 +85,14 @@ CREATE TABLE IF NOT EXISTS g16_abi_radf_l1b_c01 (
bbox_geometry geometry(POLYGON, 930916)
)
EOF
# docker exec -i ${PG_SERVER_NAME} psql -U ${POSTGRES_USER} <<EOF
# CREATE TABLE IF NOT EXISTS g16_abi_radf_l1b_c01 (
# gid SERIAL PRIMARY KEY,
# start_time CHAR(19) NOT NULL UNIQUE,
# location VARCHAR(255) NOT NULL,
# bbox_geometry geometry(POLYGON, 930916)
# )
# EOF
}
add_postgres_projections() {
......@@ -139,10 +165,12 @@ curl_layer_times() {
# []
# ["2020-12-25T15:29:25"]
if [[ ${time_result} == $expected_result ]]; then
debug "Time result (${time_result}) was not equal to the expected ${expected_result}"
if [[ "${time_result}" != "${expected_result}" ]]; then
error "Time result (${time_result}) was not equal to the expected ${expected_result}"
return 1
fi
debug "Time result (${time_result}) was equal to the expected ${expected_result}"
return $time_status
}
curl_empty_tile() {
......@@ -152,20 +180,19 @@ curl_empty_tile() {
}
run_basic_shapefile_tests() {
set -e
setup_test
debug "Starting shapefile tests..."
start_test_container
add_shapefile_content
curl_index
curl_layer_times "[]"
curl_layer_times "[\"${C01_ISOTIME}\"]"
curl_empty_tile
teardown_test
debug "SUCCESS: Shapefile test completed successfully"
set +e
}
run_basic_postgres_tests() {
set -e
setup_test
debug "Starting postgres tests..."
start_postgres
......@@ -179,22 +206,16 @@ run_basic_postgres_tests() {
curl_empty_tile
debug "SUCCESS: Postgres test completed successfully"
teardown_test
set +e
}
trap graceful_exit EXIT
exit_status=0
run_basic_shapefile_tests || exit_status=1
set -e
run_basic_shapefile_tests
echo "#######"
run_basic_postgres_tests || exit_status=1
run_basic_postgres_tests
echo "#######"
if [[ $exit_status -eq 0 ]]; then
debug "SUCCESS"
trap - EXIT # tests should have cleared this already, otherwise produces extra output
else
debug "FAIL"
fi
exit $exit_status
trap - EXIT # tests should have cleared this already, otherwise produces extra output
debug "SUCCESS"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment