+ assert_in(attr, addr_parts)
+
+@then(u'address of result (?P<lid>\d+) is')
+def check_address(context, lid):
+ context.execute_steps("then more than %s results are returned" % lid)
+
+ addr_parts = dict(context.response.result[int(lid)]['address'])
+
+ for line in context.table:
+ assert_in(line['type'], addr_parts)
+ assert_equal(addr_parts[line['type']], line['value'],
+ "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))
+
+@then(u'result (?P<lid>\d+ )?has bounding box in (?P<coords>[\d,.-]+)')
+def step_impl(context, lid, coords):
+ if lid is None:
+ context.execute_steps("then at least 1 result is returned")
+ bboxes = context.response.property_list('boundingbox')
+ else:
+ context.execute_steps("then more than %sresults are returned" % lid)
+ bboxes = [ context.response.result[int(lid)]['boundingbox']]
+
+ coord = [ float(x) for x in coords.split(',') ]
+
+ for bbox in bboxes:
+ if isinstance(bbox, str):
+ bbox = bbox.split(',')
+ bbox = [ float(x) for x in bbox ]
+
+ assert_greater_equal(bbox[0], coord[0])
+ assert_less_equal(bbox[1], coord[1])
+ assert_greater_equal(bbox[2], coord[2])
+ assert_less_equal(bbox[3], coord[3])
+
+@then(u'result (?P<lid>\d+ )?has centroid in (?P<coords>[\d,.-]+)')
+def step_impl(context, lid, coords):
+ if lid is None:
+ context.execute_steps("then at least 1 result is returned")
+ bboxes = zip(context.response.property_list('lat'),
+ context.response.property_list('lon'))
+ else:
+ context.execute_steps("then more than %sresults are returned" % lid)
+ res = context.response.result[int(lid)]
+ bboxes = [ (res['lat'], res['lon']) ]
+
+ coord = [ float(x) for x in coords.split(',') ]
+
+ for lat, lon in bboxes:
+ lat = float(lat)
+ lon = float(lon)
+ assert_greater_equal(lat, coord[0])
+ assert_less_equal(lat, coord[1])
+ assert_greater_equal(lon, coord[2])
+ assert_less_equal(lon, coord[3])
+
+@then(u'there are(?P<neg> no)? duplicates')
+def check_for_duplicates(context, neg):
+ context.execute_steps("then at least 1 result is returned")