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)
```
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user