From 7ba5152493327d277115aab9b344b652decd3f2e Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Sun, 15 Sep 2024 13:51:51 +0200 Subject: [PATCH] remove PHP frontend support from BDD tests --- test/bdd/api/details/simple.feature | 33 ------------ test/bdd/api/reverse/layers.feature | 6 --- test/bdd/api/reverse/v1_params.feature | 15 ------ test/bdd/api/search/params.feature | 13 ----- test/bdd/api/search/postcode.feature | 2 +- test/bdd/api/search/queries.feature | 18 ------- test/bdd/db/query/postcodes.feature | 1 - test/bdd/db/query/reverse.feature | 1 - test/bdd/environment.py | 6 --- test/bdd/steps/nominatim_environment.py | 8 ++- test/bdd/steps/steps_api_queries.py | 68 +------------------------ 11 files changed, 6 insertions(+), 165 deletions(-) diff --git a/test/bdd/api/details/simple.feature b/test/bdd/api/details/simple.feature index 0e456aa5..5e0bacc5 100644 --- a/test/bdd/api/details/simple.feature +++ b/test/bdd/api/details/simple.feature @@ -42,16 +42,6 @@ Feature: Object details | N300209696:highway | - @v1-api-php-only - Scenario: Details for interpolation way just return the dependent street - When sending details query for W1 - Then the result is valid json - And results contain - | category | - | highway | - - - @v1-api-python-only Scenario: Details for interpolation way return the interpolation When sending details query for W1 Then the result is valid json @@ -60,17 +50,6 @@ Feature: Object details | place | houses | W | 1 | 15 | - @v1-api-php-only - @Fail - Scenario: Details for Tiger way just return the dependent street - When sending details query for 112871 - Then the result is valid json - And results contain - | category | - | highway | - - - @v1-api-python-only @Fail Scenario: Details for interpolation way return the interpolation When sending details query for 112871 @@ -81,17 +60,6 @@ Feature: Object details And result has not attributes osm_type,osm_id - @v1-api-php-only - @Fail - Scenario: Details for postcodes just return the dependent place - When sending details query for 112820 - Then the result is valid json - And results contain - | category | - | boundary | - - - @v1-api-python-only @Fail Scenario: Details for interpolation way return the interpolation When sending details query for 112820 @@ -102,7 +70,6 @@ Feature: Object details And result has not attributes osm_type,osm_id - @v1-api-python-only Scenario Outline: Details debug output returns no errors When sending debug details query for Then the result is valid html diff --git a/test/bdd/api/reverse/layers.feature b/test/bdd/api/reverse/layers.feature index ef028864..f1885f0e 100644 --- a/test/bdd/api/reverse/layers.feature +++ b/test/bdd/api/reverse/layers.feature @@ -3,7 +3,6 @@ Feature: Layer parameter in reverse geocoding Testing correct function of layer selection while reverse geocoding - @v1-api-python-only Scenario: POIs are selected by default When sending v1/reverse at 47.14077,9.52414 Then results contain @@ -11,7 +10,6 @@ Feature: Layer parameter in reverse geocoding | tourism | viewpoint | - @v1-api-python-only Scenario Outline: Same address level POI with different layers When sending v1/reverse at 47.14077,9.52414 | layer | @@ -31,7 +29,6 @@ Feature: Layer parameter in reverse geocoding | natural,poi | tourism | - @v1-api-python-only Scenario Outline: POIs are not selected without housenumber for address layer When sending v1/reverse at 47.13816,9.52168 | layer | @@ -46,7 +43,6 @@ Feature: Layer parameter in reverse geocoding | address | amenity | parking | - @v1-api-python-only Scenario: Between natural and low-zoom address prefer natural When sending v1/reverse at 47.13636,9.52094 | layer | zoom | @@ -56,7 +52,6 @@ Feature: Layer parameter in reverse geocoding | waterway | - @v1-api-python-only Scenario Outline: Search for mountain peaks begins at level 12 When sending v1/reverse at 47.08293,9.57109 | layer | zoom | @@ -71,7 +66,6 @@ Feature: Layer parameter in reverse geocoding | 13 | waterway | river | - @v1-api-python-only Scenario Outline: Reverse search with manmade layers When sending v1/reverse at 32.46904,-86.44439 | layer | diff --git a/test/bdd/api/reverse/v1_params.feature b/test/bdd/api/reverse/v1_params.feature index a1f08afd..09a190ed 100644 --- a/test/bdd/api/reverse/v1_params.feature +++ b/test/bdd/api/reverse/v1_params.feature @@ -18,20 +18,6 @@ Feature: v1/reverse Parameter Tests When sending v1/reverse at ,52.52 Then a HTTP 400 is returned - @v1-api-php-only - Scenario: Missing osm_id parameter - When sending v1/reverse at , - | osm_type | - | N | - Then a HTTP 400 is returned - - @v1-api-php-only - Scenario: Missing osm_type parameter - When sending v1/reverse at , - | osm_id | - | 3498564 | - Then a HTTP 400 is returned - Scenario Outline: Bad format for lat or lon When sending v1/reverse at , @@ -151,7 +137,6 @@ Feature: v1/reverse Parameter Tests | foo; evil | - @v1-api-python-only Scenario Outline: Reverse debug mode produces valid HTML When sending v1/reverse at , with format debug | lat | lon | diff --git a/test/bdd/api/search/params.feature b/test/bdd/api/search/params.feature index e667b690..77e2ea20 100644 --- a/test/bdd/api/search/params.feature +++ b/test/bdd/api/search/params.feature @@ -353,19 +353,6 @@ Feature: Search queries | svg | | geokml | - @v1-api-php-only - Scenario: Search along a route - When sending json search query "rathaus" with address - Then result addresses contain - | ID | town | - | 0 | Schaan | - When sending json search query "rathaus" with address - | bounded | routewidth | route | - | 1 | 0.1 | 9.54353,47.11772,9.54314,47.11894 | - Then result addresses contain - | town | - | Triesenberg | - Scenario: Array parameters are ignored When sending json search query "Vaduz" with address diff --git a/test/bdd/api/search/postcode.feature b/test/bdd/api/search/postcode.feature index 827af1ea..bb1b755b 100644 --- a/test/bdd/api/search/postcode.feature +++ b/test/bdd/api/search/postcode.feature @@ -3,7 +3,7 @@ Feature: Searches with postcodes Various searches involving postcodes - @v1-api-php-only + @Fail Scenario: US 5+4 ZIP codes are shortened to 5 ZIP codes if not found When sending json search query "36067 1111, us" with address Then result addresses contain diff --git a/test/bdd/api/search/queries.feature b/test/bdd/api/search/queries.feature index b2793faa..6e640acc 100644 --- a/test/bdd/api/search/queries.feature +++ b/test/bdd/api/search/queries.feature @@ -106,17 +106,6 @@ Feature: Search queries | class | type | | club | scout | - @v1-api-php-only - Scenario: With multiple amenity search only the first is used - When sending json search query "[club=scout] [church] vaduz" - Then results contain - | class | type | - | club | scout | - When sending json search query "[amenity=place_of_worship] [club=scout] vaduz" - Then results contain - | class | type | - | amenity | place_of_worship | - Scenario: POI search near given coordinate When sending json search query "restaurant near 47.16712,9.51100" Then results contain @@ -129,13 +118,6 @@ Feature: Search queries | class | type | | leisure | firepit | - @v1-api-php-only - Scenario: Arbitrary key/value search near given coordinate and named place - When sending json search query "[leisure=firepit] ebenholz 47° 9′ 26″ N 9° 36′ 45″ E" - Then results contain - | class | type | - | leisure | firepit | - Scenario: POI search in a bounded viewbox When sending json search query "restaurants" diff --git a/test/bdd/db/query/postcodes.feature b/test/bdd/db/query/postcodes.feature index fa4f6a0b..1ee73e98 100644 --- a/test/bdd/db/query/postcodes.feature +++ b/test/bdd/db/query/postcodes.feature @@ -98,7 +98,6 @@ Feature: Querying fo postcode variants @fail-legacy - @v1-api-python-only Scenario: Postcode areas are preferred over postcode points Given the grid with origin DE | 1 | 2 | diff --git a/test/bdd/db/query/reverse.feature b/test/bdd/db/query/reverse.feature index 12941102..11ee8685 100644 --- a/test/bdd/db/query/reverse.feature +++ b/test/bdd/db/query/reverse.feature @@ -2,7 +2,6 @@ Feature: Reverse searches Test results of reverse queries - @v1-api-python-only Scenario: POI in POI area Given the 0.0001 grid with origin 1,1 | 1 | | | | | | | | 2 | diff --git a/test/bdd/environment.py b/test/bdd/environment.py index 155b8d90..e2e64403 100644 --- a/test/bdd/environment.py +++ b/test/bdd/environment.py @@ -66,9 +66,3 @@ def before_tag(context, tag): if tag == 'fail-legacy': if context.config.userdata['TOKENIZER'] == 'legacy': context.scenario.skip("Not implemented in legacy tokenizer") - if tag == 'v1-api-php-only': - if context.config.userdata['API_ENGINE'] != 'php': - context.scenario.skip("Only valid with PHP version of v1 API.") - if tag == 'v1-api-python-only': - if context.config.userdata['API_ENGINE'] == 'php': - context.scenario.skip("Only valid with Python version of v1 API.") diff --git a/test/bdd/steps/nominatim_environment.py b/test/bdd/steps/nominatim_environment.py index dd6ecda6..9836865c 100644 --- a/test/bdd/steps/nominatim_environment.py +++ b/test/bdd/steps/nominatim_environment.py @@ -44,11 +44,9 @@ class NominatimEnvironment: self.api_db_done = False self.website_dir = None - self.api_engine = None - if config['API_ENGINE'] != 'php': - if not hasattr(self, f"create_api_request_func_{config['API_ENGINE']}"): - raise RuntimeError(f"Unknown API engine '{config['API_ENGINE']}'") - self.api_engine = getattr(self, f"create_api_request_func_{config['API_ENGINE']}")() + if not hasattr(self, f"create_api_request_func_{config['API_ENGINE']}"): + raise RuntimeError(f"Unknown API engine '{config['API_ENGINE']}'") + self.api_engine = getattr(self, f"create_api_request_func_{config['API_ENGINE']}")() if self.tokenizer == 'legacy' and self.server_module_path is None: raise RuntimeError("You must set -DSERVER_MODULE_PATH when testing the legacy tokenizer.") diff --git a/test/bdd/steps/steps_api_queries.py b/test/bdd/steps/steps_api_queries.py index 93501e42..4d15381d 100644 --- a/test/bdd/steps/steps_api_queries.py +++ b/test/bdd/steps/steps_api_queries.py @@ -1,13 +1,10 @@ -# SPDX-License-Identifier: GPL-2.0-only +# SPDX-License-Identifier: GPL-3.0-or-later # # This file is part of Nominatim. (https://nominatim.org) # -# Copyright (C) 2022 by the Nominatim developer community. +# Copyright (C) 2024 by the Nominatim developer community. # For a full list of authors see the git log. """ Steps that run queries against the API. - - Queries may either be run directly via PHP using the query script - or via the HTTP interface using php-cgi. """ from pathlib import Path import json @@ -25,29 +22,6 @@ from table_compare import NominatimID LOG = logging.getLogger(__name__) -BASE_SERVER_ENV = { - 'HTTP_HOST' : 'localhost', - 'HTTP_USER_AGENT' : 'Mozilla/5.0 (X11; Linux x86_64; rv:51.0) Gecko/20100101 Firefox/51.0', - 'HTTP_ACCEPT' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', - 'HTTP_ACCEPT_ENCODING' : 'gzip, deflate', - 'HTTP_CONNECTION' : 'keep-alive', - 'SERVER_SIGNATURE' : '
Nominatim BDD Tests
', - 'SERVER_SOFTWARE' : 'Nominatim test', - 'SERVER_NAME' : 'localhost', - 'SERVER_ADDR' : '127.0.1.1', - 'SERVER_PORT' : '80', - 'REMOTE_ADDR' : '127.0.0.1', - 'DOCUMENT_ROOT' : '/var/www', - 'REQUEST_SCHEME' : 'http', - 'CONTEXT_PREFIX' : '/', - 'SERVER_ADMIN' : 'webmaster@localhost', - 'REMOTE_PORT' : '49319', - 'GATEWAY_INTERFACE' : 'CGI/1.1', - 'SERVER_PROTOCOL' : 'HTTP/1.1', - 'REQUEST_METHOD' : 'GET', - 'REDIRECT_STATUS' : 'CGI' -} - def make_todo_list(context, result_id): if result_id is None: @@ -88,50 +62,12 @@ def send_api_query(endpoint, params, fmt, context): for h in context.table.headings: params[h] = context.table[0][h] - if context.nominatim.api_engine is None: - return send_api_query_php(endpoint, params, context) - return asyncio.run(context.nominatim.api_engine(endpoint, params, Path(context.nominatim.website_dir.name), context.nominatim.test_env, getattr(context, 'http_headers', {}))) - -def send_api_query_php(endpoint, params, context): - env = dict(BASE_SERVER_ENV) - env['QUERY_STRING'] = urlencode(params) - - env['SCRIPT_NAME'] = f'/{endpoint}.php' - env['REQUEST_URI'] = f"{env['SCRIPT_NAME']}?{env['QUERY_STRING']}" - env['CONTEXT_DOCUMENT_ROOT'] = os.path.join(context.nominatim.website_dir.name, 'website') - env['SCRIPT_FILENAME'] = os.path.join(env['CONTEXT_DOCUMENT_ROOT'], - f'{endpoint}.php') - - LOG.debug("Environment:" + json.dumps(env, sort_keys=True, indent=2)) - - if hasattr(context, 'http_headers'): - for k, v in context.http_headers.items(): - env['HTTP_' + k.upper().replace('-', '_')] = v - - cmd = ['/usr/bin/env', 'php-cgi', '-f', env['SCRIPT_FILENAME']] - - for k,v in params.items(): - cmd.append(f"{k}={v}") - - outp, err = run_script(cmd, cwd=context.nominatim.website_dir.name, env=env) - - assert len(err) == 0, f"Unexpected PHP error: {err}" - - if outp.startswith('Status: '): - status = int(outp[8:11]) - else: - status = 200 - - content_start = outp.find('\r\n\r\n') - - return outp[content_start + 4:], status - @given(u'the HTTP header') def add_http_header(context): if not hasattr(context, 'http_headers'): -- 2.39.5