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

Add fake postgres record to unit test

parent b64aaa5d
No related branches found
No related tags found
No related merge requests found
Pipeline #36969 failed with stages
in 5 minutes and 57 seconds
......@@ -75,7 +75,16 @@ s_file.write({
EOF
}
add_postgres_content() {
add_postgres_projections() {
# copied from tile gen
debug "Creating PostGIS projections"
docker exec -i ${PG_SERVER_NAME} psql -U ${POSTGRES_USER} <<EOF
INSERT into spatial_ref_sys (srid, auth_name, auth_srid, srtext, proj4text)
values (930916, 'EPSG', 4269, 'PROJCRS["GOES-16 ABI Fixed Grid",BASEGEOGCRS["GOES-16 ABI Fixed Grid",DATUM["North American Datum 1983",ELLIPSOID["GRS 1980",6378137,298.257222101,LENGTHUNIT["metre",1]],ID["EPSG",6269]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8901]]],CONVERSION["unknown",METHOD["Geostationary Satellite (Sweep X)"],PARAMETER["Longitude of natural origin",-75,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8802]],PARAMETER["Satellite Height",35786023,LENGTHUNIT["metre",1,ID["EPSG",9001]]],PARAMETER["False easting",0,LENGTHUNIT["metre",1],ID["EPSG",8806]],PARAMETER["False northing",0,LENGTHUNIT["metre",1],ID["EPSG",8807]]],CS[Cartesian,2],AXIS["(E)",east,ORDER[1],LENGTHUNIT["metre",1,ID["EPSG",9001]]],AXIS["(N)",north,ORDER[2],LENGTHUNIT["metre",1,ID["EPSG",9001]]]]', '+proj=geos +sweep=x +lon_0=-75 +h=35786023 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs +type=crs') ON CONFLICT (srid) DO NOTHING
EOF
}
add_postgres_tables() {
debug "Creating PostGIS table"
docker exec -i ${PG_SERVER_NAME} psql -U ${POSTGRES_USER} <<EOF
CREATE TABLE IF NOT EXISTS g16_abi_radf_l1b_c01 (
......@@ -85,22 +94,27 @@ 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() {
# copied from tile gen
debug "Creating PostGIS projections"
add_postgres_content() {
debug "Creating values for fake DB row for C01"
insert_values=$(docker exec -i test python3 <<EOF
from shapely.geometry import box
from shapely import wkb
dt_str = "${C01_ISOTIME}"
location = "/data/tiles/g16/abi/radf/${C01_GTIFF_NAME}"
bbox = box(-50000, -50000, 50000, 50000)
bbox_wkb = wkb.dumps(bbox, hex=True, srid=930916)
values = (dt_str, location, bbox_wkb)
print(repr(values))
EOF
)
debug "Inserting fake DB row for C01"
docker exec -i ${PG_SERVER_NAME} psql -U ${POSTGRES_USER} <<EOF
INSERT into spatial_ref_sys (srid, auth_name, auth_srid, srtext, proj4text)
values (930916, 'EPSG', 4269, 'PROJCRS["GOES-16 ABI Fixed Grid",BASEGEOGCRS["GOES-16 ABI Fixed Grid",DATUM["North American Datum 1983",ELLIPSOID["GRS 1980",6378137,298.257222101,LENGTHUNIT["metre",1]],ID["EPSG",6269]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8901]]],CONVERSION["unknown",METHOD["Geostationary Satellite (Sweep X)"],PARAMETER["Longitude of natural origin",-75,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8802]],PARAMETER["Satellite Height",35786023,LENGTHUNIT["metre",1,ID["EPSG",9001]]],PARAMETER["False easting",0,LENGTHUNIT["metre",1],ID["EPSG",8806]],PARAMETER["False northing",0,LENGTHUNIT["metre",1],ID["EPSG",8807]]],CS[Cartesian,2],AXIS["(E)",east,ORDER[1],LENGTHUNIT["metre",1,ID["EPSG",9001]]],AXIS["(N)",north,ORDER[2],LENGTHUNIT["metre",1,ID["EPSG",9001]]]]', '+proj=geos +sweep=x +lon_0=-75 +h=35786023 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs +type=crs') ON CONFLICT (srid) DO NOTHING
INSERT into g16_abi_radf_l1b_c01 (start_time, location, bbox_geometry)
VALUES ${insert_values} ON CONFLICT (start_time) DO NOTHING
RETURNING (start_time)
EOF
}
......@@ -199,10 +213,11 @@ run_basic_postgres_tests() {
start_pg_test_container
add_shapefile_content
add_postgres_projections
add_postgres_tables
add_postgres_content
curl_index
curl_layer_times "[]"
curl_layer_times "[\"${C01_ISOTIME}\"]"
curl_empty_tile
debug "SUCCESS: Postgres test completed successfully"
teardown_test
......
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