diff --git a/server/extension/sql/100_routing_helper.sql b/server/extension/sql/100_routing_helper.sql index 603753f..7ef9916 100644 --- a/server/extension/sql/100_routing_helper.sql +++ b/server/extension/sql/100_routing_helper.sql @@ -25,7 +25,7 @@ RETURNS cdb_dataservices_server.simple_route AS $$ quota_service = QuotaService(user_routing_config, redis_conn) if not quota_service.check_user_quota(): - plpy.error('You have reach the limit of your quota') + plpy.error('You have reached the limit of your quota') try: client = MapzenRouting(user_routing_config.mapzen_api_key) diff --git a/server/extension/sql/110_data_observatory.sql b/server/extension/sql/110_data_observatory.sql index b4394a1..b77b101 100644 --- a/server/extension/sql/110_data_observatory.sql +++ b/server/extension/sql/110_data_observatory.sql @@ -15,7 +15,7 @@ RETURNS json AS $$ quota_service = QuotaService(user_data_observatory_config, redis_conn) if not quota_service.check_user_quota(): - plpy.error('You have reach the limit of your quota') + plpy.error('You have reached the limit of your quota') try: obs_plan = plpy.prepare("SELECT cdb_observatory.OBS_GetDemographicSnapshot($1, $2, $3) as snapshot;", ["geometry(Geometry, 4326)", "text", "text"]) @@ -53,7 +53,7 @@ RETURNS json AS $$ quota_service = QuotaService(user_data_observatory_config, redis_conn) if not quota_service.check_user_quota(): - plpy.error('You have reach the limit of your quota') + plpy.error('You have reached the limit of your quota') try: obs_plan = plpy.prepare("SELECT cdb_observatory.OBS_GetSegmentSnapshot($1, $2) as snapshot;", ["geometry(Geometry, 4326)", "text"]) diff --git a/server/extension/sql/20_geocode_street.sql b/server/extension/sql/20_geocode_street.sql index 035aeef..a955f78 100644 --- a/server/extension/sql/20_geocode_street.sql +++ b/server/extension/sql/20_geocode_street.sql @@ -31,7 +31,7 @@ RETURNS Geometry AS $$ # -- Check the quota quota_service = QuotaService(user_geocoder_config, redis_conn) if not quota_service.check_user_quota(): - plpy.error('You have reach the limit of your quota') + plpy.error('You have reached the limit of your quota') try: geocoder = HereMapsGeocoder(user_geocoder_config.heremaps_app_id, user_geocoder_config.heremaps_app_code) @@ -96,7 +96,7 @@ RETURNS Geometry AS $$ user_geocoder_config = GD["user_geocoder_config_{0}".format(username)] quota_service = QuotaService(user_geocoder_config, redis_conn) if not quota_service.check_user_quota(): - plpy.error('You have reach the limit of your quota') + plpy.error('You have reached the limit of your quota') try: geocoder = MapzenGeocoder(user_geocoder_config.mapzen_api_key) diff --git a/server/extension/sql/80_isolines_helper.sql b/server/extension/sql/80_isolines_helper.sql index 7eb7cdc..eaa84a1 100644 --- a/server/extension/sql/80_isolines_helper.sql +++ b/server/extension/sql/80_isolines_helper.sql @@ -13,7 +13,7 @@ RETURNS SETOF cdb_dataservices_server.isoline AS $$ # -- Check the quota quota_service = QuotaService(user_isolines_routing_config, redis_conn) if not quota_service.check_user_quota(): - plpy.error('You have reach the limit of your quota') + plpy.error('You have reached the limit of your quota') try: client = HereMapsRoutingIsoline(user_isolines_routing_config.heremaps_app_id, user_isolines_routing_config.heremaps_app_code, base_url = HereMapsRoutingIsoline.PRODUCTION_ROUTING_BASE_URL) diff --git a/test/integration/test_admin0_functions.py b/test/integration/test_admin0_functions.py index 8958502..4393ee3 100644 --- a/test/integration/test_admin0_functions.py +++ b/test/integration/test_admin0_functions.py @@ -8,7 +8,7 @@ class TestAdmin0Functions(TestCase): def setUp(self): self.env_variables = IntegrationTestHelper.get_environment_variables() - self.sql_api_url = "https://{0}.{1}/api/v2/sql".format( + self.sql_api_url = "https://{0}.{1}/api/v1/sql".format( self.env_variables['username'], self.env_variables['host'], self.env_variables['api_key'] diff --git a/test/integration/test_admin1_functions.py b/test/integration/test_admin1_functions.py index 8e09d70..703b071 100644 --- a/test/integration/test_admin1_functions.py +++ b/test/integration/test_admin1_functions.py @@ -8,7 +8,7 @@ class TestAdmin1Functions(TestCase): def setUp(self): self.env_variables = IntegrationTestHelper.get_environment_variables() - self.sql_api_url = "https://{0}.{1}/api/v2/sql".format( + self.sql_api_url = "https://{0}.{1}/api/v1/sql".format( self.env_variables['username'], self.env_variables['host'], self.env_variables['api_key'] diff --git a/test/integration/test_data_observatory_functions.py b/test/integration/test_data_observatory_functions.py new file mode 100644 index 0000000..8e247a3 --- /dev/null +++ b/test/integration/test_data_observatory_functions.py @@ -0,0 +1,45 @@ +from unittest import TestCase +from nose.tools import assert_raises +from nose.tools import assert_not_equal, assert_equal +from ..helpers.integration_test_helper import IntegrationTestHelper + + +class TestDataObservatoryFunctions(TestCase): + + def setUp(self): + self.env_variables = IntegrationTestHelper.get_environment_variables() + self.sql_api_url = "https://{0}.{1}/api/v1/sql".format( + self.env_variables['username'], + self.env_variables['host'], + self.env_variables['api_key'] + ) + + def test_if_get_demographic_snapshot_is_ok(self): + query = "SELECT duration, length, shape as the_geom " \ + "FROM cdb_do_get_demographic_snapshot(CDB_LatLng(40.704512, -73.936669))".format( + self.env_variables['api_key']) + routing = IntegrationTestHelper.execute_query(self.sql_api_url, query) + assert_not_equal(routing['the_geom'], None) + + def test_if_get_demographic_snapshot_without_api_key_raise_error(self): + query = "SELECT duration, length, shape as the_geom " \ + "FROM cdb_do_get_demographic_snapshot(CDB_LatLng(40.704512, -73.936669))" + try: + IntegrationTestHelper.execute_query(self.sql_api_url, query) + except Exception as e: + assert_equal(e.message[0], "The api_key must be provided") + + def test_if_get_segment_snapshot_is_ok(self): + query = "SELECT duration, length, shape as the_geom " \ + "FROM cdb_do_get_segment_snapshot(CDB_LatLng(40.704512, -73.936669))".format( + self.env_variables['api_key']) + routing = IntegrationTestHelper.execute_query(self.sql_api_url, query) + assert_not_equal(routing['the_geom'], None) + + def test_if_get_segment_snapshot_without_api_key_raise_error(self): + query = "SELECT duration, length, shape as the_geom " \ + "FROM cdb_do_get_segment_snapshot(CDB_LatLng(40.704512, -73.936669))" + try: + IntegrationTestHelper.execute_query(self.sql_api_url, query) + except Exception as e: + assert_equal(e.message[0], "The api_key must be provided") diff --git a/test/integration/test_ipaddress_functions.py b/test/integration/test_ipaddress_functions.py index 69056b6..29011a6 100644 --- a/test/integration/test_ipaddress_functions.py +++ b/test/integration/test_ipaddress_functions.py @@ -8,7 +8,7 @@ class TestPostalcodeFunctions(TestCase): def setUp(self): self.env_variables = IntegrationTestHelper.get_environment_variables() - self.sql_api_url = "https://{0}.{1}/api/v2/sql".format( + self.sql_api_url = "https://{0}.{1}/api/v1/sql".format( self.env_variables['username'], self.env_variables['host'], self.env_variables['api_key'] diff --git a/test/integration/test_isolines_functions.py b/test/integration/test_isolines_functions.py index 936699c..0949867 100644 --- a/test/integration/test_isolines_functions.py +++ b/test/integration/test_isolines_functions.py @@ -8,7 +8,7 @@ class TestIsolinesFunctions(TestCase): def setUp(self): self.env_variables = IntegrationTestHelper.get_environment_variables() - self.sql_api_url = "https://{0}.{1}/api/v2/sql".format( + self.sql_api_url = "https://{0}.{1}/api/v1/sql".format( self.env_variables['username'], self.env_variables['host'], self.env_variables['api_key'] diff --git a/test/integration/test_namedplace_functions.py b/test/integration/test_namedplace_functions.py index 6b7abf5..a091422 100644 --- a/test/integration/test_namedplace_functions.py +++ b/test/integration/test_namedplace_functions.py @@ -8,7 +8,7 @@ class TestNameplaceFunctions(TestCase): def setUp(self): self.env_variables = IntegrationTestHelper.get_environment_variables() - self.sql_api_url = "https://{0}.{1}/api/v2/sql".format( + self.sql_api_url = "https://{0}.{1}/api/v1/sql".format( self.env_variables['username'], self.env_variables['host'], self.env_variables['api_key'] diff --git a/test/integration/test_postalcode_functions.py b/test/integration/test_postalcode_functions.py index 07055f9..6e50c5c 100644 --- a/test/integration/test_postalcode_functions.py +++ b/test/integration/test_postalcode_functions.py @@ -8,7 +8,7 @@ class TestPostalcodeFunctions(TestCase): def setUp(self): self.env_variables = IntegrationTestHelper.get_environment_variables() - self.sql_api_url = "https://{0}.{1}/api/v2/sql".format( + self.sql_api_url = "https://{0}.{1}/api/v1/sql".format( self.env_variables['username'], self.env_variables['host'], self.env_variables['api_key'] diff --git a/test/integration/test_routing_functions.py b/test/integration/test_routing_functions.py index 3f02f01..61dd7ec 100644 --- a/test/integration/test_routing_functions.py +++ b/test/integration/test_routing_functions.py @@ -8,7 +8,7 @@ class TestRoutingFunctions(TestCase): def setUp(self): self.env_variables = IntegrationTestHelper.get_environment_variables() - self.sql_api_url = "https://{0}.{1}/api/v2/sql".format( + self.sql_api_url = "https://{0}.{1}/api/v1/sql".format( self.env_variables['username'], self.env_variables['host'], self.env_variables['api_key'] diff --git a/test/integration/test_street_functions.py b/test/integration/test_street_functions.py index 8b82f68..c9647ff 100644 --- a/test/integration/test_street_functions.py +++ b/test/integration/test_street_functions.py @@ -8,7 +8,7 @@ class TestStreetFunctions(TestCase): def setUp(self): self.env_variables = IntegrationTestHelper.get_environment_variables() - self.sql_api_url = "https://{0}.{1}/api/v2/sql".format( + self.sql_api_url = "https://{0}.{1}/api/v1/sql".format( self.env_variables['username'], self.env_variables['host'], self.env_variables['api_key']