mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-16 15:47:58 +00:00
add more tests for interpolations (mostly updating)
This commit is contained in:
@@ -119,10 +119,10 @@ def check_search_name_content(step):
|
||||
else:
|
||||
raise Exception("Cannot handle field %s in search_name table" % (k, ))
|
||||
|
||||
@step(u'node (\d+) expands to housenumbers')
|
||||
@step(u'way (\d+) expands to housenumbers')
|
||||
def check_interpolated_housenumbers(step, nodeid):
|
||||
"""Check that the exact set of housenumbers has been entered in
|
||||
placex for the given source node. Expected are tow columns:
|
||||
placex for the given source node. Expected are two columns:
|
||||
housenumber and centroid
|
||||
"""
|
||||
numbers = {}
|
||||
@@ -132,7 +132,8 @@ def check_interpolated_housenumbers(step, nodeid):
|
||||
cur = world.conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
|
||||
cur.execute("""SELECT DISTINCT housenumber,
|
||||
ST_X(centroid) as clat, ST_Y(centroid) as clon
|
||||
FROM placex WHERE osm_type = 'N' and osm_id = %s""",
|
||||
FROM placex WHERE osm_type = 'W' and osm_id = %s
|
||||
and class = 'place' and type = 'address'""",
|
||||
(int(nodeid),))
|
||||
assert_equals(len(numbers), cur.rowcount)
|
||||
for r in cur:
|
||||
@@ -140,6 +141,32 @@ def check_interpolated_housenumbers(step, nodeid):
|
||||
world.match_geometry((r['clat'], r['clon']), numbers[r["housenumber"]])
|
||||
del numbers[r["housenumber"]]
|
||||
|
||||
@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))
|
||||
|
||||
@step(u'table search_name has no entry for (.*)')
|
||||
def check_placex_missing(step, osmid):
|
||||
|
||||
@@ -213,8 +213,8 @@ def import_database(step):
|
||||
world.run_nominatim_script('setup', 'create-functions', 'create-partition-functions')
|
||||
cur = world.conn.cursor()
|
||||
cur.execute("""insert into placex (osm_type, osm_id, class, type, name, admin_level,
|
||||
housenumber, street, addr_place, isin, postcode, country_code, extratags,
|
||||
geometry) select * from place""")
|
||||
housenumber, street, addr_place, isin, postcode, country_code, extratags,
|
||||
geometry) select * from place""")
|
||||
world.conn.commit()
|
||||
world.run_nominatim_script('setup', 'index', 'index-noanalyse')
|
||||
#world.db_dump_table('placex')
|
||||
|
||||
@@ -94,7 +94,7 @@ def get_placeid(oid):
|
||||
q = 'SELECT place_id FROM placex where osm_type = %s and osm_id = %s and class = %s'
|
||||
params = (osmtype, osmid, cls)
|
||||
cur.execute(q, params)
|
||||
assert_equals (cur.rowcount, 1)
|
||||
assert_equals(cur.rowcount, 1, "%d rows found for place %s" % (cur.rowcount, oid))
|
||||
return cur.fetchone()[0]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user