]> git.openstreetmap.org Git - nominatim.git/blobdiff - test/python/api/test_api_details.py
move localization into add_result_details
[nominatim.git] / test / python / api / test_api_details.py
index 625c4e7afdc131b6452551fbf30e05d5db9b3e1e..05a7aa7f29f030202523c7941fed66636e1ec1a3 100644 (file)
@@ -31,7 +31,7 @@ def test_lookup_in_placex(apiobj, idobj):
                      indexed_date=import_date,
                      geometry='LINESTRING(23 34, 23.1 34, 23.1 34.1, 23 34)')
 
                      indexed_date=import_date,
                      geometry='LINESTRING(23 34, 23.1 34, 23.1 34.1, 23 34)')
 
-    result = apiobj.api.details(idobj, napi.LookupDetails())
+    result = apiobj.api.details(idobj)
 
     assert result is not None
 
 
     assert result is not None
 
@@ -79,7 +79,7 @@ def test_lookup_in_placex_minimal_info(apiobj):
                      indexed_date=import_date,
                      geometry='LINESTRING(23 34, 23.1 34, 23.1 34.1, 23 34)')
 
                      indexed_date=import_date,
                      geometry='LINESTRING(23 34, 23.1 34, 23.1 34.1, 23 34)')
 
-    result = apiobj.api.details(napi.PlaceID(332), napi.LookupDetails())
+    result = apiobj.api.details(napi.PlaceID(332))
 
     assert result is not None
 
 
     assert result is not None
 
@@ -121,8 +121,7 @@ def test_lookup_in_placex_with_geometry(apiobj):
     apiobj.add_placex(place_id=332,
                       geometry='LINESTRING(23 34, 23.1 34)')
 
     apiobj.add_placex(place_id=332,
                       geometry='LINESTRING(23 34, 23.1 34)')
 
-    result = apiobj.api.details(napi.PlaceID(332),
-                               napi.LookupDetails(geometry_output=napi.GeometryFormat.GEOJSON))
+    result = apiobj.api.details(napi.PlaceID(332), geometry_output=napi.GeometryFormat.GEOJSON)
 
     assert result.geometry == {'geojson': '{"type":"LineString","coordinates":[[23,34],[23.1,34]]}'}
 
 
     assert result.geometry == {'geojson': '{"type":"LineString","coordinates":[[23,34],[23.1,34]]}'}
 
@@ -144,25 +143,27 @@ def test_lookup_placex_with_address_details(apiobj):
                               country_code='pl',
                               rank_search=17, rank_address=16)
 
                               country_code='pl',
                               rank_search=17, rank_address=16)
 
