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'
else:
assert_in(attr, addr_parts)
-@then(u'address of result (?P<lid>\d+) is')
-def check_address(context, lid):
+@then(u'address of result (?P<lid>\d+) (?P<complete>is|contains)')
+def check_address(context, lid, complete):
context.execute_steps("then more than %s results are returned" % lid)
addr_parts = dict(context.response.result[int(lid)]['address'])
"Bad address value for %s" % line['type'])
del addr_parts[line['type']]
- eq_(0, len(addr_parts), "Additional address parts found: %s" % str(addr_parts))
+ if complete == 'is':
+ eq_(0, len(addr_parts), "Additional address parts found: %s" % str(addr_parts))
@then(u'result (?P<lid>\d+ )?has bounding box in (?P<coords>[\d,.-]+)')
def step_impl(context, lid, coords):