X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/6d431aebb77fb80ba51feb0596accbd39ace1125..c3238682a8867edfb3c052ca4d2d27b3926ad17a:/test/bdd/steps/db_ops.py?ds=sidebyside diff --git a/test/bdd/steps/db_ops.py b/test/bdd/steps/db_ops.py index f4c485fd..2b012c41 100644 --- a/test/bdd/steps/db_ops.py +++ b/test/bdd/steps/db_ops.py @@ -110,6 +110,9 @@ class PlaceObjName(object): if self.pid is None: return "" + if self.pid == 0: + return "place ID 0" + cur = self.conn.cursor() cur.execute("""SELECT osm_type, osm_id, class FROM placex WHERE place_id = %s""", @@ -467,15 +470,25 @@ def check_search_name_contents(context, exclude): for res in cur: for h in row.headings: if h in ('name_vector', 'nameaddress_vector'): - terms = [x.strip().replace('#', ' ') for x in row[h].split(',')] + terms = [x.strip() for x in row[h].split(',') if not x.strip().startswith('#')] + words = [x.strip()[1:] for x in row[h].split(',') if x.strip().startswith('#')] subcur = context.db.cursor() - subcur.execute("""SELECT word_id, word_token - FROM word, (SELECT unnest(%s) as term) t - WHERE word_token = make_standard_name(t.term)""", - (terms,)) + subcur.execute(""" SELECT word_id, word_token + FROM word, (SELECT unnest(%s::TEXT[]) as term) t + WHERE word_token = make_standard_name(t.term) + and class is null and country_code is null + and operator is null + UNION + SELECT word_id, word_token + FROM word, (SELECT unnest(%s::TEXT[]) as term) t + WHERE word_token = ' ' || make_standard_name(t.term) + and class is null and country_code is null + and operator is null + """, + (terms, words)) if not exclude: - ok_(subcur.rowcount >= len(terms), - "No word entry found for " + row[h]) + ok_(subcur.rowcount >= len(terms) + len(words), + "No word entry found for " + row[h] + ". Entries found: " + str(subcur.rowcount)) for wid in subcur: if exclude: assert_not_in(wid[0], res[h],