diff --git a/tests/test_api.py b/tests/test_api.py index 9bee6eef0..beada9b75 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -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') diff --git a/wcs/api.py b/wcs/api.py index 825808399..08f50f7bc 100644 --- a/wcs/api.py +++ b/wcs/api.py @@ -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']