Integration tests for the data observatory

This commit is contained in:
Mario de Frutos
2016-04-20 12:47:29 +02:00
parent 3c5325c1d7
commit 1daf78e41a
13 changed files with 59 additions and 14 deletions

View File

@@ -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)

View File

@@ -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"])

View File

@@ -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)

View File

@@ -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)

View File

@@ -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']

View File

@@ -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']

View File

@@ -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")

View File

@@ -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']

View File

@@ -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']

View File

@@ -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']

View File

@@ -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']

View File

@@ -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']

View File

@@ -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']