]> 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 adba11ad05b3519cbf28dbca0e22fe85bf2ca7b7..6939ddb9ba28c19ef59656ea9652511fb9272f11 100644 (file)
@@ -58,7 +58,7 @@ def test_lookup_in_placex(apiobj, idobj):
     assert result.importance == pytest.approx(0.01)
 
     assert result.country_code == 'gb'
     assert result.importance == pytest.approx(0.01)
 
     assert result.country_code == 'gb'
-    assert result.indexed_date == import_date
+    assert result.indexed_date == import_date.replace(tzinfo=dt.timezone.utc)
 
     assert result.address_rows is None
     assert result.linked_rows is None
 
     assert result.address_rows is None
     assert result.linked_rows is None
@@ -106,7 +106,7 @@ def test_lookup_in_placex_minimal_info(apiobj):
     assert result.importance is None
 
     assert result.country_code is None
     assert result.importance is None
 
     assert result.country_code is None
-    assert result.indexed_date == import_date
+    assert result.indexed_date == import_date.replace(tzinfo=dt.timezone.utc)
 
     assert result.address_rows is None
     assert result.linked_rows is None
 
     assert result.address_rows is None
     assert result.linked_rows is None
@@ -290,7 +290,7 @@ def test_lookup_in_osmline(apiobj, idobj):
     assert result.importance is None
 
     assert result.country_code == 'gb'
     assert result.importance is None
 
     assert result.country_code == 'gb'
-    assert result.indexed_date == import_date
+    assert result.indexed_date == import_date.replace(tzinfo=dt.timezone.utc)
 
     assert result.address_rows is None
     assert result.linked_rows is None
 
     assert result.address_rows is None
     assert result.linked_rows is None
@@ -378,6 +378,10 @@ def test_lookup_in_tiger(apiobj):
                      startnumber=1, endnumber=4, step=1,
                      postcode='34425',
                      geometry='LINESTRING(23 34, 23 35)')
                      startnumber=1, endnumber=4, step=1,
                      postcode='34425',
                      geometry='LINESTRING(23 34, 23 35)')
+    apiobj.add_placex(place_id=12,
+                      category=('highway', 'residential'),
+                      osm_type='W', osm_id=6601223,
+                      geometry='LINESTRING(23 34, 23 35)')
 
     result = apiobj.api.lookup(napi.PlaceID(4924), napi.LookupDetails())
 
 
     result = apiobj.api.lookup(napi.PlaceID(4924), napi.LookupDetails())
 
@@ -390,7 +394,7 @@ def test_lookup_in_tiger(apiobj):
     assert result.place_id == 4924
     assert result.parent_place_id == 12
     assert result.linked_place_id is None
     assert result.place_id == 4924
     assert result.parent_place_id == 12
     assert result.linked_place_id is None
-    assert result.osm_object is None
+    assert result.osm_object == ('W', 6601223)
     assert result.admin_level == 15
 
     assert result.names is None
     assert result.admin_level == 15
 
     assert result.names is None
@@ -506,7 +510,7 @@ def test_lookup_in_postcode(apiobj):
     assert result.importance is None
 
     assert result.country_code == 'gb'
     assert result.importance is None
 
     assert result.country_code == 'gb'
-    assert result.indexed_date == import_date
+    assert result.indexed_date == import_date.replace(tzinfo=dt.timezone.utc)
 
     assert result.address_rows is None
     assert result.linked_rows is None
 
     assert result.address_rows is None
     assert result.linked_rows is None
@@ -559,6 +563,15 @@ def test_lookup_postcode_with_address_details(apiobj):
                                 rank_address=4, distance=0.0)
            ]
 
                                 rank_address=4, distance=0.0)
            ]
 
+@pytest.mark.parametrize('objid', [napi.PlaceID(1736),
+                                   napi.OsmID('W', 55),
+                                   napi.OsmID('N', 55, 'amenity')])
+def test_lookup_missing_object(apiobj, objid):
+    apiobj.add_placex(place_id=1, osm_type='N', osm_id=55,
+                      class_='place', type='suburb')
+
+    assert apiobj.api.lookup(objid, napi.LookupDetails()) is None
+
 
 @pytest.mark.parametrize('gtype', (napi.GeometryFormat.KML,
                                     napi.GeometryFormat.SVG,
 
 @pytest.mark.parametrize('gtype', (napi.GeometryFormat.KML,
                                     napi.GeometryFormat.SVG,