api: fix content type of reverse geocoding responses (#22580)
This commit is contained in:
parent
c22b84459e
commit
c44b70c622
|
@ -2034,10 +2034,11 @@ def test_get_secret_and_orig(no_request_pub):
|
|||
|
||||
def test_reverse_geocoding(pub):
|
||||
with mock.patch('qommon.misc.urlopen') as urlopen:
|
||||
urlopen.side_effect = lambda *args: StringIO('xxx')
|
||||
urlopen.side_effect = lambda *args: StringIO(json.dumps({'address': 'xxx'}))
|
||||
get_app(pub).get('/api/reverse-geocoding', status=400)
|
||||
resp = get_app(pub).get('/api/reverse-geocoding?lat=0&lon=0')
|
||||
assert resp.body == 'xxx'
|
||||
assert resp.content_type == 'application/json'
|
||||
assert resp.body == json.dumps({'address': 'xxx'})
|
||||
assert urlopen.call_args[0][0] == 'http://nominatim.openstreetmap.org/reverse?zoom=18&format=json&addressdetails=1&lat=0&lon=0&accept-language=en'
|
||||
|
||||
pub.site_options.add_section('options')
|
||||
|
|
|
@ -678,6 +678,7 @@ class ApiDirectory(Directory):
|
|||
code = ApiTrackingCodeDirectory()
|
||||
|
||||
def reverse_geocoding(self):
|
||||
get_response().set_content_type('application/json')
|
||||
try:
|
||||
lat = get_request().form['lat']
|
||||
lon = get_request().form['lon']
|
||||
|
|
Loading…
Reference in New Issue