From: Sarah Hoffmann Date: Fri, 13 Oct 2023 19:32:03 +0000 (+0200) Subject: enable BDD tests for sqlite databases X-Git-Tag: v4.4.0~87^2~4 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/d8dca2a3a9049db7da8b805042833846a188290d?ds=sidebyside enable BDD tests for sqlite databases The database must currently be created by hand and the name handed in via -DAPI_TEST_DB='sqlite:...'. --- diff --git a/nominatim/api/reverse.py b/nominatim/api/reverse.py index 78400a56..78e3a20c 100644 --- a/nominatim/api/reverse.py +++ b/nominatim/api/reverse.py @@ -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)\ diff --git a/test/bdd/api/details/language.feature b/test/bdd/api/details/language.feature index 6611c81b..5351ce41 100644 --- a/test/bdd/api/details/language.feature +++ b/test/bdd/api/details/language.feature @@ -1,3 +1,4 @@ +@SQLITE @APIDB Feature: Localization of search results diff --git a/test/bdd/api/details/params.feature b/test/bdd/api/details/params.feature index 3d5635de..0fb64171 100644 --- a/test/bdd/api/details/params.feature +++ b/test/bdd/api/details/params.feature @@ -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 | polygon_geojson | diff --git a/test/bdd/api/details/simple.feature b/test/bdd/api/details/simple.feature index 4c54b0d6..99d34223 100644 --- a/test/bdd/api/details/simple.feature +++ b/test/bdd/api/details/simple.feature @@ -1,3 +1,4 @@ +@SQLITE @APIDB Feature: Object details Check details page for correctness diff --git a/test/bdd/api/errors/formats.feature b/test/bdd/api/errors/formats.feature index 8a8e6561..e279a8fa 100644 --- a/test/bdd/api/errors/formats.feature +++ b/test/bdd/api/errors/formats.feature @@ -1,3 +1,4 @@ +@SQLITE @APIDB Feature: Places by osm_type and osm_id Tests Simple tests for errors in various response formats. diff --git a/test/bdd/api/lookup/simple.feature b/test/bdd/api/lookup/simple.feature index 9ea38812..1e5b8ee7 100644 --- a/test/bdd/api/lookup/simple.feature +++ b/test/bdd/api/lookup/simple.feature @@ -1,3 +1,4 @@ +@SQLITE @APIDB Feature: Places by osm_type and osm_id Tests Simple tests for response format. diff --git a/test/bdd/api/reverse/geometry.feature b/test/bdd/api/reverse/geometry.feature index 2c14dd5f..33fadbbd 100644 --- a/test/bdd/api/reverse/geometry.feature +++ b/test/bdd/api/reverse/geometry.feature @@ -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 diff --git a/test/bdd/api/reverse/language.feature b/test/bdd/api/reverse/language.feature index e42689f7..69f84ebc 100644 --- a/test/bdd/api/reverse/language.feature +++ b/test/bdd/api/reverse/language.feature @@ -1,3 +1,4 @@ +@SQLITE @APIDB Feature: Localization of reverse search results diff --git a/test/bdd/api/reverse/layers.feature b/test/bdd/api/reverse/layers.feature index d4c334a5..ef028864 100644 --- a/test/bdd/api/reverse/layers.feature +++ b/test/bdd/api/reverse/layers.feature @@ -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 | | 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 | | | @@ -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 | diff --git a/test/bdd/api/reverse/queries.feature b/test/bdd/api/reverse/queries.feature index d51378d6..37abb22d 100644 --- a/test/bdd/api/reverse/queries.feature +++ b/test/bdd/api/reverse/queries.feature @@ -1,3 +1,4 @@ +@SQLITE @APIDB Feature: Reverse geocoding Testing the reverse function diff --git a/test/bdd/api/reverse/v1_geocodejson.feature b/test/bdd/api/reverse/v1_geocodejson.feature index c9112b94..56b85e20 100644 --- a/test/bdd/api/reverse/v1_geocodejson.feature +++ b/test/bdd/api/reverse/v1_geocodejson.feature @@ -1,3 +1,4 @@ +@SQLITE @APIDB Feature: Geocodejson for Reverse API Testing correctness of geocodejson output (API version v1). diff --git a/test/bdd/api/reverse/v1_geojson.feature b/test/bdd/api/reverse/v1_geojson.feature index 0b6ad0d3..e705529d 100644 --- a/test/bdd/api/reverse/v1_geojson.feature +++ b/test/bdd/api/reverse/v1_geojson.feature @@ -1,3 +1,4 @@ +@SQLITE @APIDB Feature: Geojson for Reverse API Testing correctness of geojson output (API version v1). diff --git a/test/bdd/api/reverse/v1_json.feature b/test/bdd/api/reverse/v1_json.feature index ac3c799e..1f629c0f 100644 --- a/test/bdd/api/reverse/v1_json.feature +++ b/test/bdd/api/reverse/v1_json.feature @@ -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 | diff --git a/test/bdd/api/reverse/v1_params.feature b/test/bdd/api/reverse/v1_params.feature index 70a6505b..a1f08afd 100644 --- a/test/bdd/api/reverse/v1_params.feature +++ b/test/bdd/api/reverse/v1_params.feature @@ -1,3 +1,4 @@ +@SQLITE @APIDB Feature: v1/reverse Parameter Tests Tests for parameter inputs for the v1 reverse endpoint. diff --git a/test/bdd/api/reverse/v1_xml.feature b/test/bdd/api/reverse/v1_xml.feature index 75f27220..95e7478c 100644 --- a/test/bdd/api/reverse/v1_xml.feature +++ b/test/bdd/api/reverse/v1_xml.feature @@ -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 diff --git a/test/bdd/api/status/simple.feature b/test/bdd/api/status/simple.feature index 1323caa1..993fa1ec 100644 --- a/test/bdd/api/status/simple.feature +++ b/test/bdd/api/status/simple.feature @@ -1,3 +1,4 @@ +@SQLITE @APIDB Feature: Status queries Testing status query diff --git a/test/bdd/environment.py b/test/bdd/environment.py index afaa5151..664b5ac7 100644 --- a/test/bdd/environment.py +++ b/test/bdd/environment.py @@ -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() diff --git a/test/bdd/steps/nominatim_environment.py b/test/bdd/steps/nominatim_environment.py index 7299988b..11dede30 100644 --- a/test/bdd/steps/nominatim_environment.py +++ b/test/bdd/steps/nominatim_environment.py @@ -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