+@then("place_addressline contains")
+def check_place_addressline(context):
+ cur = context.db.cursor(cursor_factory=psycopg2.extras.DictCursor)
+
+ for row in context.table:
+ pid = NominatimID(row['object']).get_place_id(cur)
+ apid = NominatimID(row['address']).get_place_id(cur)
+ cur.execute(""" SELECT * FROM place_addressline
+ WHERE place_id = %s AND address_place_id = %s""",
+ (pid, apid))
+ assert_less(0, cur.rowcount,
+ "No rows found for place %s and address %s"
+ % (row['object'], row['address']))
+
+ for res in cur:
+ for h in row.headings:
+ if h not in ('address', 'object'):
+ assert_db_column(res, h, row[h], context)
+
+ context.db.commit()
+
+@then("place_addressline doesn't contain")
+def check_place_addressline_exclude(context):
+ cur = context.db.cursor(cursor_factory=psycopg2.extras.DictCursor)
+
+ for row in context.table:
+ pid = NominatimID(row['object']).get_place_id(cur)
+ apid = NominatimID(row['address']).get_place_id(cur)
+ cur.execute(""" SELECT * FROM place_addressline
+ WHERE place_id = %s AND address_place_id = %s""",
+ (pid, apid))
+ eq_(0, cur.rowcount,
+ "Row found for place %s and address %s" % (row['object'], row['address']))
+
+ context.db.commit()
+
+@then("(?P<oid>\w+) expands to(?P<neg> no)? interpolation")
+def check_location_property_osmline(context, oid, neg):
+ cur = context.db.cursor(cursor_factory=psycopg2.extras.DictCursor)
+ nid = NominatimID(oid)
+
+ eq_('W', nid.typ, "interpolation must be a way")
+
+ cur.execute("""SELECT *, ST_AsText(linegeo) as geomtxt
+ FROM location_property_osmline
+ WHERE osm_id = %s AND startnumber IS NOT NULL""",
+ (nid.oid, ))
+
+ if neg:
+ eq_(0, cur.rowcount)
+ return
+
+ todo = list(range(len(list(context.table))))
+ for res in cur:
+ for i in todo:
+ row = context.table[i]
+ if (int(row['start']) == res['startnumber']
+ and int(row['end']) == res['endnumber']):
+ todo.remove(i)
+ break
+ else:
+ assert False, "Unexpected row %s" % (str(res))
+
+ for h in row.headings:
+ if h in ('start', 'end'):
+ continue
+ elif h == 'parent_place_id':
+ compare_place_id(row[h], res[h], h, context)
+ else:
+ assert_db_column(res, h, row[h], context)
+
+ eq_(todo, [])
+