|
@@ 130-142 (lines=13) @@
|
| 127 |
|
res = geolocation.lookup(lat=55.6775055555556, lon=12.5686222222222) |
| 128 |
|
assert res['address']['city'] == 'K\u00f8benhavn', res |
| 129 |
|
|
| 130 |
|
@mock.patch('elodie.constants.location_db', '%s/location.json-cached' % gettempdir()) |
| 131 |
|
def test_place_name_deprecated_string_cached(): |
| 132 |
|
# See gh-160 for backwards compatability needed when a string is stored instead of a dict |
| 133 |
|
helper.reset_dbs() |
| 134 |
|
with open('%s/location.json-cached' % gettempdir(), 'w') as f: |
| 135 |
|
f.write(""" |
| 136 |
|
[{"lat": 37.3667027222222, "long": -122.033383611111, "name": "OLDVALUE"}] |
| 137 |
|
""" |
| 138 |
|
) |
| 139 |
|
place_name = geolocation.place_name(37.3667027222222, -122.033383611111) |
| 140 |
|
helper.restore_dbs() |
| 141 |
|
|
| 142 |
|
assert place_name['city'] == 'Sunnyvale', place_name |
| 143 |
|
|
| 144 |
|
@mock.patch('elodie.constants.location_db', '%s/location.json-cached' % gettempdir()) |
| 145 |
|
def test_place_name_cached(): |
|
@@ 144-155 (lines=12) @@
|
| 141 |
|
|
| 142 |
|
assert place_name['city'] == 'Sunnyvale', place_name |
| 143 |
|
|
| 144 |
|
@mock.patch('elodie.constants.location_db', '%s/location.json-cached' % gettempdir()) |
| 145 |
|
def test_place_name_cached(): |
| 146 |
|
helper.reset_dbs() |
| 147 |
|
with open('%s/location.json-cached' % gettempdir(), 'w') as f: |
| 148 |
|
f.write(""" |
| 149 |
|
[{"lat": 37.3667027222222, "long": -122.033383611111, "name": {"city": "UNITTEST"}}] |
| 150 |
|
""" |
| 151 |
|
) |
| 152 |
|
place_name = geolocation.place_name(37.3667027222222, -122.033383611111) |
| 153 |
|
helper.restore_dbs() |
| 154 |
|
|
| 155 |
|
assert place_name['city'] == 'UNITTEST', place_name |
| 156 |
|
|
| 157 |
|
def test_place_name_no_default(): |
| 158 |
|
# See gh-160 for backwards compatability needed when a string is stored instead of a dict |