removing cdb_latlng from tests

This commit is contained in:
Andy Eschbacher
2016-04-27 10:54:54 -07:00
parent 11df52dc3b
commit a9d084e250
2 changed files with 22 additions and 22 deletions

View File

@@ -7,7 +7,7 @@
-- should give back a table like obs_{hex hash}
SELECT
cdb_observatory._OBS_GeomTable(
CDB_LatLng(40.7128,-74.0059),
ST_SetSRID(ST_Point(-74.0059, 40.7128), 4326),
'"us.census.tiger".census_tract'
);
@@ -15,14 +15,14 @@ SELECT
-- should give back null
SELECT
cdb_observatory._OBS_GeomTable(
CDB_LatLng(40.7128,-74.0059),
ST_SetSRID(ST_Point(-74.0059, 40.7128), 4326),
'"us.census.tiger".nonexistant_id' -- not in catalog
);
-- future test: give back nulls when geometry doesn't intersect
-- SELECT
-- cdb_observatory._OBS_GeomTable(
-- CDB_LatLng(0,0), -- should give back null since it's in the ocean?
-- ST_SetSRID(ST_Point(0,0)), -- should give back null since it's in the ocean?
-- '"us.census.tiger".census_tract'
-- );
@@ -37,7 +37,7 @@ SELECT
array_agg(a) expected from cdb_observatory._OBS_GetColumnData(
'"us.census.tiger".census_tract',
Array['"us.census.tiger".census_tract_geoid', '"us.census.acs".B01001001'],
'2009 - 2013') a
'2009 - 2013') a
)
select (expected)[1]::text = '{"colname":"geoid","tablename":"obs_d34555209878e8c4b37cf0b2b3d072ff129ec470","aggregate":null,"name":"US Census Tract Geoids","type":"Text","description":""}' as test_get_obs_column_with_geoid_and_census_1,
(expected)[2]::text = '{"colname":"geoid","tablename":"obs_ab038198aaab3f3cb055758638ee4de28ad70146","aggregate":null,"name":"US Census Tract Geoids","type":"Text","description":""}' as test_get_obs_column_with_geoid_and_census_2
@@ -50,7 +50,7 @@ SELECT
array_agg(a) expected from cdb_observatory._OBS_GetColumnData(
'"us.census.tiger".census_tract',
Array['"us.census.tiger".baloney'],
'2009 - 2013') a
'2009 - 2013') a
)
select expected is null as OBS_GetColumnData_missing_measure
from result;

View File

