From 09e24e13d3c4a42d2fec81b197634b669457ea66 Mon Sep 17 00:00:00 2001 From: antoniocarlon Date: Wed, 18 Mar 2020 12:09:12 +0100 Subject: [PATCH 1/2] Fixing is_destination for HERE isolines --- .../cartodb_services/here/routing.py | 2 +- server/lib/python/cartodb_services/setup.py | 2 +- .../cartodb_services/test/test_heremapsrouting.py | 13 +++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/server/lib/python/cartodb_services/cartodb_services/here/routing.py b/server/lib/python/cartodb_services/cartodb_services/here/routing.py index ab36adf..fddc3d7 100644 --- a/server/lib/python/cartodb_services/cartodb_services/here/routing.py +++ b/server/lib/python/cartodb_services/cartodb_services/here/routing.py @@ -115,7 +115,7 @@ class HereMapsRoutingIsoline(Traceable): def __parse_source_param(self, source, options): key = 'start' - if 'is_destination' in options and options['is_destination']: + if 'is_destination' in options and options['is_destination'].lower() == 'true': key = 'destination' return {key: source} diff --git a/server/lib/python/cartodb_services/setup.py b/server/lib/python/cartodb_services/setup.py index 3c644e5..30e60e2 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.23.1', + version='0.23.2', description='CartoDB Services API Python Library', diff --git a/server/lib/python/cartodb_services/test/test_heremapsrouting.py b/server/lib/python/cartodb_services/test/test_heremapsrouting.py index 6226572..2aff5dc 100644 --- a/server/lib/python/cartodb_services/test/test_heremapsrouting.py +++ b/server/lib/python/cartodb_services/test/test_heremapsrouting.py @@ -133,6 +133,7 @@ class HereMapsRoutingIsolineTestCase(unittest.TestCase): self.isoline_url = "{0}{1}".format(HereMapsRoutingIsoline.PRODUCTION_ROUTING_BASE_URL, HereMapsRoutingIsoline.ISOLINE_PATH) + def test_calculate_isodistance_with_valid_params(self, req_mock): url = "{0}?start=geo%2133.0%2C1.0&mode=shortest%3Bcar".format(self.isoline_url) req_mock.register_uri('GET', url, text=self.GOOD_RESPONSE) @@ -204,6 +205,17 @@ class HereMapsRoutingIsolineTestCase(unittest.TestCase): 'fastest;car;traffic:false;motorway:-1') def test_source_parameters_works_properly(self, req_mock): + req_mock.register_uri('GET', requests_mock.ANY, + text=self.GOOD_RESPONSE) + response = self.routing.calculate_isochrone('geo!33.0,1.0', 'car', + ['1000', '2000'], + ['is_destination=false']) + parsed_url = urlparse(req_mock.request_history[0].url) + url_params = parse_qs(parsed_url.query) + + self.assertEqual(url_params['start'][0], 'geo!33.0,1.0') + + def test_destination_parameters_works_properly(self, req_mock): req_mock.register_uri('GET', requests_mock.ANY, text=self.GOOD_RESPONSE) response = self.routing.calculate_isochrone('geo!33.0,1.0', 'car', @@ -211,6 +223,7 @@ class HereMapsRoutingIsolineTestCase(unittest.TestCase): ['is_destination=true']) parsed_url = urlparse(req_mock.request_history[0].url) url_params = parse_qs(parsed_url.query) + self.assertEqual(url_params['destination'][0], 'geo!33.0,1.0') def test_isodistance_with_nonstandard_url(self, req_mock): From a1fdaacb4c05e62ab7a96050e2e070c6f83ed385 Mon Sep 17 00:00:00 2001 From: antoniocarlon Date: Wed, 18 Mar 2020 12:14:16 +0100 Subject: [PATCH 2/2] Fixed spacing --- .../lib/python/cartodb_services/test/test_heremapsrouting.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/server/lib/python/cartodb_services/test/test_heremapsrouting.py b/server/lib/python/cartodb_services/test/test_heremapsrouting.py index 2aff5dc..96c114c 100644 --- a/server/lib/python/cartodb_services/test/test_heremapsrouting.py +++ b/server/lib/python/cartodb_services/test/test_heremapsrouting.py @@ -133,7 +133,6 @@ class HereMapsRoutingIsolineTestCase(unittest.TestCase): self.isoline_url = "{0}{1}".format(HereMapsRoutingIsoline.PRODUCTION_ROUTING_BASE_URL, HereMapsRoutingIsoline.ISOLINE_PATH) - def test_calculate_isodistance_with_valid_params(self, req_mock): url = "{0}?start=geo%2133.0%2C1.0&mode=shortest%3Bcar".format(self.isoline_url) req_mock.register_uri('GET', url, text=self.GOOD_RESPONSE) @@ -212,7 +211,6 @@ class HereMapsRoutingIsolineTestCase(unittest.TestCase): ['is_destination=false']) parsed_url = urlparse(req_mock.request_history[0].url) url_params = parse_qs(parsed_url.query) - self.assertEqual(url_params['start'][0], 'geo!33.0,1.0') def test_destination_parameters_works_properly(self, req_mock): @@ -223,7 +221,6 @@ class HereMapsRoutingIsolineTestCase(unittest.TestCase): ['is_destination=true']) parsed_url = urlparse(req_mock.request_history[0].url) url_params = parse_qs(parsed_url.query) - self.assertEqual(url_params['destination'][0], 'geo!33.0,1.0') def test_isodistance_with_nonstandard_url(self, req_mock):