switch BDD tests to always use search API

This commit is contained in:
Sarah Hoffmann
2021-06-06 15:27:52 +02:00
parent f0a7850edf
commit 3aac51c81f
13 changed files with 260 additions and 266 deletions

View File

@@ -8,7 +8,9 @@ import xml.etree.ElementTree as ET
from check_functions import Almost
OSM_TYPE = {'N' : 'node', 'W' : 'way', 'R' : 'relation'}
OSM_TYPE = {'N' : 'node', 'W' : 'way', 'R' : 'relation',
'n' : 'node', 'w' : 'way', 'r' : 'relation',
'node' : 'n', 'way' : 'w', 'relation' : 'r'}
def _geojson_result_to_json_result(geojson_result):
result = geojson_result['properties']
@@ -139,6 +141,9 @@ class GenericResponse:
assert self.result[i]['osm_type'] in (OSM_TYPE[value[0]], value[0]), \
BadRowValueAssert(self, i, 'osm_type', value)
self.assert_field(i, 'osm_id', value[1:])
elif name == 'osm_type':
assert self.result[i]['osm_type'] in (OSM_TYPE[value[0]], value[0]), \
BadRowValueAssert(self, i, 'osm_type', value)
elif name == 'centroid':
lon, lat = value.split(' ')
self.assert_field(i, 'lat', float(lat))

View File

@@ -55,29 +55,6 @@ def compare(operator, op1, op2):
raise Exception("unknown operator '%s'" % operator)
@when(u'searching for "(?P<query>.*)"(?P<dups> with dups)?')
def query_cmd(context, query, dups):
""" Query directly via PHP script.
"""
cmd = ['/usr/bin/env', 'php']
cmd.append(context.nominatim.src_dir / 'lib-php' / 'admin' / 'query.php')
if query:
cmd.extend(['--search', query])
# add more parameters in table form
if context.table:
for h in context.table.headings:
value = context.table[0][h].strip()
if value:
cmd.extend(('--' + h, value))
if dups:
cmd.extend(('--dedupe', '0'))
outp, err = run_script(cmd, cwd=context.nominatim.website_dir.name,
env=context.nominatim.test_env)
context.response = SearchResponse(outp, 'json')
def send_api_query(endpoint, params, fmt, context):
if fmt is not None and fmt.strip() != 'debug':
params['format'] = fmt.strip()