adding tests fro new json returning get methods
This commit is contained in:
@@ -41,34 +41,34 @@ Done.
|
|||||||
{female_pop,male_pop} | {}
|
{female_pop,male_pop} | {}
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
names | vals
|
obs_get_gini_index_at_test_point
|
||||||
--------------+----------
|
----------------------------------
|
||||||
{gini_index} | {0.3494}
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
names | vals
|
obs_get_gini_index_at_null_island
|
||||||
--------------+------
|
-----------------------------------
|
||||||
{gini_index} | {}
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
_obs_getpoints
|
obs_getpoints_for_test_point
|
||||||
--------------------
|
------------------------------
|
||||||
{4809.33511352425}
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
_obs_getpoints
|
obs_getpoints_for_null_island
|
||||||
----------------
|
-------------------------------
|
||||||
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
_obs_getpolygons
|
obs_getpolygons_for_test_point
|
||||||
--------------------
|
--------------------------------
|
||||||
{1570.72353789469}
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
_obs_getpolygons
|
obs_getpolygons_for_null_island
|
||||||
------------------
|
---------------------------------
|
||||||
{NULL}
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
segment_name | total_pop_quantile | male_pop_quantile | female_pop_quantile | median_age_quantile | white_pop_quantile | black_pop_quantile | asian_pop_quantile | hispanic_pop_quantile | not_us_citizen_pop_quantile | workers_16_and_over_quantile | commuters_by_car_truck_van_quantile | commuters_by_public_transportation_quantile | commuters_by_bus_quantile | commuters_by_subway_or_elevated_quantile | walked_to_work_quantile | worked_at_home_quantile | children_quantile | households_quantile | population_3_years_over_quantile | in_school_quantile | in_grades_1_to_4_quantile | in_grades_5_to_8_quantile | in_grades_9_to_12_quantile | in_undergrad_college_quantile | pop_25_years_over_quantile | high_school_diploma_quantile | bachelors_degree_quantile | masters_degree_quantile | pop_5_years_over_quantile | speak_only_english_at_home_quantile | speak_spanish_at_home_quantile | pop_determined_poverty_status_quantile | poverty_quantile | median_income_quantile | gini_index_quantile | income_per_capita_quantile | housing_units_quantile | vacant_housing_units_quantile | vacant_housing_units_for_rent_quantile | vacant_housing_units_for_sale_quantile | median_rent_quantile | percent_income_spent_on_rent_quantile | owner_occupied_housing_units_quantile | million_dollar_housing_units_quantile
|
segment_name | total_pop_quantile | male_pop_quantile | female_pop_quantile | median_age_quantile | white_pop_quantile | black_pop_quantile | asian_pop_quantile | hispanic_pop_quantile | not_us_citizen_pop_quantile | workers_16_and_over_quantile | commuters_by_car_truck_van_quantile | commuters_by_public_transportation_quantile | commuters_by_bus_quantile | commuters_by_subway_or_elevated_quantile | walked_to_work_quantile | worked_at_home_quantile | children_quantile | households_quantile | population_3_years_over_quantile | in_school_quantile | in_grades_1_to_4_quantile | in_grades_5_to_8_quantile | in_grades_9_to_12_quantile | in_undergrad_college_quantile | pop_25_years_over_quantile | high_school_diploma_quantile | bachelors_degree_quantile | masters_degree_quantile | pop_5_years_over_quantile | speak_only_english_at_home_quantile | speak_spanish_at_home_quantile | pop_determined_poverty_status_quantile | poverty_quantile | median_income_quantile | gini_index_quantile | income_per_capita_quantile | housing_units_quantile | vacant_housing_units_quantile | vacant_housing_units_for_rent_quantile | vacant_housing_units_for_sale_quantile | median_rent_quantile | percent_income_spent_on_rent_quantile | owner_occupied_housing_units_quantile | million_dollar_housing_units_quantile
|
||||||
|
|||||||
@@ -41,22 +41,28 @@ FROM
|
|||||||
-- -----------|-------
|
-- -----------|-------
|
||||||
-- gini_index | 0.3494
|
-- gini_index | 0.3494
|
||||||
|
|
||||||
SELECT * FROM
|
WITH result as (
|
||||||
cdb_observatory._OBS_Get(
|
SELECT _OBS_GetJSON::text as expected FROM
|
||||||
|
cdb_observatory._OBS_GetJSON(
|
||||||
cdb_observatory._TestPoint(),
|
cdb_observatory._TestPoint(),
|
||||||
Array['"us.census.acs".B19083001']::text[],
|
Array['"us.census.acs".B19083001']::text[],
|
||||||
'2009 - 2013',
|
'2009 - 2013',
|
||||||
'"us.census.tiger".block_group'
|
'"us.census.tiger".block_group'
|
||||||
);
|
)
|
||||||
|
) select expected = '{"value":0.3494,"name":"Gini Index","tablename":"obs_3e7cc9cfd403b912c57b42d5f9195af9ce2f3cdb","aggregate":"","type":"Numeric","description":""}'
|
||||||
|
from result;
|
||||||
|
|
||||||
-- gini index at null island
|
-- gini index at null island
|
||||||
SELECT * FROM
|
WITH result as (
|
||||||
cdb_observatory._OBS_Get(
|
SELECT count(_OBS_GetJSON) as expected FROM
|
||||||
|
cdb_observatory._OBS_GetJSON(
|
||||||
CDB_LatLng(0, 0),
|
CDB_LatLng(0, 0),
|
||||||
Array['"us.census.acs".B19083001']::text[],
|
Array['"us.census.acs".B19083001']::text[],
|
||||||
'2009 - 2013',
|
'2009 - 2013',
|
||||||
'"us.census.tiger".block_group'
|
'"us.census.tiger".block_group'
|
||||||
);
|
)
|
||||||
|
) select expected = 0 as OBS_Get_gini_index_at_null_island
|
||||||
|
from result;
|
||||||
|
|
||||||
-- OBS_GetPoints
|
-- OBS_GetPoints
|
||||||
-- obs_getpoints
|
-- obs_getpoints
|
||||||
@@ -64,19 +70,21 @@ SELECT * FROM
|
|||||||
-- {4809.33511352425}
|
-- {4809.33511352425}
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
cdb_observatory._OBS_GetPoints(
|
(cdb_observatory._OBS_GetPoints(
|
||||||
cdb_observatory._TestPoint(),
|
cdb_observatory._TestPoint(),
|
||||||
'obs_a92e1111ad3177676471d66bb8036e6d057f271b'::text, -- see example in obs_geomtable
|
'obs_a92e1111ad3177676471d66bb8036e6d057f271b'::text, -- see example in obs_geomtable
|
||||||
Array[('total_pop','obs_ab038198aaab3f3cb055758638ee4de28ad70146','sum')::cdb_observatory.OBS_ColumnData]
|
(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 = '{"value":4809.33511352425,"name":"Total Population","tablename":"obs_ab038198aaab3f3cb055758638ee4de28ad70146","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
|
-- what happens at null island
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
cdb_observatory._OBS_GetPoints(
|
(cdb_observatory._OBS_GetPoints(
|
||||||
CDB_LatLng(0, 0),
|
CDB_LatLng(0, 0),
|
||||||
'obs_a92e1111ad3177676471d66bb8036e6d057f271b'::text, -- see example in obs_geomtable
|
'obs_a92e1111ad3177676471d66bb8036e6d057f271b'::text, -- see example in obs_geomtable
|
||||||
Array[('total_pop','obs_ab038198aaab3f3cb055758638ee4de28ad70146','sum')::cdb_observatory.OBS_ColumnData]
|
(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
|
||||||
|
as OBS_GetPoints_for_null_island;
|
||||||
|
|
||||||
-- OBS_GetPolygons
|
-- OBS_GetPolygons
|
||||||
-- obs_getpolygons
|
-- obs_getpolygons
|
||||||
@@ -84,19 +92,21 @@ SELECT
|
|||||||
-- {12996.8172420752}
|
-- {12996.8172420752}
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
cdb_observatory._OBS_GetPolygons(
|
(cdb_observatory._OBS_GetPolygons(
|
||||||
cdb_observatory._TestArea(),
|
cdb_observatory._TestArea(),
|
||||||
'obs_a92e1111ad3177676471d66bb8036e6d057f271b'::text, -- see example in obs_geomtable
|
'obs_a92e1111ad3177676471d66bb8036e6d057f271b'::text, -- see example in obs_geomtable
|
||||||
Array[('total_pop','obs_ab038198aaab3f3cb055758638ee4de28ad70146','sum')::cdb_observatory.OBS_ColumnData]
|
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 = '{"value":12996.8172420752,"name":"Total Population","tablename":"obs_ab038198aaab3f3cb055758638ee4de28ad70146","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
|
-- see what happens around null island
|
||||||
SELECT
|
SELECT
|
||||||
cdb_observatory._OBS_GetPolygons(
|
(cdb_observatory._OBS_GetPolygons(
|
||||||
ST_Buffer(CDB_LatLng(0, 0)::geography, 500)::geometry,
|
ST_Buffer(CDB_LatLng(0, 0)::geography, 500)::geometry,
|
||||||
'obs_a92e1111ad3177676471d66bb8036e6d057f271b'::text, -- see example in obs_geomtable
|
'obs_a92e1111ad3177676471d66bb8036e6d057f271b'::text, -- see example in obs_geomtable
|
||||||
Array[('total_pop','obs_ab038198aaab3f3cb055758638ee4de28ad70146','sum')::cdb_observatory.OBS_ColumnData]
|
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
|
||||||
|
as OBS_GetPolygons_for_null_island;
|
||||||
|
|
||||||
SELECT * FROM
|
SELECT * FROM
|
||||||
cdb_observatory._OBS_GetSegmentSnapshot(
|
cdb_observatory._OBS_GetSegmentSnapshot(
|
||||||
|
|||||||
Reference in New Issue
Block a user