]> git.openstreetmap.org Git - nominatim.git/commitdiff
enable BDD tests for sqlite databases
authorSarah Hoffmann <lonvia@denofr.de>
Fri, 13 Oct 2023 19:32:03 +0000 (21:32 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Mon, 23 Oct 2023 15:19:12 +0000 (17:19 +0200)
The database must currently be created by hand and the name handed
in via -DAPI_TEST_DB='sqlite:...'.

18 files changed:
nominatim/api/reverse.py
test/bdd/api/details/language.feature
test/bdd/api/details/params.feature
test/bdd/api/details/simple.feature
test/bdd/api/errors/formats.feature
test/bdd/api/lookup/simple.feature
test/bdd/api/reverse/geometry.feature
test/bdd/api/reverse/language.feature
test/bdd/api/reverse/layers.feature
test/bdd/api/reverse/queries.feature
test/bdd/api/reverse/v1_geocodejson.feature
test/bdd/api/reverse/v1_geojson.feature
test/bdd/api/reverse/v1_json.feature
test/bdd/api/reverse/v1_params.feature
test/bdd/api/reverse/v1_xml.feature
test/bdd/api/status/simple.feature
test/bdd/environment.py
test/bdd/steps/nominatim_environment.py

index 78400a5663671e918477376a58faff8c137646a4..78e3a20c4900827781cfa97eac8c37b0833c57d0 100644 (file)
@@ -436,7 +436,7 @@ class ReverseGeocoder:
                   .where(t.c.indexed_status == 0)\
                   .where(t.c.linked_place_id == None)\
                   .where(self._filter_by_layer(t))\
-                  .where(t.c.geometry.intersects(sa.func.ST_Expand(WKT_PARAM, 0.001)))\
+                  .where(t.c.geometry.intersects(sa.func.ST_Expand(WKT_PARAM, 0.007)))\
                   .order_by(sa.desc(t.c.rank_search))\
                   .order_by('distance')\
                   .limit(50)\
index 6611c81b527df0f791a1078ba660c61a22741c13..5351ce417185a5a813e9ee5ffcf1ce18491828a1 100644 (file)
@@ -1,3 +1,4 @@
+@SQLITE
 @APIDB
 Feature: Localization of search results
 
index 3d5635de126c6136c575a2f7e860e6f7492d7234..0fb641712446a268a6a877239c83fcd6bc2c1db9 100644 (file)
@@ -2,6 +2,7 @@
 Feature: Object details
     Testing different parameter options for details API.
 
+    @SQLITE
     Scenario: JSON Details
         When sending json details query for W297699560
         Then the result is valid json
@@ -11,6 +12,7 @@ Feature: Object details
             | type  |
             | Point |
 
+    @SQLITE
     Scenario: JSON Details with pretty printing
         When sending json details query for W297699560
             | pretty |
@@ -19,6 +21,7 @@ Feature: Object details
         And result has attributes geometry
         And result has not attributes keywords,address,linked_places,parentof
 
+    @SQLITE
      Scenario: JSON Details with addressdetails
         When sending json details query for W297699560
             | addressdetails |
@@ -26,6 +29,7 @@ Feature: Object details
         Then the result is valid json
         And result has attributes address
 
+    @SQLITE
     Scenario: JSON Details with linkedplaces
         When sending json details query for R123924
             | linkedplaces |
@@ -33,6 +37,7 @@ Feature: Object details
         Then the result is valid json
         And result has attributes linked_places
 
+    @SQLITE
     Scenario: JSON Details with hierarchy
         When sending json details query for W297699560
             | hierarchy |
@@ -40,6 +45,7 @@ Feature: Object details
         Then the result is valid json
         And result has attributes hierarchy
 
+    @SQLITE
     Scenario: JSON Details with grouped hierarchy
         When sending json details query for W297699560
             | hierarchy | group_hierarchy |
@@ -69,6 +75,7 @@ Feature: Object details
         Then the result is valid json
         And result has attributes keywords
 
+    @SQLITE
     Scenario Outline: JSON details with full geometry
         When sending json details query for <osmid>
             | polygon_geojson |
index 4c54b0d67c0fe8d6a8e78153da771638003dc450..99d3422334b3baf36b18040dc883727b72c76bd7 100644 (file)
@@ -1,3 +1,4 @@
+@SQLITE
 @APIDB
 Feature: Object details
     Check details page for correctness
index 8a8e656113cf81daf6e8801a5007ed0f1ee58b2c..e279a8fa9e12978b8c93622538b2bffa640c8360 100644 (file)
@@ -1,3 +1,4 @@
+@SQLITE
 @APIDB
 Feature: Places by osm_type and osm_id Tests
     Simple tests for errors in various response formats.
index 9ea388122868c54b53d9b2211b942bfb33ecdab2..1e5b8ee77744672571a0603d9b7b0e8981f0f032 100644 (file)
@@ -1,3 +1,4 @@
+@SQLITE
 @APIDB
 Feature: Places by osm_type and osm_id Tests
     Simple tests for response format.
index 2c14dd5f2a5d19d40b6b7264dc41debd5074afff..33fadbbdff5a106d26c8679f8c0fbf31d270b6be 100644 (file)
@@ -1,3 +1,4 @@
+@SQLITE
 @APIDB
 Feature: Geometries for reverse geocoding
     Tests for returning geometries with reverse
@@ -9,7 +10,7 @@ Feature: Geometries for reverse geocoding
           | 1            |
         Then results contain
           | geotext |
-          | POLYGON((9.5225302 47.138066,9.5225348 47.1379282,9.5226142 47.1379294,9.5226143 47.1379257,9.522615 47.137917,9.5226225 47.1379098,9.5226334 47.1379052,9.5226461 47.1379037,9.5226588 47.1379056,9.5226693 47.1379107,9.5226762 47.1379181,9.5226762 47.1379268,9.5226761 47.1379308,9.5227366 47.1379317,9.5227352 47.1379753,9.5227608 47.1379757,9.5227595 47.1380148,9.5227355 47.1380145,9.5227337 47.1380692,9.5225302 47.138066)) |
+          | ^POLYGON\(\(9.5225302 47.138066, ?9.5225348 47.1379282, ?9.5226142 47.1379294, ?9.5226143 47.1379257, ?9.522615 47.137917, ?9.5226225 47.1379098, ?9.5226334 47.1379052, ?9.5226461 47.1379037, ?9.5226588 47.1379056, ?9.5226693 47.1379107, ?9.5226762 47.1379181, ?9.5226762 47.1379268, ?9.5226761 47.1379308, ?9.5227366 47.1379317, ?9.5227352 47.1379753, ?9.5227608 47.1379757, ?9.5227595 47.1380148, ?9.5227355 47.1380145, ?9.5227337 47.1380692, ?9.5225302 47.138066\)\) |
 
 
     Scenario: Polygons can be slightly simplified
@@ -18,7 +19,7 @@ Feature: Geometries for reverse geocoding
           | 1            | 0.00001            |
         Then results contain
           | geotext |
-          | POLYGON((9.5225302 47.138066,9.5225348 47.1379282,9.5226142 47.1379294,9.5226225 47.1379098,9.5226588 47.1379056,9.5226761 47.1379308,9.5227366 47.1379317,9.5227352 47.1379753,9.5227608 47.1379757,9.5227595 47.1380148,9.5227355 47.1380145,9.5227337 47.1380692,9.5225302 47.138066)) |
+          | ^POLYGON\(\(9.5225302 47.138066, ?9.5225348 47.1379282, ?9.5226142 47.1379294, ?9.5226225 47.1379098, ?9.5226588 47.1379056, ?9.5226761 47.1379308, ?9.5227366 47.1379317, ?9.5227352 47.1379753, ?9.5227608 47.1379757, ?9.5227595 47.1380148, ?9.5227355 47.1380145, ?9.5227337 47.1380692, ?9.5225302 47.138066\)\) |
 
 
     Scenario: Polygons can be much simplified
@@ -27,7 +28,7 @@ Feature: Geometries for reverse geocoding
           | 1            | 0.9               |
         Then results contain
           | geotext |
-          | POLYGON((9.5225302 47.138066,9.5225348 47.1379282,9.5227608 47.1379757,9.5227337 47.1380692,9.5225302 47.138066)) |
+          | ^POLYGON\(\(9.5225302 47.138066, ?9.5225348 47.1379282, ?9.5227608 47.1379757, ?9.5227337 47.1380692, ?9.5225302 47.138066\)\) |
 
 
     Scenario: For polygons return the centroid as center point
index e42689f73d12a9aeb0df1bd7e783398e274e93b4..69f84ebc4a030cdbe4cd89d47307d90b9b86c046 100644 (file)
@@ -1,3 +1,4 @@
+@SQLITE
 @APIDB
 Feature: Localization of reverse search results
 
index d4c334a54e170fa5ff28e908767851835458b7e2..ef02886478cbc81aae2358b99f15f2a6692c8b55 100644 (file)
@@ -1,3 +1,4 @@
+@SQLITE
 @APIDB
 Feature: Layer parameter in reverse geocoding
     Testing correct function of layer selection while reverse geocoding
@@ -57,7 +58,7 @@ Feature: Layer parameter in reverse geocoding
 
     @v1-api-python-only
     Scenario Outline: Search for mountain peaks begins at level 12
-        When sending v1/reverse at 47.08221,9.56769
+        When sending v1/reverse at 47.08293,9.57109
           | layer   | zoom   |
           | natural | <zoom> |
         Then results contain
@@ -71,7 +72,7 @@ Feature: Layer parameter in reverse geocoding
 
 
     @v1-api-python-only
-     Scenario Outline: Reverse serach with manmade layers
+     Scenario Outline: Reverse search with manmade layers
         When sending v1/reverse at 32.46904,-86.44439
           | layer   |
           | <layer> |
@@ -84,5 +85,5 @@ Feature: Layer parameter in reverse geocoding
           | manmade         | leisure  | park        |
           | address         | highway  | residential |
           | poi             | leisure  | pitch       |
-          | natural         | waterway | stream      |
+          | natural         | waterway | river       |
           | natural,manmade | leisure  | park        |
index d51378d6443dab6e2a0254dc7a23bf969daba2b6..37abb22d4095317a397c2bf35fff71924efdbd63 100644 (file)
@@ -1,3 +1,4 @@
+@SQLITE
 @APIDB
 Feature: Reverse geocoding
     Testing the reverse function
index c9112b94c591439779163a0b4f8626b71b125326..56b85e2009d2618c0db9a071eff528ab031dc7dd 100644 (file)
@@ -1,3 +1,4 @@
+@SQLITE
 @APIDB
 Feature: Geocodejson for Reverse API
     Testing correctness of geocodejson output (API version v1).
index 0b6ad0d3a3ff6744a277855abcec1a88d7a1b577..e705529d38be7a6e8730dc71128c1adb2dbbb6ae 100644 (file)
@@ -1,3 +1,4 @@
+@SQLITE
 @APIDB
 Feature: Geojson for Reverse API
     Testing correctness of geojson output (API version v1).
index ac3c799ed8d71c9c9956ad6bc450a1f8fa39f57a..1f629c0fa110941d1e4ea70e6c3b3b6fbce8d00b 100644 (file)
@@ -1,3 +1,4 @@
+@SQLITE
 @APIDB
 Feature: Json output for Reverse API
     Testing correctness of json and jsonv2 output (API version v1).
@@ -93,7 +94,7 @@ Feature: Json output for Reverse API
           | polygon_text | 1     |
        Then results contain
           | geotext |
-          | LINESTRING(9.5039353 47.0657546,9.5040437 47.0657781,9.5040808 47.065787,9.5054298 47.0661407) |
+          | ^LINESTRING\(9.5039353 47.0657546, ?9.5040437 47.0657781, ?9.5040808 47.065787, ?9.5054298 47.0661407\) |
 
        Examples:
           | format |
index 70a6505bfa7730e042348860d23bc58512dcb606..a1f08afd37d6919e20af7f00741012ff07ba0bae 100644 (file)
@@ -1,3 +1,4 @@
+@SQLITE
 @APIDB
 Feature: v1/reverse Parameter Tests
     Tests for parameter inputs for the v1 reverse endpoint.
index 75f27220497009eb65c2d7e0daee3b0b426eed50..95e7478ca6daadf2bcbd54f23cccab3187ae0ef6 100644 (file)
@@ -1,3 +1,4 @@
+@SQLITE
 @APIDB
 Feature: XML output for Reverse API
     Testing correctness of xml output (API version v1).
@@ -66,7 +67,7 @@ Feature: XML output for Reverse API
           | polygon_text | 1     |
        Then results contain
           | geotext |
-          | LINESTRING(9.5039353 47.0657546,9.5040437 47.0657781,9.5040808 47.065787,9.5054298 47.0661407) |
+          | ^LINESTRING\(9.5039353 47.0657546, ?9.5040437 47.0657781, ?9.5040808 47.065787, ?9.5054298 47.0661407\) |
 
 
     Scenario: Output of SVG
index 1323caa161ec581b2700401edb3e3f5c95b913b8..993fa1ecb48e31bcbc876831476957df3f65ab40 100644 (file)
@@ -1,3 +1,4 @@
+@SQLITE
 @APIDB
 Feature: Status queries
     Testing status query
index afaa51512a7c1041e659725e2bc6ca9bfaaae77e..664b5ac79e7d2013182ebff5036f04889870f586 100644 (file)
@@ -46,7 +46,10 @@ def before_all(context):
 
 
 def before_scenario(context, scenario):
-    if 'DB' in context.tags:
+    if not 'SQLITE' in context.tags \
+       and context.config.userdata['API_TEST_DB'].startswith('sqlite:'):
+        context.scenario.skip("Not usable with Sqlite database.")
+    elif 'DB' in context.tags:
         context.nominatim.setup_db(context)
     elif 'APIDB' in context.tags:
         context.nominatim.setup_api_db()
index 7299988b2330d5369d27d312c350afed48f53500..11dede3049854a323388fceae13fa61b428fb689 100644 (file)
@@ -86,7 +86,10 @@ class NominatimEnvironment:
             be picked up by dotenv and creates a project directory with the
             appropriate website scripts.
         """
-        dsn = 'pgsql:dbname={}'.format(dbname)
+        if dbname.startswith('sqlite:'):
+            dsn = 'sqlite:dbname={}'.format(dbname[7:])
+        else:
+            dsn = 'pgsql:dbname={}'.format(dbname)
         if self.db_host:
             dsn += ';host=' + self.db_host
         if self.db_port:
@@ -197,6 +200,9 @@ class NominatimEnvironment:
         """
         self.write_nominatim_config(self.api_test_db)
 
+        if self.api_test_db.startswith('sqlite:'):
+            return
+
         if not self.api_db_done:
             self.api_db_done = True