Skip to content

Commit

Permalink
Add debug log message for Mapquest URL (#448)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmathai authored Mar 11, 2023
1 parent 3e88440 commit 76ad823
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions elodie/geolocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ def lookup(**kwargs):
path,
urllib.parse.urlencode(params)
)
# log the MapQuest url gh-446
log.info('MapQuest url: %s' % (url))
r = requests.get(url, headers=headers)
return parse_result(r.json())
except requests.exceptions.RequestException as e:
Expand Down
13 changes: 13 additions & 0 deletions elodie/tests/geolocation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
from mock import patch
from tempfile import gettempdir

try:
from StringIO import StringIO
except ImportError:
from io import StringIO

sys.path.insert(0, os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))))

from . import helper
Expand Down Expand Up @@ -115,6 +120,14 @@ def test_lookup_with_prefer_english_names_false():
res = geolocation.lookup(lat=55.66333, lon=37.61583)
assert res['address']['city'] == u'\u041d\u0430\u0433\u043e\u0440\u043d\u044b\u0439 \u0440\u0430\u0439\u043e\u043d', res

@mock.patch('elodie.constants.debug', True)
def test_lookup_debug_mapquest_url():
out = StringIO()
sys.stdout = out
res = geolocation.lookup(location='Sunnyvale, CA')
output = out.getvalue()
assert 'MapQuest url:' in output, output

@mock.patch('elodie.constants.location_db', '%s/location.json-cached' % gettempdir())
def test_place_name_deprecated_string_cached():
# See gh-160 for backwards compatability needed when a string is stored instead of a dict
Expand Down

0 comments on commit 76ad823

Please sign in to comment.