mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-15 19:07:58 +00:00
Locales and localization refactor with Locales as a localizer object.
Removed auto-localization from search/search_address APIs (now explicit), simplified AddressLines to subclass List[AddressLine], made display_name a computed property in Results instead of field and removed result-localization circular dependencies
This commit is contained in:
@@ -34,6 +34,7 @@ def test_lookup_in_placex(apiobj, frontend, idobj):
|
||||
|
||||
api = frontend(apiobj, options={'details'})
|
||||
result = api.details(idobj)
|
||||
napi.Locales().localize_results([result])
|
||||
|
||||
assert result is not None
|
||||
|
||||
@@ -83,6 +84,7 @@ def test_lookup_in_placex_minimal_info(apiobj, frontend):
|
||||
|
||||
api = frontend(apiobj, options={'details'})
|
||||
result = api.details(napi.PlaceID(332))
|
||||
napi.Locales().localize_results([result])
|
||||
|
||||
assert result is not None
|
||||
|
||||
@@ -149,6 +151,7 @@ def test_lookup_placex_with_address_details(apiobj, frontend):
|
||||
|
||||
api = frontend(apiobj, options={'details'})
|
||||
result = api.details(napi.PlaceID(332), address_details=True)
|
||||
napi.Locales().localize_results([result])
|
||||
|
||||
assert result.address_rows == [
|
||||
napi.AddressLine(place_id=332, osm_object=('W', 4),
|
||||
@@ -350,6 +353,7 @@ def test_lookup_osmline_with_address_details(apiobj, frontend):
|
||||
|
||||
api = frontend(apiobj, options={'details'})
|
||||
result = api.details(napi.PlaceID(9000), address_details=True)
|
||||
napi.Locales().localize_results([result])
|
||||
|
||||
assert result.address_rows == [
|
||||
napi.AddressLine(place_id=332, osm_object=('W', 4),
|
||||
@@ -450,6 +454,7 @@ def test_lookup_tiger_with_address_details(apiobj, frontend):
|
||||
|
||||
api = frontend(apiobj, options={'details'})
|
||||
result = api.details(napi.PlaceID(9000), address_details=True)
|
||||
napi.Locales().localize_results([result])
|
||||
|
||||
assert result.address_rows == [
|
||||
napi.AddressLine(place_id=332, osm_object=('W', 4),
|
||||
@@ -545,6 +550,7 @@ def test_lookup_postcode_with_address_details(apiobj, frontend):
|
||||
|
||||
api = frontend(apiobj, options={'details'})
|
||||
result = api.details(napi.PlaceID(9000), address_details=True)
|
||||
napi.Locales().localize_results([result])
|
||||
|
||||
assert result.address_rows == [
|
||||
napi.AddressLine(place_id=9000, osm_object=None,
|
||||
|
||||
@@ -119,7 +119,7 @@ def test_search_details_full():
|
||||
country_code='ll',
|
||||
indexed_date=import_date
|
||||
)
|
||||
search.localize(napi.Locales())
|
||||
napi.Locales().localize_results([search])
|
||||
|
||||
result = v1_format.format_result(search, 'json', {})
|
||||
|
||||
|
||||
@@ -102,11 +102,10 @@ def test_format_reverse_with_address(fmt):
|
||||
rank_address=10,
|
||||
distance=0.0)
|
||||
]))
|
||||
reverse.localize(napi.Locales())
|
||||
napi.Locales().localize_results([reverse])
|
||||
|
||||
raw = v1_format.format_result(napi.ReverseResults([reverse]), fmt,
|
||||
{'addressdetails': True})
|
||||
|
||||
if fmt == 'xml':
|
||||
root = ET.fromstring(raw)
|
||||
assert root.find('addressparts').find('county').text == 'Hello'
|
||||
@@ -165,7 +164,7 @@ def test_format_reverse_geocodejson_special_parts():
|
||||
distance=0.0)
|
||||
]))
|
||||
|
||||
reverse.localize(napi.Locales())
|
||||
napi.Locales().localize_results([reverse])
|
||||
|
||||
raw = v1_format.format_result(napi.ReverseResults([reverse]), 'geocodejson',
|
||||
{'addressdetails': True})
|
||||
|
||||
@@ -74,8 +74,7 @@ class TestCliReverseCall:
|
||||
napi.Point(1.0, -3.0),
|
||||
names={'name': 'Name', 'name:fr': 'Nom'},
|
||||
extratags={'extra': 'Extra'},
|
||||
locale_name='Name',
|
||||
display_name='Name')
|
||||
locale_name='Name')
|
||||
|
||||
monkeypatch.setattr(napi.NominatimAPI, 'reverse',
|
||||
lambda *args, **kwargs: result)
|
||||
@@ -122,8 +121,7 @@ class TestCliLookupCall:
|
||||
napi.Point(1.0, -3.0),
|
||||
names={'name': 'Name', 'name:fr': 'Nom'},
|
||||
extratags={'extra': 'Extra'},
|
||||
locale_name='Name',
|
||||
display_name='Name')
|
||||
locale_name='Name')
|
||||
|
||||
monkeypatch.setattr(napi.NominatimAPI, 'lookup',
|
||||
lambda *args, **kwargs: napi.SearchResults([result]))
|
||||
@@ -150,8 +148,7 @@ def test_search(cli_call, tmp_path, capsys, monkeypatch, endpoint, params):
|
||||
napi.Point(1.0, -3.0),
|
||||
names={'name': 'Name', 'name:fr': 'Nom'},
|
||||
extratags={'extra': 'Extra'},
|
||||
locale_name='Name',
|
||||
display_name='Name')
|
||||
locale_name='Name')
|
||||
|
||||
monkeypatch.setattr(napi.NominatimAPI, endpoint,
|
||||
lambda *args, **kwargs: napi.SearchResults([result]))
|
||||
|
||||
Reference in New Issue
Block a user