]> git.openstreetmap.org Git - nominatim.git/blobdiff - test/python/test_cli_replication.py
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / test / python / test_cli_replication.py
index dcaeaf25fb8fff283f3228ac0fe2d12d56a99ad5..8e47e96e208fce677c7e42fd611f6992d52a7336 100644 (file)
@@ -53,8 +53,7 @@ def init_status(temp_db_conn, status_table):
 @pytest.fixture
 def index_mock(monkeypatch, tokenizer_mock, init_status):
     mock = MockParamCapture()
-    monkeypatch.setattr(nominatim.indexer.indexer.Indexer, 'index_boundaries', mock)
-    monkeypatch.setattr(nominatim.indexer.indexer.Indexer, 'index_by_rank', mock)
+    monkeypatch.setattr(nominatim.indexer.indexer.Indexer, 'index_full', mock)
 
     return mock
 
@@ -107,6 +106,16 @@ class TestCliReplication:
         assert str(update_mock.last_args[1]['osm2pgsql']) == '/secret/osm2pgsql'
 
 
+    @pytest.mark.parametrize("update_interval", [60, 3600])
+    def test_replication_catchup(self, monkeypatch, index_mock, update_interval, placex_table):
+        monkeypatch.setenv('NOMINATIM_REPLICATION_UPDATE_INTERVAL', str(update_interval))
+        states = [nominatim.tools.replication.UpdateState.NO_CHANGES]
+        monkeypatch.setattr(nominatim.tools.replication, 'update',
+                            lambda *args, **kwargs: states.pop())
+
+        assert self.call_nominatim('--catch-up') == 0
+
+
     def test_replication_update_custom_threads(self, update_mock):
         assert self.call_nominatim('--once', '--no-index', '--threads', '4') == 0
 
@@ -122,7 +131,7 @@ class TestCliReplication:
         with pytest.raises(IndexError):
             self.call_nominatim()
 
-        assert index_mock.called == 4
+        assert index_mock.called == 2
 
 
     def test_replication_update_continuous_no_change(self, monkeypatch, index_mock):
@@ -137,6 +146,6 @@ class TestCliReplication:
         with pytest.raises(IndexError):
             self.call_nominatim()
 
-        assert index_mock.called == 2
+        assert index_mock.called == 1
         assert sleep_mock.called == 1
         assert sleep_mock.last_args[0] == 60