enable BDD tests for sqlite databases

The database must currently be created by hand and the name handed
in via -DAPI_TEST_DB='sqlite:...'.
This commit is contained in:
Sarah Hoffmann
2023-10-13 21:32:03 +02:00
parent 8216899a9a
commit d8dca2a3a9
18 changed files with 41 additions and 11 deletions

View File

@@ -436,7 +436,7 @@ class ReverseGeocoder:
.where(t.c.indexed_status == 0)\ .where(t.c.indexed_status == 0)\
.where(t.c.linked_place_id == None)\ .where(t.c.linked_place_id == None)\
.where(self._filter_by_layer(t))\ .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(sa.desc(t.c.rank_search))\
.order_by('distance')\ .order_by('distance')\
.limit(50)\ .limit(50)\

View File

@@ -1,3 +1,4 @@
@SQLITE
@APIDB @APIDB
Feature: Localization of search results Feature: Localization of search results

View File

@@ -2,6 +2,7 @@
Feature: Object details Feature: Object details
Testing different parameter options for details API. Testing different parameter options for details API.
@SQLITE
Scenario: JSON Details Scenario: JSON Details
When sending json details query for W297699560 When sending json details query for W297699560
Then the result is valid json Then the result is valid json
@@ -11,6 +12,7 @@ Feature: Object details
| type | | type |
| Point | | Point |
@SQLITE
Scenario: JSON Details with pretty printing Scenario: JSON Details with pretty printing
When sending json details query for W297699560 When sending json details query for W297699560
| pretty | | pretty |
@@ -19,6 +21,7 @@ Feature: Object details
And result has attributes geometry And result has attributes geometry
And result has not attributes keywords,address,linked_places,parentof And result has not attributes keywords,address,linked_places,parentof
@SQLITE
Scenario: JSON Details with addressdetails Scenario: JSON Details with addressdetails
When sending json details query for W297699560 When sending json details query for W297699560
| addressdetails | | addressdetails |
@@ -26,6 +29,7 @@ Feature: Object details
Then the result is valid json Then the result is valid json
And result has attributes address And result has attributes address
@SQLITE
Scenario: JSON Details with linkedplaces Scenario: JSON Details with linkedplaces
When sending json details query for R123924 When sending json details query for R123924
| linkedplaces | | linkedplaces |
@@ -33,6 +37,7 @@ Feature: Object details
Then the result is valid json Then the result is valid json
And result has attributes linked_places And result has attributes linked_places
@SQLITE
Scenario: JSON Details with hierarchy Scenario: JSON Details with hierarchy
When sending json details query for W297699560 When sending json details query for W297699560
| hierarchy | | hierarchy |
@@ -40,6 +45,7 @@ Feature: Object details
Then the result is valid json Then the result is valid json
And result has attributes hierarchy And result has attributes hierarchy
@SQLITE
Scenario: JSON Details with grouped hierarchy Scenario: JSON Details with grouped hierarchy
When sending json details query for W297699560 When sending json details query for W297699560
| hierarchy | group_hierarchy | | hierarchy | group_hierarchy |
@@ -69,6 +75,7 @@ Feature: Object details
Then the result is valid json Then the result is valid json
And result has attributes keywords And result has attributes keywords
@SQLITE
Scenario Outline: JSON details with full geometry Scenario Outline: JSON details with full geometry
When sending json details query for <osmid> When sending json details query for <osmid>
| polygon_geojson | | polygon_geojson |

View File

@@ -1,3 +1,4 @@
@SQLITE
@APIDB @APIDB
Feature: Object details Feature: Object details
Check details page for correctness Check details page for correctness

View File

@@ -1,3 +1,4 @@
@SQLITE
@APIDB @APIDB
Feature: Places by osm_type and osm_id Tests Feature: Places by osm_type and osm_id Tests
Simple tests for errors in various response formats. Simple tests for errors in various response formats.

View File

@@ -1,3 +1,4 @@
@SQLITE
@APIDB @APIDB
Feature: Places by osm_type and osm_id Tests Feature: Places by osm_type and osm_id Tests
Simple tests for response format. Simple tests for response format.

View File

@@ -1,3 +1,4 @@
@SQLITE
@APIDB @APIDB
Feature: Geometries for reverse geocoding Feature: Geometries for reverse geocoding
Tests for returning geometries with reverse Tests for returning geometries with reverse
@@ -9,7 +10,7 @@ Feature: Geometries for reverse geocoding
| 1 | | 1 |
Then results contain Then results contain
| geotext | | 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 Scenario: Polygons can be slightly simplified
@@ -18,7 +19,7 @@ Feature: Geometries for reverse geocoding
| 1 | 0.00001 | | 1 | 0.00001 |
Then results contain Then results contain
| geotext | | 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 Scenario: Polygons can be much simplified
@@ -27,7 +28,7 @@ Feature: Geometries for reverse geocoding
| 1 | 0.9 | | 1 | 0.9 |
Then results contain Then results contain
| geotext | | 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 Scenario: For polygons return the centroid as center point

