fix various failing BDD tests

This commit is contained in:
Sarah Hoffmann
2023-05-26 15:08:48 +02:00
parent 146a0b29c0
commit 8f299838f7
8 changed files with 18 additions and 17 deletions

View File

@@ -296,13 +296,13 @@ def format_excluded(ids: Any) -> List[int]:
"""
plist: Sequence[str]
if isinstance(ids, str):
plist = ids.split(',')
plist = [s.strip() for s in ids.split(',')]
elif isinstance(ids, abc.Sequence):
plist = ids
else:
raise UsageError("Parameter 'excluded' needs to be a comma-separated list "
"or a Python list of numbers.")
if any(not isinstance(i, int) or (isinstance(i, str) and not i.isdigit()) for i in plist):
if not all(isinstance(i, int) or (isinstance(i, str) and i.isdigit()) for i in plist):
raise UsageError("Parameter 'excluded' only takes place IDs.")
return [int(id) for id in plist if id]

View File

@@ -53,7 +53,7 @@ def feature_type_to_rank(feature_type: Optional[str]) -> Tuple[int, int]:
#pylint: disable=too-many-arguments
def extend_query_parts(queryparts: dict[str, Any], details: dict[str, Any],
def extend_query_parts(queryparts: Dict[str, Any], details: Dict[str, Any],
feature_type: Optional[str],
namedetails: bool, extratags: bool,
excluded: Iterable[str]) -> None:

View File

@@ -370,6 +370,9 @@ async def lookup_endpoint(api: napi.NominatimAPIAsync, params: ASGIAdaptor) -> A
if len(oid) > 1 and oid[0] in 'RNWrnw' and oid[1:].isdigit():
places.append(napi.OsmID(oid[0], int(oid[1:])))
if len(places) > params.config().get_int('LOOKUP_MAX_COUNT'):
params.raise_error('Too many object IDs.')
if places:
results = await api.lookup(places, **details)
else:
@@ -439,6 +442,8 @@ async def search_endpoint(api: napi.NominatimAPIAsync, params: ASGIAdaptor) -> A
details['min_rank'], details['max_rank'] = \
helpers.feature_type_to_rank(params.get('featureType', ''))
if params.get('featureType', None) is not None:
details['layers'] = napi.DataLayer.ADDRESS
query = params.get('q', None)
queryparts = {}