Return dictionary with "Unknown Location" instead of string when location is not found #106 (#201)

This commit is contained in:
Jaisen Mathai 2017-03-15 22:43:21 -07:00 committed by GitHub
parent 56f0b1e170
commit 31db4e661a
2 changed files with 9 additions and 1 deletions

View File

@ -144,7 +144,7 @@ def place_name(lat, lon):
lookup_place_name['default'] = address[loc]
if('default' not in lookup_place_name):
lookup_place_name = 'Unknown Location'
lookup_place_name = {'default': 'Unknown Location'}
if(lookup_place_name is not {}):
db.add_location(lat, lon, lookup_place_name)

View File

@ -139,6 +139,14 @@ def test_place_name_cached():
assert place_name['city'] == 'UNITTEST', place_name
def test_place_name_no_default():
# See gh-160 for backwards compatability needed when a string is stored instead of a dict
helper.reset_dbs()
place_name = geolocation.place_name(123456.000, 123456.000)
helper.restore_dbs()
assert place_name['default'] == 'Unknown Location', place_name
@mock.patch('elodie.geolocation.__KEY__', 'invalid_key')
def test_lookup_with_invalid_key():
res = geolocation.lookup(location='Sunnyvale, CA')