import pytest
-import nominatim_api.v1 as api_impl
+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)