-    result = apiobj.api.details(napi.PlaceID(332),
-                               napi.LookupDetails(address_details=True))
+    result = apiobj.api.details(napi.PlaceID(332), address_details=True)
 
     assert result.address_rows == [
                napi.AddressLine(place_id=332, osm_object=('W', 4),
                                 category=('highway', 'residential'),
                                 names={'name': 'Street'}, extratags={},
                                 admin_level=15, fromarea=True, isaddress=True,
 
     assert result.address_rows == [
                napi.AddressLine(place_id=332, osm_object=('W', 4),
                                 category=('highway', 'residential'),
                                 names={'name': 'Street'}, extratags={},
                                 admin_level=15, fromarea=True, isaddress=True,
-                                rank_address=26, distance=0.0),
+                                rank_address=26, distance=0.0,
+                                local_name='Street'),
                napi.AddressLine(place_id=1000, osm_object=('N', 3333),
                                 category=('place', 'suburb'),
                                 names={'name': 'Smallplace'}, extratags={},
                                 admin_level=13, fromarea=False, isaddress=True,
                napi.AddressLine(place_id=1000, osm_object=('N', 3333),
                                 category=('place', 'suburb'),
                                 names={'name': 'Smallplace'}, extratags={},
                                 admin_level=13, fromarea=False, isaddress=True,
-                                rank_address=23, distance=0.0034),
+                                rank_address=23, distance=0.0034,
+                                local_name='Smallplace'),
                napi.AddressLine(place_id=1001, osm_object=('N', 3334),
                                 category=('place', 'city'),
                                 names={'name': 'Bigplace'}, extratags={},
                                 admin_level=15, fromarea=True, isaddress=True,
                napi.AddressLine(place_id=1001, osm_object=('N', 3334),
                                 category=('place', 'city'),
                                 names={'name': 'Bigplace'}, extratags={},
                                 admin_level=15, fromarea=True, isaddress=True,
-                                rank_address=16, distance=0.0),
+                                rank_address=16, distance=0.0,
+                                local_name='Bigplace'),
                napi.AddressLine(place_id=None, osm_object=None,
                                 category=('place', 'country_code'),
                                 names={'ref': 'pl'}, extratags={},
                napi.AddressLine(place_id=None, osm_object=None,
                                 category=('place', 'country_code'),
                                 names={'ref': 'pl'}, extratags={},
@@ -177,8 +178,7 @@ def test_lookup_place_with_linked_places_none_existing(apiobj):
                      country_code='pl', linked_place_id=45,
                      rank_search=27, rank_address=26)
 
                      country_code='pl', linked_place_id=45,
                      rank_search=27, rank_address=26)
 
-    result = apiobj.api.details(napi.PlaceID(332),
-                               napi.LookupDetails(linked_places=True))
+    result = apiobj.api.details(napi.PlaceID(332), linked_places=True)
 
     assert result.linked_rows == []
 
 
     assert result.linked_rows == []
 
@@ -197,8 +197,7 @@ def test_lookup_place_with_linked_places_existing(apiobj):
                      country_code='pl', linked_place_id=332,
                      rank_search=27, rank_address=26)
 
                      country_code='pl', linked_place_id=332,
                      rank_search=27, rank_address=26)
 
-    result = apiobj.api.details(napi.PlaceID(332),
-                               napi.LookupDetails(linked_places=True))
+    result = apiobj.api.details(napi.PlaceID(332), linked_places=True)
 
     assert result.linked_rows == [
                napi.AddressLine(place_id=1001, osm_object=('W', 5),
 
     assert result.linked_rows == [
                napi.AddressLine(place_id=1001, osm_object=('W', 5),
@@ -220,8 +219,7 @@ def test_lookup_place_with_parented_places_not_existing(apiobj):
                      country_code='pl', parent_place_id=45,
                      rank_search=27, rank_address=26)
 
                      country_code='pl', parent_place_id=45,
                      rank_search=27, rank_address=26)
 
-    result = apiobj.api.details(napi.PlaceID(332),
-                               napi.LookupDetails(parented_places=True))
+    result = apiobj.api.details(napi.PlaceID(332), parented_places=True)
 
     assert result.parented_rows == []
 
 
     assert result.parented_rows == []
 
@@ -240,8 +238,7 @@ def test_lookup_place_with_parented_places_existing(apiobj):
                      country_code='pl', parent_place_id=332,
                      rank_search=27, rank_address=26)
 
                      country_code='pl', parent_place_id=332,
                      rank_search=27, rank_address=26)
 
-    result = apiobj.api.details(napi.PlaceID(332),
-                               napi.LookupDetails(parented_places=True))
+    result = apiobj.api.details(napi.PlaceID(332), parented_places=True)
 
     assert result.parented_rows == [
                napi.AddressLine(place_id=1001, osm_object=('N', 5),
 
     assert result.parented_rows == [
                napi.AddressLine(place_id=1001, osm_object=('N', 5),
@@ -263,7 +260,7 @@ def test_lookup_in_osmline(apiobj, idobj):
                        indexed_date=import_date,
                        geometry='LINESTRING(23 34, 23 35)')
 
                        indexed_date=import_date,
                        geometry='LINESTRING(23 34, 23 35)')
 
-    result = apiobj.api.details(idobj, napi.LookupDetails())
+    result = apiobj.api.details(idobj)
 
     assert result is not None
 
 
     assert result is not None
 
@@ -310,13 +307,13 @@ def test_lookup_in_osmline_split_interpolation(apiobj):
                        startnumber=11, endnumber=20, step=1)
 
     for i in range(1, 6):
                        startnumber=11, endnumber=20, step=1)
 
     for i in range(1, 6):
