From ffdb6524dae08d4aa2f3a0d5ee01303ebf3bc4d3 Mon Sep 17 00:00:00 2001 From: Rafa de la Torre Date: Wed, 8 Mar 2017 10:19:29 +0100 Subject: [PATCH] Fix bug: search_type can be None Found via unit test: ```sh $ nosetests -x test/ ....................................................................................E ====================================================================== ERROR: test_geocode_address_with_valid_params (test.test_mapzengeocoder.MapzenGeocoderTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/requests_mock/mocker.py", line 177, in inner return func(*args, **kwargs) File "/home/ubuntu/src/dataservices-api/server/lib/python/cartodb_services/test/test_mapzengeocoder.py", line 100, in test_geocode_address_with_valid_params country='ESP') File "/home/ubuntu/src/dataservices-api/server/lib/python/cartodb_services/cartodb_services/mapzen/qps.py", line 28, in wrapped_function return QPSService(retry_timeout=timeout, queries_per_second=qps).call(original_function, *args, **kwargs) File "/home/ubuntu/src/dataservices-api/server/lib/python/cartodb_services/cartodb_services/mapzen/qps.py", line 53, in call raise e AttributeError: 'NoneType' object has no attribute 'lower' ---------------------------------------------------------------------- Ran 85 tests in 0.140s FAILED (errors=1) ``` --- .../python/cartodb_services/cartodb_services/mapzen/geocoder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/lib/python/cartodb_services/cartodb_services/mapzen/geocoder.py b/server/lib/python/cartodb_services/cartodb_services/mapzen/geocoder.py index 0d56b38..742acc0 100644 --- a/server/lib/python/cartodb_services/cartodb_services/mapzen/geocoder.py +++ b/server/lib/python/cartodb_services/cartodb_services/mapzen/geocoder.py @@ -27,7 +27,7 @@ class MapzenGeocoder(Traceable): country=None, search_type=None): # Remove the search_type if its address from the params sent to mapzen - if search_type.lower() == 'address': + if search_type and search_type.lower() == 'address': search_type = None request_params = self._build_requests_parameters(searchtext, city,