@@ -13,12 +13,12 @@ FROM result;
WITH result as (
SELECT array_agg(_obs_getcensus->>'value') as b
FROM( select * from
FROM( select * from
cdb_observatory._OBS_GetCensus(
cdb_observatory._TestPoint(),
Array['total_pop','male_pop']::text[]
)) a
)
)
select b='{9516.27915900609,6152.51885204623}'
as test_obsGetCensusWithTestPointAnd2Variables
from result;
@@ -27,24 +27,24 @@ select b='{9516.27915900609,6152.51885204623}'
WITH result as (
SELECT count(vals) non_null
FROM( select _OBS_GetCensus->>'value' vals from
FROM( select _OBS_GetCensus->>'value' vals from
cdb_observatory._OBS_GetCensus(
ST_Buffer(CDB_LatLng(0, 0)::geography, 5000)::geometry,
ST_Buffer(ST_SetSRID(ST_Point(0, 0), 4326)::geography, 5000)::geometry,
Array['total_pop','male_pop']::text[]
)) a
)
)
SELECT non_null = 0 as test_obsGetCensusWithNullIslandArea
FROM result;
-- expect nulls back {female_pop, male_pop} | {NULL, NULL}
WITH result as (
SELECT count(vals) non_null
FROM( select _OBS_GetCensus->>'value' vals from
FROM( select _OBS_GetCensus->>'value' vals from
cdb_observatory._OBS_GetCensus(
CDB_LatLng(0, 0),
ST_SetSRID(ST_Point(0, 0), 4326),
Array['total_pop','male_pop']::text[]
)) a
)
)
SELECT non_null = 0 as test_obsGetCensusWithNullIsland
FROM result;
@@ -60,7 +60,7 @@ WITH result as (
Array['"us.census.acs".B19083001']::text[],
'2009 - 2013',
'"us.census.tiger".block_group'
)
)
) select expected = '{"value":0.3494,"name":"Gini Index","tablename":"obs_3e7cc9cfd403b912c57b42d5f9195af9ce2f3cdb","aggregate":"","type":"Numeric","description":""}'
as OBS_Get_gini_index_at_test_point
from result;
@@ -69,14 +69,14 @@ WITH result as (
WITH result as (
SELECT count(_OBS_Get) as expected FROM
cdb_observatory._OBS_Get(
CDB_LatLng(0, 0),
ST_SetSRID(ST_Point(0, 0), 4326),
Array['"us.census.acs".B19083001']::text[],
'2009 - 2013',
'"us.census.tiger".block_group'
)
)
) select expected = 0 as OBS_Get_gini_index_at_null_island
from result;
-- OBS_GetPoints
-- obs_getpoints
-- --------------------
@@ -93,7 +93,7 @@ SELECT
SELECT
(cdb_observatory._OBS_GetPoints(
CDB_LatLng(0, 0),
ST_SetSRID(ST_Point(0, 0), 4326),
'obs_a92e1111ad3177676471d66bb8036e6d057f271b'::text, -- see example in obs_geomtable
(Array['{"colname":"total_pop","tablename":"obs_ab038198aaab3f3cb055758638ee4de28ad70146","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 is null
@@ -115,7 +115,7 @@ SELECT
-- see what happens around null island
SELECT
(cdb_observatory._OBS_GetPolygons(
ST_Buffer(CDB_LatLng(0, 0)::geography, 500)::geometry,
ST_Buffer(ST_SetSRID(ST_Point(0, 0), 4326)::geography, 500)::geometry,
'obs_a92e1111ad3177676471d66bb8036e6d057f271b'::text, -- see example in obs_geomtable
Array['{"colname":"total_pop","tablename":"obs_ab038198aaab3f3cb055758638ee4de28ad70146","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]->>'value' is null
@@ -128,7 +128,7 @@ SELECT cdb_observatory.OBS_GetSegmentSnapshot(
-- segmentation around null island
SELECT cdb_observatory.OBS_GetSegmentSnapshot(
CDB_LatLng(0, 0),
ST_SetSRID(ST_Point(0, 0), 4326),
'"us.census.tiger".census_tract'
)::text = '{"segment_name":null,"\"us.census.acs\".B01001001_quantile":null,"\"us.census.acs\".B01001002_quantile":null,"\"us.census.acs\".B01001026_quantile":null,"\"us.census.acs\".B01002001_quantile":null,"\"us.census.acs\".B03002003_quantile":null,"\"us.census.acs\".B03002004_quantile":null,"\"us.census.acs\".B03002006_quantile":null,"\"us.census.acs\".B03002012_quantile":null,"\"us.census.acs\".B05001006_quantile":null,"\"us.census.acs\".B08006001_quantile":null,"\"us.census.acs\".B08006002_quantile":null,"\"us.census.acs\".B08006008_quantile":null,"\"us.census.acs\".B08006009_quantile":null,"\"us.census.acs\".B08006011_quantile":null,"\"us.census.acs\".B08006015_quantile":null,"\"us.census.acs\".B08006017_quantile":null,"\"us.census.acs\".B09001001_quantile":null,"\"us.census.acs\".B11001001_quantile":null,"\"us.census.acs\".B14001001_quantile":null,"\"us.census.acs\".B14001002_quantile":null,"\"us.census.acs\".B14001005_quantile":null,"\"us.census.acs\".B14001006_quantile":null,"\"us.census.acs\".B14001007_quantile":null,"\"us.census.acs\".B14001008_quantile":null,"\"us.census.acs\".B15003001_quantile":null,"\"us.census.acs\".B15003017_quantile":null,"\"us.census.acs\".B15003022_quantile":null,"\"us.census.acs\".B15003023_quantile":null,"\"us.census.acs\".B16001001_quantile":null,"\"us.census.acs\".B16001002_quantile":null,"\"us.census.acs\".B16001003_quantile":null,"\"us.census.acs\".B17001001_quantile":null,"\"us.census.acs\".B17001002_quantile":null,"\"us.census.acs\".B19013001_quantile":null,"\"us.census.acs\".B19083001_quantile":null,"\"us.census.acs\".B19301001_quantile":null,"\"us.census.acs\".B25001001_quantile":null,"\"us.census.acs\".B25002003_quantile":null,"\"us.census.acs\".B25004002_quantile":null,"\"us.census.acs\".B25004004_quantile":null,"\"us.census.acs\".B25058001_quantile":null,"\"us.census.acs\".B25071001_quantile":null,"\"us.census.acs\".B25075001_quantile":null,"\"us.census.acs\".B25075025_quantile":null}' as null_island_segmentation;
@@ -143,11 +143,11 @@ WITH result as (
select (expected)[1]::text = '{"category":"Wealthy, urban without Kids","name":"SS_segment_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":"SS_segment_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
from result;
WITH result as (
SELECT array_agg(_OBS_GetCategories) as expected FROM
cdb_observatory._OBS_GetCategories(
CDB_LatLng(0,0),
ST_SetSRID(ST_Point(0,0), 4326),
Array['"us.census.spielman_singleton_segments".X10'],
'"us.census.tiger".census_tract'
)