-        result = apiobj.api.details(napi.OsmID('W', 9, str(i)), napi.LookupDetails())
+        result = apiobj.api.details(napi.OsmID('W', 9, str(i)))
         assert result.place_id == 1000
     for i in range(7, 11):
         assert result.place_id == 1000
     for i in range(7, 11):
-        result = apiobj.api.details(napi.OsmID('W', 9, str(i)), napi.LookupDetails())
+        result = apiobj.api.details(napi.OsmID('W', 9, str(i)))
         assert result.place_id == 1001
     for i in range(12, 22):
         assert result.place_id == 1001
     for i in range(12, 22):
-        result = apiobj.api.details(napi.OsmID('W', 9, str(i)), napi.LookupDetails())
+        result = apiobj.api.details(napi.OsmID('W', 9, str(i)))
         assert result.place_id == 1002
 
 
         assert result.place_id == 1002
 
 
@@ -340,30 +337,33 @@ def test_lookup_osmline_with_address_details(apiobj):
                               country_code='pl',
                               rank_search=17, rank_address=16)
 
                               country_code='pl',
                               rank_search=17, rank_address=16)
 
-    result = apiobj.api.details(napi.PlaceID(9000),
-                               napi.LookupDetails(address_details=True))
+    result = apiobj.api.details(napi.PlaceID(9000), address_details=True)
 
     assert result.address_rows == [
                napi.AddressLine(place_id=None, osm_object=None,
                                 category=('place', 'house_number'),
                                 names={'ref': '2'}, extratags={},
                                 admin_level=None, fromarea=True, isaddress=True,
 
     assert result.address_rows == [
                napi.AddressLine(place_id=None, osm_object=None,
                                 category=('place', 'house_number'),
                                 names={'ref': '2'}, extratags={},
                                 admin_level=None, fromarea=True, isaddress=True,
-                                rank_address=28, distance=0.0),
+                                rank_address=28, distance=0.0,
+                                local_name='2'),
                napi.AddressLine(place_id=332, osm_object=('W', 4),
                                 category=('highway', 'residential'),
                                 names={'name': 'Street'}, extratags={},
                                 admin_level=15, fromarea=True, isaddress=True,
                napi.AddressLine(place_id=332, osm_object=('W', 4),
                                 category=('highway', 'residential'),
                                 names={'name': 'Street'}, extratags={},
                                 admin_level=15, fromarea=True, isaddress=True,
-                                rank_address=26, distance=0.0),
+                                rank_address=26, distance=0.0,
+                                local_name='Street'),
                napi.AddressLine(place_id=1000, osm_object=('N', 3333),
                                 category=('place', 'suburb'),
                                 names={'name': 'Smallplace'}, extratags={},
                                 admin_level=13, fromarea=False, isaddress=True,
                napi.AddressLine(place_id=1000, osm_object=('N', 3333),
                                 category=('place', 'suburb'),
                                 names={'name': 'Smallplace'}, extratags={},
                                 admin_level=13, fromarea=False, isaddress=True,
-                                rank_address=23, distance=0.0034),
+                                rank_address=23, distance=0.0034,
+                                local_name='Smallplace'),
                napi.AddressLine(place_id=1001, osm_object=('N', 3334),
                                 category=('place', 'city'),
                                 names={'name': 'Bigplace'}, extratags={},
                                 admin_level=15, fromarea=True, isaddress=True,
                napi.AddressLine(place_id=1001, osm_object=('N', 3334),
                                 category=('place', 'city'),
                                 names={'name': 'Bigplace'}, extratags={},
                                 admin_level=15, fromarea=True, isaddress=True,
-                                rank_address=16, distance=0.0),
+                                rank_address=16, distance=0.0,
+                                local_name='Bigplace'),
                napi.AddressLine(place_id=None, osm_object=None,
                                 category=('place', 'country_code'),
                                 names={'ref': 'pl'}, extratags={},
                napi.AddressLine(place_id=None, osm_object=None,
                                 category=('place', 'country_code'),
                                 names={'ref': 'pl'}, extratags={},
@@ -383,7 +383,7 @@ def test_lookup_in_tiger(apiobj):
                       osm_type='W', osm_id=6601223,
                       geometry='LINESTRING(23 34, 23 35)')
 
                       osm_type='W', osm_id=6601223,
                       geometry='LINESTRING(23 34, 23 35)')
 
-    result = apiobj.api.details(napi.PlaceID(4924), napi.LookupDetails())
+    result = apiobj.api.details(napi.PlaceID(4924))
 
     assert result is not None
 
 
     assert result is not None
 
@@ -441,30 +441,33 @@ def test_lookup_tiger_with_address_details(apiobj):
                               country_code='us',
                               rank_search=17, rank_address=16)
 
                               country_code='us',
                               rank_search=17, rank_address=16)
 
