From 45d9edbba635af5ef5c9c59bff42fbfb346bcf31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Ignacio=20S=C3=A1nchez=20Lara?= Date: Tue, 13 Feb 2018 15:58:10 +0100 Subject: [PATCH 01/10] Mapbox test API key is supplied now through a MAPBOX_API_KEY environment variable --- server/lib/python/cartodb_services/test/credentials.py | 6 ++++++ .../lib/python/cartodb_services/test/test_mapboxgeocoder.py | 4 ++-- .../lib/python/cartodb_services/test/test_mapboxisoline.py | 4 ++-- .../lib/python/cartodb_services/test/test_mapboxmatrix.py | 4 ++-- .../lib/python/cartodb_services/test/test_mapboxrouting.py | 4 ++-- 5 files changed, 14 insertions(+), 8 deletions(-) create mode 100644 server/lib/python/cartodb_services/test/credentials.py diff --git a/server/lib/python/cartodb_services/test/credentials.py b/server/lib/python/cartodb_services/test/credentials.py new file mode 100644 index 0000000..1818f84 --- /dev/null +++ b/server/lib/python/cartodb_services/test/credentials.py @@ -0,0 +1,6 @@ +import os + +def api_key(): + """Returns Mapbox API key. Requires setting MAPBOX_API_KEY environment variable.""" + return os.environ['MAPBOX_API_KEY'] + diff --git a/server/lib/python/cartodb_services/test/test_mapboxgeocoder.py b/server/lib/python/cartodb_services/test/test_mapboxgeocoder.py index 910da0a..286bcaa 100644 --- a/server/lib/python/cartodb_services/test/test_mapboxgeocoder.py +++ b/server/lib/python/cartodb_services/test/test_mapboxgeocoder.py @@ -2,8 +2,8 @@ import unittest from mock import Mock from cartodb_services.mapbox import MapboxGeocoder from cartodb_services.tools.exceptions import ServiceException +import credentials -VALID_TOKEN = 'pk.eyJ1IjoiYWNhcmxvbiIsImEiOiJjamJuZjQ1Zjc0Ymt4Mnh0YmFrMmhtYnY4In0.gt9cw0VeKc3rM2mV5pcEmg' INVALID_TOKEN = 'invalid_token' VALID_ADDRESS = 'Calle Siempreviva 3, Valladolid' WELL_KNOWN_LONGITUDE = -4.730947 @@ -12,7 +12,7 @@ WELL_KNOWN_LATITUDE = 41.668654 class MapboxGeocoderTestCase(unittest.TestCase): def setUp(self): - self.geocoder = MapboxGeocoder(token=VALID_TOKEN, logger=Mock()) + self.geocoder = MapboxGeocoder(token=credentials.api_key(), logger=Mock()) def test_invalid_token(self): invalid_geocoder = MapboxGeocoder(token=INVALID_TOKEN, logger=Mock()) diff --git a/server/lib/python/cartodb_services/test/test_mapboxisoline.py b/server/lib/python/cartodb_services/test/test_mapboxisoline.py index 5d62170..0c97a33 100644 --- a/server/lib/python/cartodb_services/test/test_mapboxisoline.py +++ b/server/lib/python/cartodb_services/test/test_mapboxisoline.py @@ -7,15 +7,15 @@ from cartodb_services.mapbox.routing import MapboxRouting from cartodb_services.tools import Coordinate from cartodb_services.tools.coordinates import (validate_coordinates, marshall_coordinates) +import credentials -VALID_TOKEN = 'pk.eyJ1IjoiYWNhcmxvbiIsImEiOiJjamJuZjQ1Zjc0Ymt4Mnh0YmFrMmhtYnY4In0.gt9cw0VeKc3rM2mV5pcEmg' VALID_ORIGIN = Coordinate(-73.989, 40.733) class MapboxIsolinesTestCase(unittest.TestCase): def setUp(self): - matrix_client = MapboxMatrixClient(token=VALID_TOKEN, logger=Mock()) + matrix_client = MapboxMatrixClient(token=credentials.api_key(), logger=Mock()) self.mapbox_isolines = MapboxIsolines(matrix_client, logger=Mock()) def test_calculate_isochrone(self): diff --git a/server/lib/python/cartodb_services/test/test_mapboxmatrix.py b/server/lib/python/cartodb_services/test/test_mapboxmatrix.py index 4df64fa..5bb5b4c 100644 --- a/server/lib/python/cartodb_services/test/test_mapboxmatrix.py +++ b/server/lib/python/cartodb_services/test/test_mapboxmatrix.py @@ -4,8 +4,8 @@ from cartodb_services.mapbox import MapboxMatrixClient from cartodb_services.mapbox.matrix_client import DEFAULT_PROFILE from cartodb_services.tools.exceptions import ServiceException from cartodb_services.tools import Coordinate +import credentials -VALID_TOKEN = 'pk.eyJ1IjoiYWNhcmxvbiIsImEiOiJjamJuZjQ1Zjc0Ymt4Mnh0YmFrMmhtYnY4In0.gt9cw0VeKc3rM2mV5pcEmg' INVALID_TOKEN = 'invalid_token' VALID_ORIGIN = Coordinate(-73.989, 40.733) VALID_TARGET = Coordinate(-74, 40.733) @@ -22,7 +22,7 @@ INVALID_PROFILE = 'invalid_profile' class MapboxMatrixTestCase(unittest.TestCase): def setUp(self): - self.matrix_client = MapboxMatrixClient(token=VALID_TOKEN, + self.matrix_client = MapboxMatrixClient(token=credentials.api_key(), logger=Mock()) def test_invalid_profile(self): diff --git a/server/lib/python/cartodb_services/test/test_mapboxrouting.py b/server/lib/python/cartodb_services/test/test_mapboxrouting.py index 4b88fa6..6fcbb49 100644 --- a/server/lib/python/cartodb_services/test/test_mapboxrouting.py +++ b/server/lib/python/cartodb_services/test/test_mapboxrouting.py @@ -4,8 +4,8 @@ from cartodb_services.mapbox import MapboxRouting from cartodb_services.mapbox.routing import DEFAULT_PROFILE from cartodb_services.tools.exceptions import ServiceException from cartodb_services.tools import Coordinate +import credentials -VALID_TOKEN = 'pk.eyJ1IjoiYWNhcmxvbiIsImEiOiJjamJuZjQ1Zjc0Ymt4Mnh0YmFrMmhtYnY4In0.gt9cw0VeKc3rM2mV5pcEmg' INVALID_TOKEN = 'invalid_token' VALID_WAYPOINTS = [Coordinate(-73.989, 40.733), Coordinate(-74, 40.733)] NUM_WAYPOINTS_MAX = 25 @@ -31,7 +31,7 @@ WELL_KNOWN_LENGTH = 1317.9 class MapboxRoutingTestCase(unittest.TestCase): def setUp(self): - self.routing = MapboxRouting(token=VALID_TOKEN, logger=Mock()) + self.routing = MapboxRouting(token=credentials.api_key(), logger=Mock()) def test_invalid_profile(self): with self.assertRaises(ValueError): From 029541f298c9410011623d31dbcec2672b21c271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Ignacio=20S=C3=A1nchez=20Lara?= Date: Tue, 13 Feb 2018 16:16:13 +0100 Subject: [PATCH 02/10] api_key -> mapbox_api_key rename refactor --- server/lib/python/cartodb_services/test/credentials.py | 2 +- server/lib/python/cartodb_services/test/test_mapboxgeocoder.py | 2 +- server/lib/python/cartodb_services/test/test_mapboxisoline.py | 2 +- server/lib/python/cartodb_services/test/test_mapboxmatrix.py | 2 +- server/lib/python/cartodb_services/test/test_mapboxrouting.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/server/lib/python/cartodb_services/test/credentials.py b/server/lib/python/cartodb_services/test/credentials.py index 1818f84..5f10182 100644 --- a/server/lib/python/cartodb_services/test/credentials.py +++ b/server/lib/python/cartodb_services/test/credentials.py @@ -1,6 +1,6 @@ import os -def api_key(): +def mapbox_api_key(): """Returns Mapbox API key. Requires setting MAPBOX_API_KEY environment variable.""" return os.environ['MAPBOX_API_KEY'] diff --git a/server/lib/python/cartodb_services/test/test_mapboxgeocoder.py b/server/lib/python/cartodb_services/test/test_mapboxgeocoder.py index 286bcaa..84b5213 100644 --- a/server/lib/python/cartodb_services/test/test_mapboxgeocoder.py +++ b/server/lib/python/cartodb_services/test/test_mapboxgeocoder.py @@ -12,7 +12,7 @@ WELL_KNOWN_LATITUDE = 41.668654 class MapboxGeocoderTestCase(unittest.TestCase): def setUp(self): - self.geocoder = MapboxGeocoder(token=credentials.api_key(), logger=Mock()) + self.geocoder = MapboxGeocoder(token=credentials.mapbox_api_key(), logger=Mock()) def test_invalid_token(self): invalid_geocoder = MapboxGeocoder(token=INVALID_TOKEN, logger=Mock()) diff --git a/server/lib/python/cartodb_services/test/test_mapboxisoline.py b/server/lib/python/cartodb_services/test/test_mapboxisoline.py index 0c97a33..be44b3d 100644 --- a/server/lib/python/cartodb_services/test/test_mapboxisoline.py +++ b/server/lib/python/cartodb_services/test/test_mapboxisoline.py @@ -15,7 +15,7 @@ VALID_ORIGIN = Coordinate(-73.989, 40.733) class MapboxIsolinesTestCase(unittest.TestCase): def setUp(self): - matrix_client = MapboxMatrixClient(token=credentials.api_key(), logger=Mock()) + matrix_client = MapboxMatrixClient(token=credentials.mapbox_api_key(), logger=Mock()) self.mapbox_isolines = MapboxIsolines(matrix_client, logger=Mock()) def test_calculate_isochrone(self): diff --git a/server/lib/python/cartodb_services/test/test_mapboxmatrix.py b/server/lib/python/cartodb_services/test/test_mapboxmatrix.py index 5bb5b4c..90cc3f2 100644 --- a/server/lib/python/cartodb_services/test/test_mapboxmatrix.py +++ b/server/lib/python/cartodb_services/test/test_mapboxmatrix.py @@ -22,7 +22,7 @@ INVALID_PROFILE = 'invalid_profile' class MapboxMatrixTestCase(unittest.TestCase): def setUp(self): - self.matrix_client = MapboxMatrixClient(token=credentials.api_key(), + self.matrix_client = MapboxMatrixClient(token=credentials.mapbox_api_key(), logger=Mock()) def test_invalid_profile(self): diff --git a/server/lib/python/cartodb_services/test/test_mapboxrouting.py b/server/lib/python/cartodb_services/test/test_mapboxrouting.py index 6fcbb49..8936bd8 100644 --- a/server/lib/python/cartodb_services/test/test_mapboxrouting.py +++ b/server/lib/python/cartodb_services/test/test_mapboxrouting.py @@ -31,7 +31,7 @@ WELL_KNOWN_LENGTH = 1317.9 class MapboxRoutingTestCase(unittest.TestCase): def setUp(self): - self.routing = MapboxRouting(token=credentials.api_key(), logger=Mock()) + self.routing = MapboxRouting(token=credentials.mapbox_api_key(), logger=Mock()) def test_invalid_profile(self): with self.assertRaises(ValueError): From 1fdb4d3b3a5fe506c1c698bb37f0f8ac1ab917f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Ignacio=20S=C3=A1nchez=20Lara?= Date: Tue, 13 Feb 2018 18:23:36 +0100 Subject: [PATCH 03/10] Pythonic refactor, importing single method --- .../lib/python/cartodb_services/test/test_mapboxgeocoder.py | 4 ++-- server/lib/python/cartodb_services/test/test_mapboxisoline.py | 4 ++-- server/lib/python/cartodb_services/test/test_mapboxmatrix.py | 4 ++-- server/lib/python/cartodb_services/test/test_mapboxrouting.py | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/server/lib/python/cartodb_services/test/test_mapboxgeocoder.py b/server/lib/python/cartodb_services/test/test_mapboxgeocoder.py index 84b5213..f895be1 100644 --- a/server/lib/python/cartodb_services/test/test_mapboxgeocoder.py +++ b/server/lib/python/cartodb_services/test/test_mapboxgeocoder.py @@ -2,7 +2,7 @@ import unittest from mock import Mock from cartodb_services.mapbox import MapboxGeocoder from cartodb_services.tools.exceptions import ServiceException -import credentials +from credentials import mapbox_api_key INVALID_TOKEN = 'invalid_token' VALID_ADDRESS = 'Calle Siempreviva 3, Valladolid' @@ -12,7 +12,7 @@ WELL_KNOWN_LATITUDE = 41.668654 class MapboxGeocoderTestCase(unittest.TestCase): def setUp(self): - self.geocoder = MapboxGeocoder(token=credentials.mapbox_api_key(), logger=Mock()) + self.geocoder = MapboxGeocoder(token=mapbox_api_key(), logger=Mock()) def test_invalid_token(self): invalid_geocoder = MapboxGeocoder(token=INVALID_TOKEN, logger=Mock()) diff --git a/server/lib/python/cartodb_services/test/test_mapboxisoline.py b/server/lib/python/cartodb_services/test/test_mapboxisoline.py index be44b3d..ce80d0e 100644 --- a/server/lib/python/cartodb_services/test/test_mapboxisoline.py +++ b/server/lib/python/cartodb_services/test/test_mapboxisoline.py @@ -7,7 +7,7 @@ from cartodb_services.mapbox.routing import MapboxRouting from cartodb_services.tools import Coordinate from cartodb_services.tools.coordinates import (validate_coordinates, marshall_coordinates) -import credentials +from credentials import mapbox_api_key VALID_ORIGIN = Coordinate(-73.989, 40.733) @@ -15,7 +15,7 @@ VALID_ORIGIN = Coordinate(-73.989, 40.733) class MapboxIsolinesTestCase(unittest.TestCase): def setUp(self): - matrix_client = MapboxMatrixClient(token=credentials.mapbox_api_key(), logger=Mock()) + matrix_client = MapboxMatrixClient(token=mapbox_api_key(), logger=Mock()) self.mapbox_isolines = MapboxIsolines(matrix_client, logger=Mock()) def test_calculate_isochrone(self): diff --git a/server/lib/python/cartodb_services/test/test_mapboxmatrix.py b/server/lib/python/cartodb_services/test/test_mapboxmatrix.py index 90cc3f2..579810a 100644 --- a/server/lib/python/cartodb_services/test/test_mapboxmatrix.py +++ b/server/lib/python/cartodb_services/test/test_mapboxmatrix.py @@ -4,7 +4,7 @@ from cartodb_services.mapbox import MapboxMatrixClient from cartodb_services.mapbox.matrix_client import DEFAULT_PROFILE from cartodb_services.tools.exceptions import ServiceException from cartodb_services.tools import Coordinate -import credentials +from credentials import mapbox_api_key INVALID_TOKEN = 'invalid_token' VALID_ORIGIN = Coordinate(-73.989, 40.733) @@ -22,7 +22,7 @@ INVALID_PROFILE = 'invalid_profile' class MapboxMatrixTestCase(unittest.TestCase): def setUp(self): - self.matrix_client = MapboxMatrixClient(token=credentials.mapbox_api_key(), + self.matrix_client = MapboxMatrixClient(token=mapbox_api_key(), logger=Mock()) def test_invalid_profile(self): diff --git a/server/lib/python/cartodb_services/test/test_mapboxrouting.py b/server/lib/python/cartodb_services/test/test_mapboxrouting.py index 8936bd8..2871ab8 100644 --- a/server/lib/python/cartodb_services/test/test_mapboxrouting.py +++ b/server/lib/python/cartodb_services/test/test_mapboxrouting.py @@ -4,7 +4,7 @@ from cartodb_services.mapbox import MapboxRouting from cartodb_services.mapbox.routing import DEFAULT_PROFILE from cartodb_services.tools.exceptions import ServiceException from cartodb_services.tools import Coordinate -import credentials +from credentials import mapbox_api_key INVALID_TOKEN = 'invalid_token' VALID_WAYPOINTS = [Coordinate(-73.989, 40.733), Coordinate(-74, 40.733)] @@ -31,7 +31,7 @@ WELL_KNOWN_LENGTH = 1317.9 class MapboxRoutingTestCase(unittest.TestCase): def setUp(self): - self.routing = MapboxRouting(token=credentials.mapbox_api_key(), logger=Mock()) + self.routing = MapboxRouting(token=mapbox_api_key(), logger=Mock()) def test_invalid_profile(self): with self.assertRaises(ValueError): From c14fb057d3040a2ea8f2172ff3c9bdbdcba8ad33 Mon Sep 17 00:00:00 2001 From: Mario de Frutos Date: Wed, 14 Feb 2018 11:03:51 +0100 Subject: [PATCH 04/10] Update README.md --- server/lib/python/cartodb_services/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/lib/python/cartodb_services/README.md b/server/lib/python/cartodb_services/README.md index 5cac032..5b52f3d 100644 --- a/server/lib/python/cartodb_services/README.md +++ b/server/lib/python/cartodb_services/README.md @@ -24,7 +24,7 @@ NOTE: a system installation is required at present because the library is meant ## Running the unit tests -Just run `nosetests test/` +Just run `MAPBOX_API_KEY=xxx nosetests test/` ```shell $ nosetests test/ ...................................................................................................... From 03e1d1ca613b590494602a19bed606c4bf2f2b7c Mon Sep 17 00:00:00 2001 From: Mario de Frutos Date: Wed, 21 Feb 2018 19:13:59 +0100 Subject: [PATCH 05/10] Change default provider to mapbox instead of mapzen --- .../cartodb_services/cartodb_services/metrics/config.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/lib/python/cartodb_services/cartodb_services/metrics/config.py b/server/lib/python/cartodb_services/cartodb_services/metrics/config.py index aab4dd5..f068ab2 100644 --- a/server/lib/python/cartodb_services/cartodb_services/metrics/config.py +++ b/server/lib/python/cartodb_services/cartodb_services/metrics/config.py @@ -136,7 +136,7 @@ class RoutingConfig(ServiceConfig): ROUTING_PROVIDER_KEY = 'routing_provider' MAPZEN_PROVIDER = 'mapzen' MAPBOX_PROVIDER = 'mapbox' - DEFAULT_PROVIDER = MAPZEN_PROVIDER + DEFAULT_PROVIDER = MAPBOX_PROVIDER QUOTA_KEY = 'mapzen_routing_quota' SOFT_LIMIT_KEY = 'soft_mapzen_routing_limit' METRICS_LOG_KEY = 'routing_log_path' @@ -226,7 +226,7 @@ class IsolinesRoutingConfig(ServiceConfig): MAPZEN_PROVIDER = 'mapzen' MAPBOX_PROVIDER = 'mapbox' HEREMAPS_PROVIDER = 'heremaps' - DEFAULT_PROVIDER = MAPZEN_PROVIDER + DEFAULT_PROVIDER = MAPBOX_PROVIDER METRICS_LOG_KEY = 'isolines_log_path' def __init__(self, redis_connection, db_conn, username, orgname=None): @@ -391,7 +391,7 @@ class GeocoderConfig(ServiceConfig): USERNAME_KEY = 'username' ORGNAME_KEY = 'orgname' PERIOD_END_DATE = 'period_end_date' - DEFAULT_PROVIDER = MAPZEN_GEOCODER + DEFAULT_PROVIDER = MAPBOX_GEOCODER METRICS_LOG_KEY = 'geocoder_log_path' def __init__(self, redis_connection, db_conn, username, orgname=None, forced_provider=None): From 39dabffb8529993d1d6b13164a57a77463bdbab6 Mon Sep 17 00:00:00 2001 From: Mario de Frutos Date: Wed, 21 Feb 2018 19:14:29 +0100 Subject: [PATCH 06/10] Now is not mandatory to have mapzen configuration becuase its deprecated as provider --- .../python/cartodb_services/cartodb_services/metrics/config.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/lib/python/cartodb_services/cartodb_services/metrics/config.py b/server/lib/python/cartodb_services/cartodb_services/metrics/config.py index f068ab2..82fff8d 100644 --- a/server/lib/python/cartodb_services/cartodb_services/metrics/config.py +++ b/server/lib/python/cartodb_services/cartodb_services/metrics/config.py @@ -589,8 +589,9 @@ class ServicesDBConfig: def _get_mapzen_config(self): mapzen_conf_json = self._get_conf('mapzen_conf') + # We dont use mapzen anymore so we don't need to check for its configuration if not mapzen_conf_json: - raise ConfigException('Mapzen configuration missing') + return else: mapzen_conf = json.loads(mapzen_conf_json) self._mapzen_matrix_api_key = mapzen_conf['matrix']['api_key'] From e3f23adfdd38cadd7e926d02966c47d5c311c957 Mon Sep 17 00:00:00 2001 From: Mario de Frutos Date: Wed, 21 Feb 2018 19:14:47 +0100 Subject: [PATCH 07/10] Bump to version 0.17.0 --- server/lib/python/cartodb_services/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/lib/python/cartodb_services/setup.py b/server/lib/python/cartodb_services/setup.py index 901ee87..a87deb4 100644 --- a/server/lib/python/cartodb_services/setup.py +++ b/server/lib/python/cartodb_services/setup.py @@ -10,7 +10,7 @@ from setuptools import setup, find_packages setup( name='cartodb_services', - version='0.16.7', + version='0.17.0', description='CartoDB Services API Python Library', From 199788748b8713d97c13507e3b038cd8468aaf9e Mon Sep 17 00:00:00 2001 From: Mario de Frutos Date: Wed, 21 Feb 2018 19:14:56 +0100 Subject: [PATCH 08/10] Updated NEWS.md --- NEWS.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NEWS.md b/NEWS.md index 250eaeb..9fff051 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,8 @@ +February 22th, 2018 +================== +* Version `0.17.0` of the python library + * Change default provider to Mapbox + * Remove the obligatory nature of the Mapzen configuration due to its deprecation as provider February 13th, 2018 ================== From cbc19b869c8c13c93210a7ec7642c8e41423e1c3 Mon Sep 17 00:00:00 2001 From: Mario de Frutos Date: Thu, 22 Feb 2018 11:14:33 +0100 Subject: [PATCH 09/10] Fix CR suggestions --- .../cartodb_services/metrics/config.py | 68 +++++++++---------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/server/lib/python/cartodb_services/cartodb_services/metrics/config.py b/server/lib/python/cartodb_services/cartodb_services/metrics/config.py index 82fff8d..16e076d 100644 --- a/server/lib/python/cartodb_services/cartodb_services/metrics/config.py +++ b/server/lib/python/cartodb_services/cartodb_services/metrics/config.py @@ -576,51 +576,51 @@ class ServicesDBConfig: heremaps_conf_json = self._get_conf('heremaps_conf') if not heremaps_conf_json: raise ConfigException('Here maps configuration missing') - else: - heremaps_conf = json.loads(heremaps_conf_json) - self._heremaps_geocoder_app_id = heremaps_conf['geocoder']['app_id'] - self._heremaps_geocoder_app_code = heremaps_conf['geocoder']['app_code'] - self._heremaps_geocoder_cost_per_hit = heremaps_conf['geocoder'][ - 'geocoder_cost_per_hit'] - self._heremaps_geocoder_service_params = heremaps_conf['geocoder'].get('service', {}) - self._heremaps_isolines_app_id = heremaps_conf['isolines']['app_id'] - self._heremaps_isolines_app_code = heremaps_conf['isolines']['app_code'] - self._heremaps_isolines_service_params = heremaps_conf['isolines'].get('service', {}) + + heremaps_conf = json.loads(heremaps_conf_json) + self._heremaps_geocoder_app_id = heremaps_conf['geocoder']['app_id'] + self._heremaps_geocoder_app_code = heremaps_conf['geocoder']['app_code'] + self._heremaps_geocoder_cost_per_hit = heremaps_conf['geocoder'][ + 'geocoder_cost_per_hit'] + self._heremaps_geocoder_service_params = heremaps_conf['geocoder'].get('service', {}) + self._heremaps_isolines_app_id = heremaps_conf['isolines']['app_id'] + self._heremaps_isolines_app_code = heremaps_conf['isolines']['app_code'] + self._heremaps_isolines_service_params = heremaps_conf['isolines'].get('service', {}) def _get_mapzen_config(self): mapzen_conf_json = self._get_conf('mapzen_conf') # We dont use mapzen anymore so we don't need to check for its configuration if not mapzen_conf_json: return - else: - mapzen_conf = json.loads(mapzen_conf_json) - self._mapzen_matrix_api_key = mapzen_conf['matrix']['api_key'] - self._mapzen_matrix_quota = mapzen_conf['matrix']['monthly_quota'] - self._mapzen_matrix_service_params = mapzen_conf['matrix'].get('service', {}) - self._mapzen_isochrones_service_params = mapzen_conf.get('isochrones', {}).get('service', {}) - self._mapzen_routing_api_key = mapzen_conf['routing']['api_key'] - self._mapzen_routing_quota = mapzen_conf['routing']['monthly_quota'] - self._mapzen_routing_service_params = mapzen_conf['routing'].get('service', {}) - self._mapzen_geocoder_api_key = mapzen_conf['geocoder']['api_key'] - self._mapzen_geocoder_quota = mapzen_conf['geocoder']['monthly_quota'] - self._mapzen_geocoder_service_params = mapzen_conf['geocoder'].get('service', {}) + + mapzen_conf = json.loads(mapzen_conf_json) + self._mapzen_matrix_api_key = mapzen_conf['matrix']['api_key'] + self._mapzen_matrix_quota = mapzen_conf['matrix']['monthly_quota'] + self._mapzen_matrix_service_params = mapzen_conf['matrix'].get('service', {}) + self._mapzen_isochrones_service_params = mapzen_conf.get('isochrones', {}).get('service', {}) + self._mapzen_routing_api_key = mapzen_conf['routing']['api_key'] + self._mapzen_routing_quota = mapzen_conf['routing']['monthly_quota'] + self._mapzen_routing_service_params = mapzen_conf['routing'].get('service', {}) + self._mapzen_geocoder_api_key = mapzen_conf['geocoder']['api_key'] + self._mapzen_geocoder_quota = mapzen_conf['geocoder']['monthly_quota'] + self._mapzen_geocoder_service_params = mapzen_conf['geocoder'].get('service', {}) def _get_mapbox_config(self): mapbox_conf_json = self._get_conf('mapbox_conf') if not mapbox_conf_json: raise ConfigException('Mapbox configuration missing') - else: - mapbox_conf = json.loads(mapbox_conf_json) - self._mapbox_matrix_api_keys = mapbox_conf['matrix']['api_keys'] - self._mapbox_matrix_quota = mapbox_conf['matrix']['monthly_quota'] - self._mapbox_matrix_service_params = mapbox_conf['matrix'].get('service', {}) - self._mapbox_isochrones_service_params = mapbox_conf.get('isochrones', {}).get('service', {}) - self._mapbox_routing_api_keys = mapbox_conf['routing']['api_keys'] - self._mapbox_routing_quota = mapbox_conf['routing']['monthly_quota'] - self._mapbox_routing_service_params = mapbox_conf['routing'].get('service', {}) - self._mapbox_geocoder_api_keys = mapbox_conf['geocoder']['api_keys'] - self._mapbox_geocoder_quota = mapbox_conf['geocoder']['monthly_quota'] - self._mapbox_geocoder_service_params = mapbox_conf['geocoder'].get('service', {}) + + mapbox_conf = json.loads(mapbox_conf_json) + self._mapbox_matrix_api_keys = mapbox_conf['matrix']['api_keys'] + self._mapbox_matrix_quota = mapbox_conf['matrix']['monthly_quota'] + self._mapbox_matrix_service_params = mapbox_conf['matrix'].get('service', {}) + self._mapbox_isochrones_service_params = mapbox_conf.get('isochrones', {}).get('service', {}) + self._mapbox_routing_api_keys = mapbox_conf['routing']['api_keys'] + self._mapbox_routing_quota = mapbox_conf['routing']['monthly_quota'] + self._mapbox_routing_service_params = mapbox_conf['routing'].get('service', {}) + self._mapbox_geocoder_api_keys = mapbox_conf['geocoder']['api_keys'] + self._mapbox_geocoder_quota = mapbox_conf['geocoder']['monthly_quota'] + self._mapbox_geocoder_service_params = mapbox_conf['geocoder'].get('service', {}) def _get_data_observatory_config(self): do_conf_json = self._get_conf('data_observatory_conf') From 05e2cc981e243d556eb78f97abdf9ffda072b48d Mon Sep 17 00:00:00 2001 From: Mario de Frutos Date: Thu, 22 Feb 2018 11:20:16 +0100 Subject: [PATCH 10/10] Change min log level for tests to WARNING --- client/test/expected/00_installation_test.out | 2 ++ client/test/sql/00_installation_test.sql | 2 ++ server/extension/test/expected/00_install_test.out | 2 ++ server/extension/test/sql/00_install_test.sql | 2 ++ 4 files changed, 8 insertions(+) diff --git a/client/test/expected/00_installation_test.out b/client/test/expected/00_installation_test.out index fe179b7..650b141 100644 --- a/client/test/expected/00_installation_test.out +++ b/client/test/expected/00_installation_test.out @@ -1,3 +1,5 @@ +-- Only show warning or error messages in the tests output +SET client_min_messages TO WARNING; -- Install dependencies CREATE EXTENSION postgis; CREATE EXTENSION plpythonu; diff --git a/client/test/sql/00_installation_test.sql b/client/test/sql/00_installation_test.sql index f091cd4..49eab80 100644 --- a/client/test/sql/00_installation_test.sql +++ b/client/test/sql/00_installation_test.sql @@ -1,3 +1,5 @@ +-- Only show warning or error messages in the tests output +SET client_min_messages TO WARNING; -- Install dependencies CREATE EXTENSION postgis; CREATE EXTENSION plpythonu; diff --git a/server/extension/test/expected/00_install_test.out b/server/extension/test/expected/00_install_test.out index f87ca05..cfb9ee7 100644 --- a/server/extension/test/expected/00_install_test.out +++ b/server/extension/test/expected/00_install_test.out @@ -1,3 +1,5 @@ +-- Only show warning or error messages in the tests output +SET client_min_messages TO WARNING; -- Install dependencies CREATE EXTENSION postgis; CREATE EXTENSION plpythonu; diff --git a/server/extension/test/sql/00_install_test.sql b/server/extension/test/sql/00_install_test.sql index 9ffe2e1..2d7d41a 100644 --- a/server/extension/test/sql/00_install_test.sql +++ b/server/extension/test/sql/00_install_test.sql @@ -1,3 +1,5 @@ +-- Only show warning or error messages in the tests output +SET client_min_messages TO WARNING; -- Install dependencies CREATE EXTENSION postgis; CREATE EXTENSION plpythonu;