Added isolines integration tests
This commit is contained in:
parent
448f47589a
commit
826a3e65c0
@ -29,4 +29,4 @@ class IntegrationTestHelper:
|
||||
raise Exception(json.loads(query_response.text)['error'])
|
||||
query_response_data = json.loads(query_response.text)
|
||||
|
||||
return query_response_data['rows'][0]['geometry']
|
||||
return query_response_data['rows'][0]
|
||||
|
@ -16,16 +16,15 @@ class TestAdmin0Functions(TestCase):
|
||||
|
||||
def test_if_select_with_admin0_is_ok(self):
|
||||
query = "SELECT cdb_geocode_admin0_polygon(country) as geometry " \
|
||||
"FROM {0} LIMIT 1&api_key={1}".format(
|
||||
self.env_variables['table_name'],
|
||||
self.env_variables['api_key'])
|
||||
"FROM {0} LIMIT 1&api_key={1}".format(
|
||||
self.env_variables['table_name'],
|
||||
self.env_variables['api_key'])
|
||||
geometry = IntegrationTestHelper.execute_query(self.sql_api_url, query)
|
||||
assert_not_equal(geometry, None)
|
||||
assert_not_equal(geometry['geometry'], None)
|
||||
|
||||
def test_if_select_with_admin0_without_api_key_raise_error(self):
|
||||
query = "SELECT cdb_geocode_admin0_polygon(country) as geometry " \
|
||||
"FROM {0} LIMIT 1".format(
|
||||
self.env_variables['table_name'])
|
||||
"FROM {0} LIMIT 1".format(self.env_variables['table_name'])
|
||||
try:
|
||||
IntegrationTestHelper.execute_query(self.sql_api_url, query)
|
||||
except Exception as e:
|
||||
|
@ -20,7 +20,7 @@ class TestAdmin1Functions(TestCase):
|
||||
self.env_variables['table_name'],
|
||||
self.env_variables['api_key'])
|
||||
geometry = IntegrationTestHelper.execute_query(self.sql_api_url, query)
|
||||
assert_not_equal(geometry, None)
|
||||
assert_not_equal(geometry['geometry'], None)
|
||||
|
||||
def test_if_select_with_admin1_with_country_is_ok(self):
|
||||
query = "SELECT cdb_geocode_admin1_polygon(province,country)" \
|
||||
@ -28,7 +28,7 @@ class TestAdmin1Functions(TestCase):
|
||||
self.env_variables['table_name'],
|
||||
self.env_variables['api_key'])
|
||||
geometry = IntegrationTestHelper.execute_query(self.sql_api_url, query)
|
||||
assert_not_equal(geometry, None)
|
||||
assert_not_equal(geometry['geometry'], None)
|
||||
|
||||
def test_if_select_with_admin1_without_api_key_raise_error(self):
|
||||
query = "SELECT cdb_geocode_admin1_polygon(province) as geometry " \
|
||||
|
@ -20,7 +20,7 @@ class TestPostalcodeFunctions(TestCase):
|
||||
self.env_variables['table_name'],
|
||||
self.env_variables['api_key'])
|
||||
geometry = IntegrationTestHelper.execute_query(self.sql_api_url, query)
|
||||
assert_not_equal(geometry, None)
|
||||
assert_not_equal(geometry['geometry'], None)
|
||||
|
||||
def test_if_select_with_ipaddress_without_api_key_raise_error(self):
|
||||
query = "SELECT cdb_geocode_ipaddress_point(ip) " \
|
||||
|
45
test/integration/test_isolines_functions.py
Normal file
45
test/integration/test_isolines_functions.py
Normal 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 TestIsolinesFunctions(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.env_variables = IntegrationTestHelper.get_environment_variables()
|
||||
self.sql_api_url = "https://{0}.{1}/api/v2/sql".format(
|
||||
self.env_variables['username'],
|
||||
self.env_variables['host'],
|
||||
self.env_variables['api_key']
|
||||
)
|
||||
|
||||
def test_if_select_with_isochrones_is_ok(self):
|
||||
query = "SELECT * FROM cdb_isochrone('POINT(-3.70568 40.42028)'::geometry, " \
|
||||
"'car', ARRAY[300]::integer[]);&api_key={0}".format(
|
||||
self.env_variables['api_key'])
|
||||
isolines = IntegrationTestHelper.execute_query(self.sql_api_url, query)
|
||||
assert_not_equal(isolines['the_geom'], None)
|
||||
|
||||
def test_if_select_with_isochrones_without_api_key_raise_error(self):
|
||||
query = "SELECT * FROM cdb_isochrone('POINT(-3.70568 40.42028)'::geometry, " \
|
||||
"'car', ARRAY[300]::integer[]);"
|
||||
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_select_with_isodistance_is_ok(self):
|
||||
query = "SELECT * FROM cdb_isodistance('POINT(-3.70568 40.42028)'::geometry, " \
|
||||
"'car', ARRAY[300]::integer[]);&api_key={0}".format(
|
||||
self.env_variables['api_key'])
|
||||
isolines = IntegrationTestHelper.execute_query(self.sql_api_url, query)
|
||||
assert_not_equal(isolines['the_geom'], None)
|
||||
|
||||
def test_if_select_with_isodistance_without_api_key_raise_error(self):
|
||||
query = "SELECT * FROM cdb_isodistance('POINT(-3.70568 40.42028)'::geometry, " \
|
||||
"'car', ARRAY[300]::integer[]);"
|
||||
try:
|
||||
IntegrationTestHelper.execute_query(self.sql_api_url, query)
|
||||
except Exception as e:
|
||||
assert_equal(e.message[0], "The api_key must be provided")
|
@ -20,7 +20,7 @@ class TestNameplaceFunctions(TestCase):
|
||||
self.env_variables['table_name'],
|
||||
self.env_variables['api_key'])
|
||||
geometry = IntegrationTestHelper.execute_query(self.sql_api_url, query)
|
||||
assert_not_equal(geometry, None)
|
||||
assert_not_equal(geometry['geometry'], None)
|
||||
|
||||
def test_if_select_with_namedplace_city_country_is_ok(self):
|
||||
query = "SELECT cdb_geocode_namedplace_point(city,country) " \
|
||||
@ -28,7 +28,7 @@ class TestNameplaceFunctions(TestCase):
|
||||
self.env_variables['table_name'],
|
||||
self.env_variables['api_key'])
|
||||
geometry = IntegrationTestHelper.execute_query(self.sql_api_url, query)
|
||||
assert_not_equal(geometry, None)
|
||||
assert_not_equal(geometry['geometry'], None)
|
||||
|
||||
def test_if_select_with_namedplace_city_province_country_is_ok(self):
|
||||
query = "SELECT cdb_geocode_namedplace_point(city,province,country) " \
|
||||
@ -36,7 +36,7 @@ class TestNameplaceFunctions(TestCase):
|
||||
self.env_variables['table_name'],
|
||||
self.env_variables['api_key'])
|
||||
geometry = IntegrationTestHelper.execute_query(self.sql_api_url, query)
|
||||
assert_not_equal(geometry, None)
|
||||
assert_not_equal(geometry['geometry'], None)
|
||||
|
||||
def test_if_select_with_namedplace_without_api_key_raise_error(self):
|
||||
query = "SELECT cdb_geocode_namedplace_point(city) as geometry " \
|
||||
|
@ -20,7 +20,7 @@ class TestPostalcodeFunctions(TestCase):
|
||||
self.env_variables['table_name'],
|
||||
self.env_variables['api_key'])
|
||||
geometry = IntegrationTestHelper.execute_query(self.sql_api_url, query)
|
||||
assert_not_equal(geometry, None)
|
||||
assert_not_equal(geometry['geometry'], None)
|
||||
|
||||
def test_if_select_with_postalcode_point_is_ok(self):
|
||||
query = "SELECT cdb_geocode_postalcode_point(postalcode, country) " \
|
||||
@ -28,7 +28,7 @@ class TestPostalcodeFunctions(TestCase):
|
||||
self.env_variables['table_name'],
|
||||
self.env_variables['api_key'])
|
||||
geometry = IntegrationTestHelper.execute_query(self.sql_api_url, query)
|
||||
assert_not_equal(geometry, None)
|
||||
assert_not_equal(geometry['geometry'], None)
|
||||
|
||||
def test_if_select_with_postalcode_without_api_key_raise_error(self):
|
||||
query = "SELECT cdb_geocode_postalcode_polygon(postalcode, country) " \
|
||||
|
@ -20,7 +20,7 @@ class TestStreetFunctions(TestCase):
|
||||
self.env_variables['table_name'],
|
||||
self.env_variables['api_key'])
|
||||
geometry = IntegrationTestHelper.execute_query(self.sql_api_url, query)
|
||||
assert_not_equal(geometry, None)
|
||||
assert_not_equal(geometry['geometry'], None)
|
||||
|
||||
def test_if_select_with_street_without_api_key_raise_error(self):
|
||||
query = "SELECT cdb_geocode_street_point(street) " \
|
||||
|
Loading…
Reference in New Issue
Block a user