-    result = apiobj.api.details(napi.PlaceID(9000),
-                               napi.LookupDetails(address_details=True))
+    result = apiobj.api.details(napi.PlaceID(9000), address_details=True)
 
     assert result.address_rows == [
                napi.AddressLine(place_id=None, osm_object=None,
                                 category=('place', 'house_number'),
                                 names={'ref': '2'}, extratags={},
                                 admin_level=None, fromarea=True, isaddress=True,
 
     assert result.address_rows == [
                napi.AddressLine(place_id=None, osm_object=None,
                                 category=('place', 'house_number'),
                                 names={'ref': '2'}, extratags={},
                                 admin_level=None, fromarea=True, isaddress=True,
-                                rank_address=28, distance=0.0),
+                                rank_address=28, distance=0.0,
+                                local_name='2'),
                napi.AddressLine(place_id=332, osm_object=('W', 4),
                                 category=('highway', 'residential'),
                                 names={'name': 'Street'}, extratags={},
                                 admin_level=15, fromarea=True, isaddress=True,
                napi.AddressLine(place_id=332, osm_object=('W', 4),
                                 category=('highway', 'residential'),
                                 names={'name': 'Street'}, extratags={},
                                 admin_level=15, fromarea=True, isaddress=True,
-                                rank_address=26, distance=0.0),
+                                rank_address=26, distance=0.0,
+                                local_name='Street'),
                napi.AddressLine(place_id=1000, osm_object=('N', 3333),
                                 category=('place', 'suburb'),
                                 names={'name': 'Smallplace'}, extratags={},
                                 admin_level=13, fromarea=False, isaddress=True,
                napi.AddressLine(place_id=1000, osm_object=('N', 3333),
                                 category=('place', 'suburb'),
                                 names={'name': 'Smallplace'}, extratags={},
                                 admin_level=13, fromarea=False, isaddress=True,
-                                rank_address=23, distance=0.0034),
+                                rank_address=23, distance=0.0034,
+                                local_name='Smallplace'),
                napi.AddressLine(place_id=1001, osm_object=('N', 3334),
                                 category=('place', 'city'),
                                 names={'name': 'Bigplace'}, extratags={},
                                 admin_level=15, fromarea=True, isaddress=True,
                napi.AddressLine(place_id=1001, osm_object=('N', 3334),
                                 category=('place', 'city'),
                                 names={'name': 'Bigplace'}, extratags={},
                                 admin_level=15, fromarea=True, isaddress=True,
-                                rank_address=16, distance=0.0),
+                                rank_address=16, distance=0.0,
+                                local_name='Bigplace'),
                napi.AddressLine(place_id=None, osm_object=None,
                                 category=('place', 'country_code'),
                                 names={'ref': 'us'}, extratags={},
                napi.AddressLine(place_id=None, osm_object=None,
                                 category=('place', 'country_code'),
                                 names={'ref': 'us'}, extratags={},
@@ -483,7 +486,7 @@ def test_lookup_in_postcode(apiobj):
                         indexed_date=import_date,
                         geometry='POINT(-9.45 5.6)')
 
                         indexed_date=import_date,
                         geometry='POINT(-9.45 5.6)')
 
-    result = apiobj.api.details(napi.PlaceID(554), napi.LookupDetails())
+    result = apiobj.api.details(napi.PlaceID(554))
 
     assert result is not None
 
 
     assert result is not None
 
@@ -537,25 +540,27 @@ def test_lookup_postcode_with_address_details(apiobj):
                               country_code='gb',
                               rank_search=17, rank_address=16)
 
                               country_code='gb',
                               rank_search=17, rank_address=16)
 
