- # place_addressline should not have duplicate (place_id, address_place_id)
- cur = context.db.cursor()
- cur.execute("""SELECT count(*) FROM
- (SELECT place_id, address_place_id, count(*) as c
- FROM place_addressline GROUP BY place_id, address_place_id) x
- WHERE c > 1""")
- assert cur.fetchone()[0] == 0, "Duplicates found in place_addressline"
-
-
-def assert_db_column(row, column, value, context):
- if column == 'object':
- return
-
- if column.startswith('centroid'):
- if value == 'in geometry':
- query = """SELECT ST_Within(ST_SetSRID(ST_Point({}, {}), 4326),
- ST_SetSRID('{}'::geometry, 4326))""".format(
- row['cx'], row['cy'], row['geomtxt'])
- cur = context.db.cursor()
- cur.execute(query)
- assert cur.fetchone()[0], "(Row %s failed: %s)" % (column, query)
- else:
- fac = float(column[9:]) if column.startswith('centroid*') else 1.0
- x, y = value.split(' ')
- assert Almost(float(x) * fac) == row['cx'], "Bad x coordinate"
- assert Almost(float(y) * fac) == row['cy'], "Bad y coordinate"
- elif column == 'geometry':
- geom = context.osm.parse_geometry(value, context.scene)
- cur = context.db.cursor()
- query = "SELECT ST_Equals(ST_SnapToGrid(%s, 0.00001, 0.00001), ST_SnapToGrid(ST_SetSRID('%s'::geometry, 4326), 0.00001, 0.00001))" % (
- geom, row['geomtxt'],)
- cur.execute(query)
- assert cur.fetchone()[0], "(Row %s failed: %s)" % (column, query)
- elif value == '-':
- assert row[column] is None, "Row %s" % column
- else:
- assert value == str(row[column]), \
- "Row '%s': expected: %s, got: %s" % (column, value, str(row[column]))
+ with context.db.cursor() as cur:
+ # place_addressline should not have duplicate (place_id, address_place_id)
+ cur.execute("""SELECT count(*) FROM
+ (SELECT place_id, address_place_id, count(*) as c
+ FROM place_addressline GROUP BY place_id, address_place_id) x
+ WHERE c > 1""")
+ assert cur.fetchone()[0] == 0, "Duplicates found in place_addressline"
+
+ # word table must not have empty word_tokens
+ if context.nominatim.tokenizer != 'legacy':
+ cur.execute("SELECT count(*) FROM word WHERE word_token = ''")
+ assert cur.fetchone()[0] == 0, "Empty word tokens found in word table"
+