X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/433d2f4c7d01ca4903af009827452bf05d4de6ff..e4796bb876bf75dd674ee3f25a89bebb7e037443:/test/bdd/steps/http_responses.py diff --git a/test/bdd/steps/http_responses.py b/test/bdd/steps/http_responses.py index fa841d25..3b9f59eb 100644 --- a/test/bdd/steps/http_responses.py +++ b/test/bdd/steps/http_responses.py @@ -62,8 +62,6 @@ class GenericResponse: if errorcode == 200 and fmt != 'debug': getattr(self, '_parse_' + fmt)() - else: - print("Bad response: ", page) def _parse_json(self): m = re.fullmatch(r'([\w$][^(]*)\((.*)\)', self.page) @@ -74,13 +72,14 @@ class GenericResponse: self.header['json_func'] = m.group(1) self.result = json.JSONDecoder(object_pairs_hook=OrderedDict).decode(code) if isinstance(self.result, OrderedDict): - self.result = [self.result] + if 'error' in self.result: + self.result = [] + else: + self.result = [self.result] def _parse_geojson(self): self._parse_json() - if 'error' in self.result[0]: - self.result = [] - else: + if self.result: self.result = list(map(_geojson_result_to_json_result, self.result[0]['features'])) def _parse_geocodejson(self): @@ -103,6 +102,9 @@ class GenericResponse: elif value.startswith("^"): assert re.fullmatch(value, self.result[idx][field]), \ BadRowValueAssert(self, idx, field, value) + elif isinstance(self.result[idx][field], OrderedDict): + assert self.result[idx][field] == eval('{' + value + '}'), \ + BadRowValueAssert(self, idx, field, value) else: assert str(self.result[idx][field]) == str(value), \ BadRowValueAssert(self, idx, field, value)