diff --git a/server/lib/python/cartodb_services/cartodb_services/tomtom/geocoder.py b/server/lib/python/cartodb_services/cartodb_services/tomtom/geocoder.py index 783be25..432dd31 100644 --- a/server/lib/python/cartodb_services/cartodb_services/tomtom/geocoder.py +++ b/server/lib/python/cartodb_services/cartodb_services/tomtom/geocoder.py @@ -1,3 +1,6 @@ +#!/usr/local/bin/python +# -*- coding: utf-8 -*- + import json import requests from uritemplate import URITemplate @@ -62,6 +65,15 @@ class TomTomGeocoder(Traceable): @qps_retry(qps=5) def geocode(self, searchtext, city=None, state_province=None, country=None): + if searchtext: + searchtext = searchtext.decode('utf-8') + if city: + city = city.decode('utf-8') + if state_province: + state_province = state_province.decode('utf-8') + if country: + country = country.decode('utf-8') + if not self._validate_input(searchtext, city, state_province, country): return [] diff --git a/server/lib/python/cartodb_services/test/test_tomtomgeocoder.py b/server/lib/python/cartodb_services/test/test_tomtomgeocoder.py index 7fcfcda..002847a 100644 --- a/server/lib/python/cartodb_services/test/test_tomtomgeocoder.py +++ b/server/lib/python/cartodb_services/test/test_tomtomgeocoder.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + import unittest from mock import Mock from cartodb_services.tomtom import TomTomGeocoder @@ -5,7 +7,7 @@ from cartodb_services.tools.exceptions import ServiceException from credentials import tomtom_api_key INVALID_APIKEY = 'invalid_apikey' -VALID_ADDRESS = 'Plaza Mayor 3, Valladolid' +VALID_ADDRESS = u'ManterĂ­a 3, Valladolid'.encode('utf-8') class TomTomGeocoderTestCase(unittest.TestCase):