pass
elif h == 'osm':
assert_equal(res['osm_type'], row[h][0])
- assert_equal(res['osm_id'], row[h][1:])
+ assert_equal(res['osm_id'], int(row[h][1:]))
elif h == 'centroid':
x, y = row[h].split(' ')
assert_almost_equal(float(y), float(res['lat']))
self.result = geojson_results_to_json_results(self.result)
def parse_geocodejson(self):
- return self.parse_geojson()
+ self.parse_geojson()
+ if self.result is not None:
+ self.result = [r['geocoding'] for r in self.result]
def parse_html(self):
content, errors = tidy_document(self.page,
self.result = geojson_results_to_json_results(self.result[0])
def parse_geocodejson(self):
- return self.parse_geojson()
+ self.parse_geojson()
+ if self.result is not None:
+ self.result = [r['geocoding'] for r in self.result]
def parse_xml(self):
et = ET.fromstring(self.page)
"""
cmd = ['/usr/bin/env', 'php']
cmd.append(os.path.join(context.nominatim.build_dir, 'utils', 'query.php'))
- cmd.extend(['--search', query])
+ if query:
+ cmd.extend(['--search', query])
# add more parameters in table form
if context.table:
for h in context.table.headings:
if fmt == 'json ':
outfmt = 'json'
+ elif fmt == 'jsonv2 ':
+ outfmt = 'json'
elif fmt == 'geojson ':
outfmt = 'geojson'
+ elif fmt == 'geocodejson ':
+ outfmt = 'geocodejson'
else:
outfmt = 'xml'
context.execute_steps("Then a HTTP 200 is returned")
eq_(context.response.format, fmt)
+@then(u'a (?P<fmt>\w+) user error is returned')
+def check_page_error(context, fmt):
+ context.execute_steps("Then a HTTP 400 is returned")
+ eq_(context.response.format, fmt)
+
+ if fmt == 'html':
+ assert_is_not_none(re.search(r'<html( |>).+</html>', context.response.page, re.DOTALL))
+ elif fmt == 'xml':
+ assert_is_not_none(re.search(r'<error>.+</error>', context.response.page, re.DOTALL))
+ else:
+ assert_is_not_none(re.search(r'({"error":)', context.response.page, re.DOTALL))
+
@then(u'result header contains')
def check_header_attr(context):
for line in context.table: