updating tests after adding new fixtures

This commit is contained in:
Andy Eschbacher 2016-05-06 07:47:00 -04:00
parent d747d3d3a9
commit e39b438a0a
2 changed files with 36 additions and 38 deletions

View File

@ -1,13 +1,13 @@
\i test/fixtures/load_fixtures.sql
SET client_min_messages TO WARNING;
\set ECHO all
\set ECHO none
obs_getdemographicsnapshot_test_no_returns
t
(1 row)
obs_get_gini_index_at_test_point
obs_get_median_income_at_test_point
t
(1 row)
obs_get_gini_index_at_null_island
obs_get_median_income_at_null_island
t
(1 row)
obs_getpoints_for_test_point
@ -28,41 +28,41 @@ t
null_island_segmentation
t
(1 row)
getcategories_at_test_point_1|getcategories_at_test_point_2
t|t
getcategories_at_test_point_1
t
(1 row)
getcategories_at_null_island
t
(1 row)
obs_getmeasure
9516.27915900609
obs_getmeasure_total_pop_point
10923.093200390833950
(1 row)
obs_getmeasure
1655
obs_getmeasure_total_pop_polygon
12327.3133495107
(1 row)
obs_getmeasure
0.64652567975830779836
obs_getmeasure_total_male_point_denominator
0.62157894736842105263
(1 row)
obs_getmeasure
0.64652567975830815710
obs_getmeasure_total_male_poly_denominator
0.49026340444793965457
(1 row)
obs_getcategory
obs_getcategory_point
Wealthy, urban without Kids
(1 row)
obs_getcategory
obs_getcategory_polygon
Low income, mix of minorities
(1 row)
obs_getpopulation
9516.27915900609
10923.093200390833950
(1 row)
obs_getpopulation
1655
obs_getpopulation_polygon
12327.3133495107
(1 row)
obs_getuscensusmeasure_point_male_pop
6789.5647735060920500
(1 row)
obs_getuscensusmeasure
6152.51885204623
(1 row)
obs_getuscensusmeasure
1070
6043.63061042765
(1 row)
obs_getuscensuscategory
Wealthy, urban without Kids

View File

