]> git.openstreetmap.org Git - nominatim.git/commitdiff
mock tokenizer factory for replication tests
authorSarah Hoffmann <lonvia@denofr.de>
Sat, 1 May 2021 08:50:39 +0000 (10:50 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Sat, 1 May 2021 08:50:39 +0000 (10:50 +0200)
test/python/test_cli_replication.py

index d4f8290f2caac5701debe0bada8cdd124fcb0d87..b95e6ede1787dd7619bee512e95a5694c1e30b02 100644 (file)
@@ -26,6 +26,28 @@ def call_nominatim(*args):
                                    config_dir=str(SRC_DIR / 'settings'),
                                    cli_args=['replication'] + list(args))
 
+@pytest.fixture
+def tokenizer_mock(monkeypatch):
+    class DummyTokenizer:
+        def __init__(self, *args, **kwargs):
+            self.update_sql_functions_called = False
+            self.finalize_import_called = False
+
+        def update_sql_functions(self, *args):
+            self.update_sql_functions_called = True
+
+        def finalize_import(self, *args):
+            self.finalize_import_called = True
+
+    tok = DummyTokenizer()
+    monkeypatch.setattr(nominatim.tokenizer.factory, 'get_tokenizer_for_db' ,
+                        lambda *args: tok)
+    monkeypatch.setattr(nominatim.tokenizer.factory, 'create_tokenizer' ,
+                        lambda *args: tok)
+
+    return tok
+
+
 @pytest.fixture
 def index_mock(monkeypatch, tokenizer_mock):
     mock = MockParamCapture()