-    result = apiobj.api.details(napi.PlaceID(9000),
-                               napi.LookupDetails(address_details=True))
+    result = apiobj.api.details(napi.PlaceID(9000), address_details=True)
 
     assert result.address_rows == [
                napi.AddressLine(place_id=332, osm_object=('N', 3333),
                                 category=('place', 'suburb'),
                                 names={'name': 'Smallplace'}, extratags={},
                                 admin_level=13, fromarea=True, isaddress=True,
 
     assert result.address_rows == [
                napi.AddressLine(place_id=332, osm_object=('N', 3333),
                                 category=('place', 'suburb'),
                                 names={'name': 'Smallplace'}, extratags={},
                                 admin_level=13, fromarea=True, isaddress=True,
-                                rank_address=23, distance=0.0),
+                                rank_address=23, distance=0.0,
+                                local_name='Smallplace'),
                napi.AddressLine(place_id=1001, osm_object=('N', 3334),
                                 category=('place', 'city'),
                                 names={'name': 'Bigplace'}, extratags={},
                                 admin_level=15, fromarea=True, isaddress=True,
                napi.AddressLine(place_id=1001, osm_object=('N', 3334),
                                 category=('place', 'city'),
                                 names={'name': 'Bigplace'}, extratags={},
                                 admin_level=15, fromarea=True, isaddress=True,
-                                rank_address=16, distance=0.0),
+                                rank_address=16, distance=0.0,
+                                local_name='Bigplace'),
                napi.AddressLine(place_id=None, osm_object=None,
                                 category=('place', 'postcode'),
                                 names={'ref': '34 425'}, extratags={},
                                 admin_level=None, fromarea=False, isaddress=True,
                napi.AddressLine(place_id=None, osm_object=None,
                                 category=('place', 'postcode'),
                                 names={'ref': '34 425'}, extratags={},
                                 admin_level=None, fromarea=False, isaddress=True,
-                                rank_address=5, distance=0.0),
+                                rank_address=5, distance=0.0,
+                                local_name='34 425'),
                napi.AddressLine(place_id=None, osm_object=None,
                                 category=('place', 'country_code'),
                                 names={'ref': 'gb'}, extratags={},
                napi.AddressLine(place_id=None, osm_object=None,
                                 category=('place', 'country_code'),
                                 names={'ref': 'gb'}, extratags={},
@@ -570,7 +575,7 @@ def test_lookup_missing_object(apiobj, objid):
     apiobj.add_placex(place_id=1, osm_type='N', osm_id=55,
                       class_='place', type='suburb')
 
     apiobj.add_placex(place_id=1, osm_type='N', osm_id=55,
                       class_='place', type='suburb')
 
-    assert apiobj.api.details(objid, napi.LookupDetails()) is None
+    assert apiobj.api.details(objid) is None
 
 
 @pytest.mark.parametrize('gtype', (napi.GeometryFormat.KML,
 
 
 @pytest.mark.parametrize('gtype', (napi.GeometryFormat.KML,
@@ -580,5 +585,4 @@ def test_lookup_unsupported_geometry(apiobj, gtype):
     apiobj.add_placex(place_id=332)
 
     with pytest.raises(ValueError):
     apiobj.add_placex(place_id=332)
 
     with pytest.raises(ValueError):
-        apiobj.api.details(napi.PlaceID(332),
-                          napi.LookupDetails(geometry_output=gtype))
+        apiobj.api.details(napi.PlaceID(332), geometry_output=gtype)