Code Duplication    Length = 12-13 lines in 2 locations

elodie/tests/geolocation_test.py 2 locations

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