-# SPDX-License-Identifier: GPL-2.0-only
+# SPDX-License-Identifier: GPL-3.0-or-later
#
# This file is part of Nominatim. (https://nominatim.org)
#
-# Copyright (C) 2023 by the Nominatim developer community.
+# Copyright (C) 2024 by the Nominatim developer community.
# For a full list of authors see the git log.
"""
Tests for formatting reverse results for the V1 API.
import pytest
-import nominatim.api.v1 as api_impl
-import nominatim.api as napi
+from nominatim_api.v1.format import dispatch as v1_format
+import nominatim_api as napi
FORMATS = ['json', 'jsonv2', 'geojson', 'geocodejson', 'xml']
('amenity', 'post_box'),
napi.Point(0.3, -8.9))
- raw = api_impl.format_result(napi.ReverseResults([reverse]), fmt, {})
+ raw = v1_format.format_result(napi.ReverseResults([reverse]), fmt, {})
if fmt == 'xml':
root = ET.fromstring(raw)
@pytest.mark.parametrize('fmt', FORMATS)
def test_format_reverse_no_result(fmt):
- raw = api_impl.format_result(napi.ReverseResults(), fmt, {})
+ raw = v1_format.format_result(napi.ReverseResults(), fmt, {})
if fmt == 'xml':
root = ET.fromstring(raw)
place_id=5564,
osm_object=('N', 23))
- raw = api_impl.format_result(napi.ReverseResults([reverse]), fmt, {})
+ raw = v1_format.format_result(napi.ReverseResults([reverse]), fmt, {})
if fmt == 'xml':
root = ET.fromstring(raw).find('result')
]))
reverse.localize(napi.Locales())
- raw = api_impl.format_result(napi.ReverseResults([reverse]), fmt,
+ raw = v1_format.format_result(napi.ReverseResults([reverse]), fmt,
{'addressdetails': True})
reverse.localize(napi.Locales())
- raw = api_impl.format_result(napi.ReverseResults([reverse]), 'geocodejson',
+ raw = v1_format.format_result(napi.ReverseResults([reverse]), 'geocodejson',
{'addressdetails': True})
props = json.loads(raw)['features'][0]['properties']['geocoding']
napi.Point(1.0, 2.0),
address_rows=napi.AddressLines())
- raw = api_impl.format_result(napi.ReverseResults([reverse]), fmt,
+ raw = v1_format.format_result(napi.ReverseResults([reverse]), fmt,
{'addressdetails': True})
napi.Point(1.0, 2.0),
extratags={'one': 'A', 'two':'B'})
- raw = api_impl.format_result(napi.ReverseResults([reverse]), fmt,
+ raw = v1_format.format_result(napi.ReverseResults([reverse]), fmt,
{'extratags': True})
if fmt == 'xml':
('place', 'thing'),
napi.Point(1.0, 2.0))
- raw = api_impl.format_result(napi.ReverseResults([reverse]), fmt,
+ raw = v1_format.format_result(napi.ReverseResults([reverse]), fmt,
{'extratags': True})
if fmt == 'xml':
napi.Point(1.0, 2.0),
names={'name': 'A', 'ref':'1'})
- raw = api_impl.format_result(napi.ReverseResults([reverse]), fmt,
+ raw = v1_format.format_result(napi.ReverseResults([reverse]), fmt,
{'namedetails': True})
if fmt == 'xml':
('place', 'thing'),
napi.Point(1.0, 2.0))
- raw = api_impl.format_result(napi.ReverseResults([reverse]), fmt,
+ raw = v1_format.format_result(napi.ReverseResults([reverse]), fmt,
{'namedetails': True})
if fmt == 'xml':
('amenity', 'restaurant'),
napi.Point(1.0, 2.0))
- result = api_impl.format_result(napi.ReverseResults([reverse]), fmt,
+ result = v1_format.format_result(napi.ReverseResults([reverse]), fmt,
{'icon_base_url': 'foo'})
js = json.loads(result)
('amenity', 'tree'),
napi.Point(1.0, 2.0))
- result = api_impl.format_result(napi.ReverseResults([reverse]), fmt,
+ result = v1_format.format_result(napi.ReverseResults([reverse]), fmt,
{'icon_base_url': 'foo'})
assert 'icon' not in json.loads(result)