]> git.openstreetmap.org Git - nominatim.git/blobdiff - test/python/api/test_api_lookup.py
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / test / python / api / test_api_lookup.py
index 48b0777667c8199934e4cd7994e82feffde54570..a2660f51c1a5cb4598b6ec69001f8a2ef2910414 100644 (file)
@@ -2,7 +2,7 @@
 #
 # This file is part of Nominatim. (https://nominatim.org)
 #
-# Copyright (C) 2023 by the Nominatim developer community.
+# Copyright (C) 2025 by the Nominatim developer community.
 # For a full list of authors see the git log.
 """
 Tests for lookup API call.
@@ -11,7 +11,8 @@ import json
 
 import pytest
 
-import nominatim.api as napi
+import nominatim_api as napi
+
 
 def test_lookup_empty_list(apiobj, frontend):
     api = frontend(apiobj, options={'details'})
@@ -28,17 +29,17 @@ def test_lookup_non_existing(apiobj, frontend):
                                    napi.OsmID('W', 4, 'highway')))
 def test_lookup_single_placex(apiobj, frontend, idobj):
     apiobj.add_placex(place_id=332, osm_type='W', osm_id=4,
-                     class_='highway', type='residential',
-                     name={'name': 'Road'}, address={'city': 'Barrow'},
-                     extratags={'surface': 'paved'},
-                     parent_place_id=34, linked_place_id=55,
-                     admin_level=15, country_code='gb',
-                     housenumber='4',
-                     postcode='34425', wikipedia='en:Faa',
-                     rank_search=27, rank_address=26,
-                     importance=0.01,
-                     centroid=(23, 34),
-                     geometry='LINESTRING(23 34, 23.1 34, 23.1 34.1, 23 34)')
+                      class_='highway', type='residential',
+                      name={'name': 'Road'}, address={'city': 'Barrow'},
+                      extratags={'surface': 'paved'},
+                      parent_place_id=34, linked_place_id=55,
+                      admin_level=15, country_code='gb',
+                      housenumber='4',
+                      postcode='34425', wikipedia='en:Faa',
+                      rank_search=27, rank_address=26,
+                      importance=0.01,
+                      centroid=(23, 34),
+                      geometry='LINESTRING(23 34, 23.1 34, 23.1 34.1, 23 34)')
 
     api = frontend(apiobj, options={'details'})
     result = api.lookup([idobj])
@@ -79,17 +80,17 @@ def test_lookup_single_placex(apiobj, frontend, idobj):
 
 def test_lookup_multiple_places(apiobj, frontend):
     apiobj.add_placex(place_id=332, osm_type='W', osm_id=4,
-                     class_='highway', type='residential',
-                     name={'name': 'Road'}, address={'city': 'Barrow'},
-                     extratags={'surface': 'paved'},
-                     parent_place_id=34, linked_place_id=55,
-                     admin_level=15, country_code='gb',
-                     housenumber='4',
-                     postcode='34425', wikipedia='en:Faa',
-                     rank_search=27, rank_address=26,
-                     importance=0.01,
-                     centroid=(23, 34),
-                     geometry='LINESTRING(23 34, 23.1 34, 23.1 34.1, 23 34)')
+                      class_='highway', type='residential',
+                      name={'name': 'Road'}, address={'city': 'Barrow'},
+                      extratags={'surface': 'paved'},
+                      parent_place_id=34, linked_place_id=55,
+                      admin_level=15, country_code='gb',
+                      housenumber='4',
+                      postcode='34425', wikipedia='en:Faa',
+                      rank_search=27, rank_address=26,
+                      importance=0.01,
+                      centroid=(23, 34),
+                      geometry='LINESTRING(23 34, 23.1 34, 23.1 34.1, 23 34)')
     apiobj.add_osmline(place_id=4924, osm_id=9928,
                        parent_place_id=12,
                        startnumber=1, endnumber=4, step=1,
@@ -97,7 +98,6 @@ def test_lookup_multiple_places(apiobj, frontend):
                        address={'city': 'Big'},
                        geometry='LINESTRING(23 34, 23 35)')
 
-
     api = frontend(apiobj, options={'details'})
     result = api.lookup((napi.OsmID('W', 1),
                          napi.OsmID('W', 4),
@@ -111,17 +111,17 @@ def test_lookup_multiple_places(apiobj, frontend):
 @pytest.mark.parametrize('gtype', list(napi.GeometryFormat))
 def test_simple_place_with_geometry(apiobj, frontend, gtype):
     apiobj.add_placex(place_id=332, osm_type='W', osm_id=4,
-                     class_='highway', type='residential',
-                     name={'name': 'Road'}, address={'city': 'Barrow'},
-                     extratags={'surface': 'paved'},
-                     parent_place_id=34, linked_place_id=55,
-                     admin_level=15, country_code='gb',
-                     housenumber='4',
-                     postcode='34425', wikipedia='en:Faa',
-                     rank_search=27, rank_address=26,
-                     importance=0.01,
-                     centroid=(23, 34),
-                     geometry='POLYGON((23 34, 23.1 34, 23.1 34.1, 23 34))')
+                      class_='highway', type='residential',
+                      name={'name': 'Road'}, address={'city': 'Barrow'},
+                      extratags={'surface': 'paved'},
+                      parent_place_id=34, linked_place_id=55,
+                      admin_level=15, country_code='gb',
+                      housenumber='4',
+                      postcode='34425', wikipedia='en:Faa',
+                      rank_search=27, rank_address=26,
+                      importance=0.01,
+                      centroid=(23, 34),
+                      geometry='POLYGON((23 34, 23.1 34, 23.1 34.1, 23 34))')
 
     api = frontend(apiobj, options={'details'})
     result = api.lookup([napi.OsmID('W', 4)], geometry_output=gtype)
@@ -137,17 +137,17 @@ def test_simple_place_with_geometry(apiobj, frontend, gtype):
 
 def test_simple_place_with_geometry_simplified(apiobj, frontend):
     apiobj.add_placex(place_id=332, osm_type='W', osm_id=4,
-                     class_='highway', type='residential',
-                     name={'name': 'Road'}, address={'city': 'Barrow'},
-                     extratags={'surface': 'paved'},
-                     parent_place_id=34, linked_place_id=55,
-                     admin_level=15, country_code='gb',
-                     housenumber='4',
-                     postcode='34425', wikipedia='en:Faa',
-                     rank_search=27, rank_address=26,
-                     importance=0.01,
-                     centroid=(23, 34),
-                     geometry='POLYGON((23 34, 22.999 34, 23.1 34, 23.1 34.1, 23 34))')
+                      class_='highway', type='residential',
+                      name={'name': 'Road'}, address={'city': 'Barrow'},
+                      extratags={'surface': 'paved'},
+                      parent_place_id=34, linked_place_id=55,
+                      admin_level=15, country_code='gb',
+                      housenumber='4',
+                      postcode='34425', wikipedia='en:Faa',
+                      rank_search=27, rank_address=26,
+                      importance=0.01,
+                      centroid=(23, 34),
+                      geometry='POLYGON((23 34, 22.999 34, 23.1 34, 23.1 34.1, 23 34))')
 
     api = frontend(apiobj, options={'details'})
     result = api.lookup([napi.OsmID('W', 4)],
@@ -159,5 +159,5 @@ def test_simple_place_with_geometry_simplified(apiobj, frontend):
 
     geom = json.loads(result[0].geometry['geojson'])
 
-    assert geom['type']  == 'Polygon'
+    assert geom['type'] == 'Polygon'
     assert geom['coordinates'] == [[[23, 34], [23.1, 34], [23.1, 34.1], [23, 34]]]