Added isolines integration tests

This commit is contained in:
Mario de Frutos 2016-02-24 09:54:00 +01:00
parent 448f47589a
commit 826a3e65c0
8 changed files with 60 additions and 16 deletions

View File

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

View File

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

View File

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

View File

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

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

View File

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

View File

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

View File

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