]> git.openstreetmap.org Git - nominatim.git/commitdiff
switch tests to ICU tokenizer as default
authorSarah Hoffmann <lonvia@denofr.de>
Tue, 10 May 2022 12:54:50 +0000 (14:54 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Tue, 10 May 2022 12:54:50 +0000 (14:54 +0200)
test/bdd/environment.py
test/bdd/steps/nominatim_environment.py
test/bdd/steps/steps_db_ops.py
test/python/conftest.py
test/python/mocks.py
test/python/tools/test_database_import.py
test/python/tools/test_migration.py
test/python/tools/test_postcodes.py

index 0acc73b436158f373474a63cf028166f87460b9a..ee07e6028c1ca67497082316821fb219a0c0d9f6 100644 (file)
@@ -59,5 +59,5 @@ def after_scenario(context, scenario):
 
 def before_tag(context, tag):
     if tag == 'fail-legacy':
-        if context.config.userdata['TOKENIZER'] in (None, 'legacy'):
+        if context.config.userdata['TOKENIZER'] == 'legacy':
             context.scenario.skip("Not implemented in legacy tokenizer")
index 7de32e484f50f1f645c79137a45541b2820538ca..70a03e6ec31e37a148f1ea0255c3b283913704b5 100644 (file)
@@ -207,7 +207,7 @@ class NominatimEnvironment:
                     self.run_nominatim('add-data', '--tiger-data', str((testdata / 'tiger').resolve()))
                     self.run_nominatim('freeze')
 
-                    if self.tokenizer != 'icu':
+                    if self.tokenizer == 'legacy':
                         phrase_file = str((testdata / 'specialphrases_testdb.sql').resolve())
                         run_script(['psql', '-d', self.api_test_db, '-f', phrase_file])
                     else:
index e02cad8f4ac92c46d17ab4a4e7c74c1a3016cefc..4c711b725b34588599fa01fe27cbbf16698fde6a 100644 (file)
@@ -266,7 +266,7 @@ def check_word_table_for_postcodes(context, exclude, postcodes):
     plist.sort()
 
     with context.db.cursor(cursor_factory=psycopg2.extras.DictCursor) as cur:
-        if nctx.tokenizer == 'icu':
+        if nctx.tokenizer != 'legacy':
             cur.execute("SELECT word FROM word WHERE type = 'P' and word = any(%s)",
                         (plist,))
         else:
index f4581bf92aae0b879e362bccef351616029be118..405262950b78319d2924274ad497f933b03490f2 100644 (file)
@@ -211,11 +211,6 @@ def osmline_table(temp_db_with_extensions, table_factory):
                      country_code VARCHAR(2)""")
 
 
-@pytest.fixture
-def word_table(temp_db_conn):
-    return mocks.MockWordTable(temp_db_conn)
-
-
 @pytest.fixture
 def sql_preprocessor_cfg(tmp_path, table_factory, temp_db_with_extensions):
     table_factory('country_name', 'partition INT', ((0, ), (1, ), (2, )))
index 2cd2e3e38297f1469f82a3bf236fc2b6ac969eb2..9c6ef53215dd91c24368a6153385da9011f52445 100644 (file)
@@ -14,7 +14,7 @@ import psycopg2.extras
 from nominatim.db import properties
 
 # This must always point to the mock word table for the default tokenizer.
-from mock_legacy_word_table import MockLegacyWordTable as MockWordTable
+from mock_icu_word_table import MockIcuWordTable as MockWordTable
 
 class MockPlacexTable:
     """ A placex table for testing.
index 8ac31bc0f4a2f9c20e8e18637bc8a151a1184145..68d19a07beb78e0b3b4adffa298016d2da3eff4d 100644 (file)
@@ -179,7 +179,7 @@ def test_truncate_database_tables(temp_db_conn, temp_db_cursor, table_factory, w
 
 @pytest.mark.parametrize("threads", (1, 5))
 def test_load_data(dsn, place_row, placex_table, osmline_table,
-                   word_table, temp_db_cursor, threads):
+                   temp_db_cursor, threads):
     for func in ('precompute_words', 'getorcreate_housenumber_id', 'make_standard_name'):
         temp_db_cursor.execute(f"""CREATE FUNCTION {func} (src TEXT)
                                   RETURNS TEXT AS $$ SELECT 'a'::TEXT $$ LANGUAGE SQL
index 8fef0dc1a4025461545e0ca8d42af1e12db2d2fc..d102b97da9d3ab10392810b15336e8c7ab281ae0 100644 (file)
@@ -14,6 +14,8 @@ from nominatim.tools import migration
 from nominatim.errors import UsageError
 import nominatim.version
 
+from mock_legacy_word_table import MockLegacyWordTable
+
 class DummyTokenizer:
 
     def update_sql_functions(self, config):
@@ -26,6 +28,10 @@ def postprocess_mock(monkeypatch):
     monkeypatch.setattr(migration.tokenizer_factory, 'get_tokenizer_for_db',
                         lambda *args: DummyTokenizer())
 
+@pytest.fixture
+def legacy_word_table(temp_db_conn):
+    return MockLegacyWordTable(temp_db_conn)
+
 
 def test_no_migration_old_versions(temp_db_with_extensions, table_factory, def_config):
     table_factory('country_name', 'name HSTORE, country_code TEXT')
@@ -156,7 +162,7 @@ def test_add_nominatim_property_table_repeat(temp_db_conn, temp_db_cursor,
 
 
 def test_change_housenumber_transliteration(temp_db_conn, temp_db_cursor,
-                                            word_table, placex_table):
+                                            legacy_word_table, placex_table):
     placex_table.add(housenumber='3A')
 
     temp_db_cursor.execute("""CREATE OR REPLACE FUNCTION make_standard_name(name TEXT)
index 556d6457a0e9c726e1bae855be318f4fe2f89d2f..bdfe309471f0995188c9fdd32cc13815e9cac9ee 100644 (file)
@@ -65,7 +65,7 @@ def tokenizer():
     return dummy_tokenizer.DummyTokenizer(None, None)
 
 @pytest.fixture
-def postcode_table(temp_db_conn, placex_table, word_table):
+def postcode_table(temp_db_conn, placex_table):
     return MockPostcodeTable(temp_db_conn)