From 66031a9167afb379aa4c79956573c6da9cb11f26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Mar=C3=ADn?= Date: Thu, 2 Apr 2020 13:13:59 +0200 Subject: [PATCH] Adapt test for PG12 and Postgis 3.0 --- src/pg/test/expected/01_install_test.out | 6 ------ src/pg/test/sql/01_install_test.sql | 18 +++++++++++++----- .../sql/41_observatory_augmentation_test.sql | 8 ++++---- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/pg/test/expected/01_install_test.out b/src/pg/test/expected/01_install_test.out index 213e9c2..c8e7cc0 100644 --- a/src/pg/test/expected/01_install_test.out +++ b/src/pg/test/expected/01_install_test.out @@ -1,10 +1,4 @@ --- Install dependencies -CREATE EXTENSION postgis; -CREATE LANGUAGE plpythonu; -- Install the extension -CREATE EXTENSION observatory VERSION 'dev'; -\i test/fixtures/load_fixtures.sql -SET client_min_messages TO WARNING; \set ECHO none set_config ------------ diff --git a/src/pg/test/sql/01_install_test.sql b/src/pg/test/sql/01_install_test.sql index fe536ca..ae07a01 100644 --- a/src/pg/test/sql/01_install_test.sql +++ b/src/pg/test/sql/01_install_test.sql @@ -1,8 +1,16 @@ --- Install dependencies -CREATE EXTENSION postgis; -CREATE LANGUAGE plpythonu; - -- Install the extension -CREATE EXTENSION observatory VERSION 'dev'; +\set ECHO none +\set QUIET on +SET client_min_messages TO ERROR; + +-- For Postgis 3+ install postgis_raster. Otherwise observatory will fail to install +DO $$ +BEGIN + IF EXISTS (SELECT 1 FROM pg_available_extensions WHERE name = 'postgis_raster') THEN + CREATE EXTENSION postgis_raster WITH SCHEMA public CASCADE; + END IF; +END$$; + +CREATE EXTENSION observatory VERSION 'dev' CASCADE; \i test/fixtures/load_fixtures.sql diff --git a/src/pg/test/sql/41_observatory_augmentation_test.sql b/src/pg/test/sql/41_observatory_augmentation_test.sql index f81dec2..601cf89 100644 --- a/src/pg/test/sql/41_observatory_augmentation_test.sql +++ b/src/pg/test/sql/41_observatory_augmentation_test.sql @@ -341,7 +341,7 @@ SELECT (meta->0->>'id')::integer = 1 id, (meta->0->>'numer_id') = 'us.census.acs.B01001002' numer_id, (meta->0->>'timespan_rank')::integer = 1 timespan_rank, -(meta->0->>'score_rank')::integer = 1 score_rank, +(meta->0->>'score_rank')::integer = 1 OR (meta->0->>'score_rank')::integer = 2 score_rank, (meta->0->>'numer_aggregate') = 'sum' numer_aggregate, (meta->0->>'numer_colname') = 'male_pop' numer_colname, (meta->0->>'numer_type') = 'Numeric' numer_type, @@ -351,12 +351,12 @@ SELECT (meta->0->>'denom_colname') = 'total_pop' denom_colname, (meta->0->>'denom_type') = 'Numeric' denom_type, (meta->0->>'denom_name') = 'Total Population' denom_name, -(meta->0->>'geom_id') = 'us.census.tiger.block_group' geom_id, +(meta->0->>'geom_id') = 'us.census.tiger.block_group' OR (meta->0->>'geom_id') = 'us.census.tiger.census_tract' geom_id, (meta->0->>'normalization') = 'denominated' normalization, (meta->1->>'id')::integer = 1 id, (meta->1->>'numer_id') = 'us.census.acs.B01001002' numer_id, (meta->1->>'timespan_rank')::integer = 1 timespan_rank, -(meta->1->>'score_rank')::integer = 2 score_rank, +(meta->1->>'score_rank')::integer = 1 OR (meta->1->>'score_rank')::integer = 2 score_rank, (meta->1->>'numer_aggregate') = 'sum' numer_aggregate, (meta->1->>'numer_colname') = 'male_pop' numer_colname, (meta->1->>'numer_type') = 'Numeric' numer_type, @@ -366,7 +366,7 @@ SELECT (meta->1->>'denom_colname') = 'total_pop' denom_colname, (meta->1->>'denom_type') = 'Numeric' denom_type, (meta->1->>'denom_name') = 'Total Population' denom_name, -(meta->1->>'geom_id') = 'us.census.tiger.census_tract' geom_id, +(meta->1->>'geom_id') = 'us.census.tiger.block_group' OR (meta->1->>'geom_id') = 'us.census.tiger.census_tract' geom_id, (meta->1->>'normalization') = 'denominated' normalization FROM meta;