0001-api-fix-content-type-of-reverse-geocoding-responses-.patch
tests/test_api.py | ||
---|---|---|
2041 | 2041 | |
2042 | 2042 |
def test_reverse_geocoding(pub): |
2043 | 2043 |
with mock.patch('qommon.misc.urlopen') as urlopen: |
2044 |
urlopen.side_effect = lambda *args: StringIO('xxx')
|
|
2044 |
urlopen.side_effect = lambda *args: StringIO(json.dumps({'address': 'xxx'}))
|
|
2045 | 2045 |
get_app(pub).get('/api/reverse-geocoding', status=400) |
2046 | 2046 |
resp = get_app(pub).get('/api/reverse-geocoding?lat=0&lon=0') |
2047 |
assert resp.body == 'xxx' |
|
2047 |
assert resp.content_type == 'application/json' |
|
2048 |
assert resp.body == json.dumps({'address': 'xxx'}) |
|
2048 | 2049 |
assert urlopen.call_args[0][0] == 'http://nominatim.openstreetmap.org/reverse?zoom=18&format=json&addressdetails=1&lat=0&lon=0&accept-language=en' |
2049 | 2050 | |
2050 | 2051 |
pub.site_options.add_section('options') |
wcs/api.py | ||
---|---|---|
679 | 679 |
code = ApiTrackingCodeDirectory() |
680 | 680 | |
681 | 681 |
def reverse_geocoding(self): |
682 |
get_response().set_content_type('application/json') |
|
682 | 683 |
try: |
683 | 684 |
lat = get_request().form['lat'] |
684 | 685 |
lon = get_request().form['lon'] |
685 |
- |