View File

@@ -1,3 +1,4 @@
@SQLITE
@APIDB @APIDB
Feature: Localization of reverse search results Feature: Localization of reverse search results

View File

@@ -1,3 +1,4 @@
@SQLITE
@APIDB @APIDB
Feature: Layer parameter in reverse geocoding Feature: Layer parameter in reverse geocoding
Testing correct function of layer selection while 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 @v1-api-python-only
Scenario Outline: Search for mountain peaks begins at level 12 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 | | layer | zoom |
| natural | <zoom> | | natural | <zoom> |
Then results contain Then results contain
@@ -71,7 +72,7 @@ Feature: Layer parameter in reverse geocoding
@v1-api-python-only @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 When sending v1/reverse at 32.46904,-86.44439
| layer | | layer |
| <layer> | | <layer> |
@@ -84,5 +85,5 @@ Feature: Layer parameter in reverse geocoding
| manmade | leisure | park | | manmade | leisure | park |
| address | highway | residential | | address | highway | residential |
| poi | leisure | pitch | | poi | leisure | pitch |
| natural | waterway | stream | | natural | waterway | river |
| natural,manmade | leisure | park | | natural,manmade | leisure | park |

View File

@@ -1,3 +1,4 @@
@SQLITE
@APIDB @APIDB
Feature: Reverse geocoding Feature: Reverse geocoding
Testing the reverse function Testing the reverse function

View File

@@ -1,3 +1,4 @@
@SQLITE
@APIDB @APIDB
Feature: Geocodejson for Reverse API Feature: Geocodejson for Reverse API
Testing correctness of geocodejson output (API version v1). Testing correctness of geocodejson output (API version v1).

View File

@@ -1,3 +1,4 @@
@SQLITE
@APIDB @APIDB
Feature: Geojson for Reverse API Feature: Geojson for Reverse API
Testing correctness of geojson output (API version v1). Testing correctness of geojson output (API version v1).

View File

@@ -1,3 +1,4 @@
@SQLITE
@APIDB @APIDB
Feature: Json output for Reverse API Feature: Json output for Reverse API
Testing correctness of json and jsonv2 output (API version v1). Testing correctness of json and jsonv2 output (API version v1).
@@ -93,7 +94,7 @@ Feature: Json output for Reverse API
| polygon_text | 1 | | polygon_text | 1 |
Then results contain Then results contain
| geotext | | 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: Examples:
| format | | format |

View File

@@ -1,3 +1,4 @@
@SQLITE
@APIDB @APIDB
Feature: v1/reverse Parameter Tests Feature: v1/reverse Parameter Tests
Tests for parameter inputs for the v1 reverse endpoint. Tests for parameter inputs for the v1 reverse endpoint.

View File

@@ -1,3 +1,4 @@
@SQLITE
@APIDB @APIDB
Feature: XML output for Reverse API Feature: XML output for Reverse API
Testing correctness of xml output (API version v1). Testing correctness of xml output (API version v1).
@@ -66,7 +67,7 @@ Feature: XML output for Reverse API
| polygon_text | 1 | | polygon_text | 1 |
Then results contain Then results contain
| geotext | | 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 Scenario: Output of SVG

View File

@@ -1,3 +1,4 @@
@SQLITE
@APIDB @APIDB
Feature: Status queries Feature: Status queries
Testing status query Testing status query

View File

@@ -46,7 +46,10 @@ def before_all(context):
def before_scenario(context, scenario): 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) context.nominatim.setup_db(context)
elif 'APIDB' in context.tags: elif 'APIDB' in context.tags:
context.nominatim.setup_api_db() context.nominatim.setup_api_db()

View File

@@ -86,7 +86,10 @@ class NominatimEnvironment:
be picked up by dotenv and creates a project directory with the be picked up by dotenv and creates a project directory with the
appropriate website scripts. 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: if self.db_host:
dsn += ';host=' + self.db_host dsn += ';host=' + self.db_host
if self.db_port: if self.db_port:
@@ -197,6 +200,9 @@ class NominatimEnvironment:
""" """
self.write_nominatim_config(self.api_test_db) self.write_nominatim_config(self.api_test_db)
if self.api_test_db.startswith('sqlite:'):
return
if not self.api_db_done: if not self.api_db_done:
self.api_db_done = True self.api_db_done = True