@ -46,9 +46,9 @@ WITH result as (
SELECT
(cdb_observatory._OBS_GetPoints(
cdb_observatory._TestPoint(),
'obs_1a098da56badf5f32e336002b0a81708c40d29cd'::text, -- see example in obs_geomtable
'obs_c6fb99c47d61289fbb8e561ff7773799d3fcc308'::text, -- block groups (see _obs_geomtable)
(Array['{"colname":"total_pop","tablename":"obs_1a098da56badf5f32e336002b0a81708c40d29cd","aggregate":"sum","name":"Total Population","type":"Numeric","description":"The total number of all people living in a given geographic area. This is a very useful catch-all denominator when calculating rates."}'::json])
))[1]::text = '{"value":4809.07989821893,"name":"Total Population","tablename":"obs_1a098da56badf5f32e336002b0a81708c40d29cd","aggregate":"sum","type":"Numeric","description":"The total number of all people living in a given geographic area. This is a very useful catch-all denominator when calculating rates."}'
))[1]::text = '{"value":10923.093200390833950,"name":"Total Population","tablename":"obs_1a098da56badf5f32e336002b0a81708c40d29cd","aggregate":"sum","type":"Numeric","description":"The total number of all people living in a given geographic area. This is a very useful catch-all denominator when calculating rates."}'
as OBS_GetPoints_for_test_point;
-- what happens at null island
@ -68,9 +68,9 @@ SELECT
SELECT
(cdb_observatory._OBS_GetPolygons(
cdb_observatory._TestArea(),
'obs_1a098da56badf5f32e336002b0a81708c40d29cd'::text, -- see example in obs_geomtable
'obs_c6fb99c47d61289fbb8e561ff7773799d3fcc308'::text, -- see example in obs_geomtable
Array['{"colname":"total_pop","tablename":"obs_1a098da56badf5f32e336002b0a81708c40d29cd","aggregate":"sum","name":"Total Population","type":"Numeric","description":"The total number of all people living in a given geographic area. This is a very useful catch-all denominator when calculating rates."}'::json]
))[1]::text = '{"value":1570.78845496678,"name":"Total Population","tablename":"obs_1a098da56badf5f32e336002b0a81708c40d29cd","aggregate":"sum","type":"Numeric","description":"The total number of all people living in a given geographic area. This is a very useful catch-all denominator when calculating rates."}'
))[1]::text = '{"value":12327.3133495107,"name":"Total Population","tablename":"obs_1a098da56badf5f32e336002b0a81708c40d29cd","aggregate":"sum","type":"Numeric","description":"The total number of all people living in a given geographic area. This is a very useful catch-all denominator when calculating rates."}'
as OBS_GetPolygons_for_test_point;
-- see what happens around null island
@ -102,9 +102,7 @@ WITH result as (
'us.census.tiger.census_tract'
)
)
select (expected)[1]::text = '{"category":"Wealthy, urban without Kids","name":"Spielman-Singleton Segments: 10 Clusters","tablename":"obs_65f29658e096ca1485bf683f65fdbc9f05ec3c5d","aggregate":null,"type":"Text","description":"Sociodemographic classes from Spielman and Singleton 2015, 10 clusters"}' as GetCategories_at_test_point_1,
(expected)[2]::text = '{"category":"Wealthy, urban without Kids","name":"Spielman-Singleton Segments: 10 Clusters","tablename":"obs_11ee8b82c877c073438bc935a91d3dfccef875d1","aggregate":null,"type":"Text","description":"Sociodemographic classes from Spielman and Singleton 2015, 10 clusters"}' as GetCategories_at_test_point_2,
array_length(expected, 1)
select (expected)[1]::text = '{"category":"Wealthy, urban without Kids","name":"Spielman-Singleton Segments: 10 Clusters","tablename":"obs_65f29658e096ca1485bf683f65fdbc9f05ec3c5d","aggregate":null,"type":"Text","description":"Sociodemographic classes from Spielman and Singleton 2015, 10 clusters"}' as GetCategories_at_test_point_1
from result;
WITH result as (
@ -115,7 +113,7 @@ WITH result as (
'us.census.tiger.census_tract'
)
)
select expected is null as GetCategories_at_null_island
select expected[0] is NULL as GetCategories_at_null_island
from result;
-- Point-based OBS_GetMeasure, default normalization (area)
@ -123,32 +121,32 @@ SELECT * FROM
cdb_observatory.OBS_GetMeasure(
cdb_observatory._TestPoint(),
'us.census.acs.B01001001'
);
) As t(OBS_GetMeasure_total_pop_point);
-- Poly-based OBS_GetMeasure, default normalization (none)
SELECT * FROM
cdb_observatory.OBS_GetMeasure(
cdb_observatory._TestArea(),
'us.census.acs.B01001001'
);
) As t(OBS_GetMeasure_total_pop_polygon);
-- Point-based OBS_GetMeasure with denominator normalization
SELECT cdb_observatory.OBS_GetMeasure(
cdb_observatory._TestPoint(),
'us.census.acs.B01001002', 'denominator');
'us.census.acs.B01001002', 'denominator') As OBS_GetMeasure_total_male_point_denominator;
-- Poly-based OBS_GetMeasure with denominator normalization
SELECT cdb_observatory.OBS_GetMeasure(
cdb_observatory._TestArea(),
'us.census.acs.B01001002', 'denominator');
'us.census.acs.B01001002', 'denominator') As OBS_GetMeasure_total_male_poly_denominator;
-- Point-based OBS_GetCategory
SELECT cdb_observatory.OBS_GetCategory(
cdb_observatory._TestPoint(), 'us.census.spielman_singleton_segments.X10');
cdb_observatory._TestPoint(), 'us.census.spielman_singleton_segments.X10') As OBS_GetCategory_point;
-- Poly-based OBS_GetCategory
SELECT cdb_observatory.OBS_GetCategory(
cdb_observatory._TestArea(), 'us.census.spielman_singleton_segments.X10');
cdb_observatory._TestArea(), 'us.census.spielman_singleton_segments.X10') As obs_getcategory_polygon;
-- Point-based OBS_GetPopulation, default normalization (area)
SELECT * FROM
@ -160,11 +158,11 @@ SELECT * FROM
SELECT * FROM
cdb_observatory.OBS_GetPopulation(
cdb_observatory._TestArea()
);
) As obs_getpopulation_polygon;
-- Point-based OBS_GetUSCensusMeasure, default normalization (area)
SELECT cdb_observatory.obs_getuscensusmeasure(
cdb_observatory._testpoint(), 'male population');
cdb_observatory._testpoint(), 'male population') As obs_getuscensusmeasure_point_male_pop;
-- Poly-based OBS_GetUSCensusMeasure, default normalization (none)
SELECT cdb_observatory.obs_getuscensusmeasure(