]> git.openstreetmap.org Git - nominatim.git/blobdiff - test/python/tools/test_migration.py
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / test / python / tools / test_migration.py
index 8fef0dc1a4025461545e0ca8d42af1e12db2d2fc..88c7a4dd7826a4f9a97a09455103fef6a1874971 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')
@@ -65,20 +71,6 @@ def test_already_at_version(def_config, property_table):
     assert migration.migrate(def_config, {}) == 0
 
 
-def test_no_migrations_necessary(def_config, temp_db_cursor, property_table,
-                                 monkeypatch):
-    oldversion = [x for x in nominatim.version.NOMINATIM_VERSION]
-    oldversion[0] -= 1
-    property_table.set('database_version',
-                       '{0[0]}.{0[1]}.{0[2]}-{0[3]}'.format(oldversion))
-
-    oldversion[0] = 0
-    monkeypatch.setattr(migration, '_MIGRATION_FUNCTIONS',
-                        [(tuple(oldversion), lambda **attr: True)])
-
-    assert migration.migrate(def_config, {}) == 0
-
-
 def test_run_single_migration(def_config, temp_db_cursor, property_table,
                               monkeypatch, postprocess_mock):
     oldversion = [x for x in nominatim.version.NOMINATIM_VERSION]
@@ -156,7 +148,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)