]> git.openstreetmap.org Git - nominatim.git/blobdiff - test/python/api/search/test_search_postcode.py
enable flake for Python tests
[nominatim.git] / test / python / api / search / test_search_postcode.py
index 369e15045e0fd4ecf11721e67ee342cb661ddef3..529fb409609a759c9a01c552bbcb285ba882fe38 100644 (file)
@@ -2,7 +2,7 @@
 #
 # This file is part of Nominatim. (https://nominatim.org)
 #
-# Copyright (C) 2024 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 running the postcode searcher.
@@ -15,6 +15,7 @@ from nominatim_api.search.db_searches import PostcodeSearch
 from nominatim_api.search.db_search_fields import WeightedStrings, FieldLookup, \
                                                   FieldRanking, RankedTokens
 
+
 def run_search(apiobj, frontend, global_penalty, pcs, pc_penalties=None,
                ccodes=[], lookup=[], ranking=[], details=SearchDetails()):
     if pc_penalties is None:
@@ -85,26 +86,24 @@ class TestPostcodeSearchWithAddress:
         apiobj.add_placex(place_id=1000, class_='place', type='village',
                           rank_search=22, rank_address=22,
                           country_code='ch')
-        apiobj.add_search_name(1000, names=[1,2,10,11],
+        apiobj.add_search_name(1000, names=[1, 2, 10, 11],
                                search_rank=22, address_rank=22,
                                country_code='ch')
         apiobj.add_placex(place_id=2000, class_='place', type='village',
                           rank_search=22, rank_address=22,
                           country_code='pl')
-        apiobj.add_search_name(2000, names=[1,2,20,21],
+        apiobj.add_search_name(2000, names=[1, 2, 20, 21],
                                search_rank=22, address_rank=22,
                                country_code='pl')
 
-
     def test_lookup_both(self, apiobj, frontend):
-        lookup = FieldLookup('name_vector', [1,2], 'restrict')
+        lookup = FieldLookup('name_vector', [1, 2], 'restrict')
         ranking = FieldRanking('name_vector', 0.3, [RankedTokens(0.0, [10])])
 
         results = run_search(apiobj, frontend, 0.1, ['12345'], lookup=[lookup], ranking=[ranking])
 
         assert [r.place_id for r in results] == [100, 101]
 
-
     def test_restrict_by_name(self, apiobj, frontend):
         lookup = FieldLookup('name_vector', [10], 'restrict')
 
@@ -112,11 +111,10 @@ class TestPostcodeSearchWithAddress:
 
         assert [r.place_id for r in results] == [100]
 
-
     @pytest.mark.parametrize('coord,place_id', [((16.5, 5), 100),
                                                 ((-45.1, 7.004), 101)])
     def test_lookup_near(self, apiobj, frontend, coord, place_id):
-        lookup = FieldLookup('name_vector', [1,2], 'restrict')
+        lookup = FieldLookup('name_vector', [1, 2], 'restrict')
         ranking = FieldRanking('name_vector', 0.3, [RankedTokens(0.0, [10])])
 
         results = run_search(apiobj, frontend, 0.1, ['12345'],
@@ -126,7 +124,6 @@ class TestPostcodeSearchWithAddress:
 
         assert [r.place_id for r in results] == [place_id]
 
-
     @pytest.mark.parametrize('geom', [napi.GeometryFormat.GEOJSON,
                                       napi.GeometryFormat.KML,
                                       napi.GeometryFormat.SVG,
@@ -138,18 +135,16 @@ class TestPostcodeSearchWithAddress:
         assert results
         assert all(geom.name.lower() in r.geometry for r in results)
 
-
-    @pytest.mark.parametrize('viewbox, rids', [('-46,6,-44,8', [101,100]),
-                                               ('16,4,18,6', [100,101])])
+    @pytest.mark.parametrize('viewbox, rids', [('-46,6,-44,8', [101, 100]),
+                                               ('16,4,18,6', [100, 101])])
     def test_prefer_viewbox(self, apiobj, frontend, viewbox, rids):
         results = run_search(apiobj, frontend, 0.1, ['12345'],
                              details=SearchDetails.from_kwargs({'viewbox': viewbox}))
 
         assert [r.place_id for r in results] == rids
 
-
     @pytest.mark.parametrize('viewbox, rid', [('-46,6,-44,8', 101),
-                                               ('16,4,18,6', 100)])
+                                              ('16,4,18,6', 100)])
     def test_restrict_to_viewbox(self, apiobj, frontend, viewbox, rid):
         results = run_search(apiobj, frontend, 0.1, ['12345'],
                              details=SearchDetails.from_kwargs({'viewbox': viewbox,
@@ -157,7 +152,6 @@ class TestPostcodeSearchWithAddress:
 
         assert [r.place_id for r in results] == [rid]
 
-
     @pytest.mark.parametrize('coord,rids', [((17.05, 5), [100, 101]),
                                             ((-45, 7.1), [101, 100])])
     def test_prefer_near(self, apiobj, frontend, coord, rids):
@@ -166,7 +160,6 @@ class TestPostcodeSearchWithAddress:
 
         assert [r.place_id for r in results] == rids
 
-
     @pytest.mark.parametrize('pid,rid', [(100, 101), (101, 100)])
     def test_exclude(self, apiobj, frontend, pid, rid):
         results = run_search(apiobj, frontend, 0.1, ['12345'],