+@step(u'way (\d+) expands to lines')
+def check_interpolation_lines(step, wayid):
+ """Check that the correct interpolation line has been entered in
+ location_property_osmline for the given source line/nodes. Expected are three columns:
+ startnumber, endnumber and linegeo
+ """
+ lines = {}
+ for line in step.hashes:
+ assert line["startnumber"] not in lines
+ lines[line["startnumber"]] = {'endnumber': line["endnumber"], 'geometry': line["geometry"]}
+ cur = world.conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
+ cur.execute("""SELECT startnumber::text, endnumber::text, st_astext(linegeo) as geometry
+ FROM location_property_osmline WHERE osm_id = %s""",
+ (int(wayid),))
+ assert_equals(len(lines), cur.rowcount)
+ for r in cur:
+ assert_in(r["startnumber"], lines)
+ assert_equals(r["endnumber"], lines[r["startnumber"]]["endnumber"])
+ linegeo = str(str(r["geometry"].split('(')[1]).split(')')[0]).replace(',', ', ')
+ assert_equals(linegeo, lines[r["startnumber"]]["geometry"])
+ del lines[r["startnumber"]]
+
+@step(u'way (\d+) expands exactly to housenumbers ([0-9,]*)')
+def check_interpolated_housenumber_list(step, nodeid, numberlist):
+ """ Checks that the interpolated house numbers corresponds
+ to the given list.
+ """
+ expected = numberlist.split(',');
+ cur = world.conn.cursor()
+ cur.execute("""SELECT housenumber FROM placex
+ WHERE osm_type = 'W' and osm_id = %s
+ and class = 'place' and type = 'address'""", (int(nodeid),))
+ for r in cur:
+ assert_in(r[0], expected, "Unexpected house number %s for node %s." % (r[0], nodeid))
+ expected.remove(r[0])
+ assert_equals(0, len(expected), "Missing house numbers for way %s: %s" % (nodeid, expected))
+
+@step(u'way (\d+) expands to no housenumbers')
+def check_no_interpolated_housenumber_list(step, nodeid):
+ """ Checks that the interpolated house numbers corresponds
+ to the given list.
+ """
+ cur = world.conn.cursor()
+ cur.execute("""SELECT housenumber FROM placex
+ WHERE osm_type = 'W' and osm_id = %s
+ and class = 'place' and type = 'address'""", (int(nodeid),))
+ res = [r[0] for r in cur]
+ assert_equals(0, len(res), "Unexpected house numbers for way %s: %s" % (nodeid, res))