]> git.openstreetmap.org Git - nominatim.git/blobdiff - test/bdd/steps/db_ops.py
add tests for geocodejson and fix syntax errors
[nominatim.git] / test / bdd / steps / db_ops.py
index fa8cd0de3a2ddc51fab81d427ad411c45978f267..80f922222c0018c7e99c69e8064990883c51b69c 100644 (file)
@@ -22,6 +22,8 @@ class PlaceColumn:
             self.add_hstore('extratags', key[6:], value)
         elif key.startswith('addr+'):
             self.add_hstore('address', key[5:], value)
+        elif key in ('name', 'address', 'extratags'):
+            self.columns[key] = eval('{' + value + '}')
         else:
             assert_in(key, ('class', 'type'))
             self.columns[key] = None if value == '' else value
@@ -287,7 +289,7 @@ def import_and_index_data_from_place_table(context):
               WHERE class='place' and type='houses' and osm_type='W'
                     and ST_GeometryType(geometry) = 'ST_LineString'""")
     context.db.commit()
-    context.nominatim.run_setup_script('index', 'index-noanalyse')
+    context.nominatim.run_setup_script('calculate-postcodes', 'index', 'index-noanalyse')
 
 @when("updating places")
 def update_place_table(context):
@@ -425,8 +427,8 @@ def check_placex_contents(context, exact):
 
     context.db.commit()
 
-@then("search_name contains")
-def check_search_name_contents(context):
+@then("search_name contains(?P<exclude> not)?")
+def check_search_name_contents(context, exclude):
     cur = context.db.cursor(cursor_factory=psycopg2.extras.DictCursor)
 
     for row in context.table:
@@ -444,11 +446,16 @@ def check_search_name_contents(context):
                                       FROM word, (SELECT unnest(%s) as term) t
                                       WHERE word_token = make_standard_name(t.term)""",
                                    (terms,))
-                    ok_(subcur.rowcount >= len(terms),
-                        "No word entry found for " + row[h])
+                    if not exclude:
+                        ok_(subcur.rowcount >= len(terms),
+                            "No word entry found for " + row[h])
                     for wid in subcur:
-                        assert_in(wid[0], res[h],
-                                  "Missing term for %s/%s: %s" % (pid, h, wid[1]))
+                        if exclude:
+                            assert_not_in(wid[0], res[h],
+                                          "Found term for %s/%s: %s" % (pid, h, wid[1]))
+                        else:
+                            assert_in(wid[0], res[h],
+                                      "Missing term for %s/%s: %s" % (pid, h, wid[1]))
                 else:
                     assert_db_column(res, h, row[h], context)