Code Duplication    Length = 12-13 lines in 2 locations

elodie/tests/geolocation_test.py 2 locations

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