X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/430c316e45c5fcbaf7f8023958a13ad1f31f44b2..345637290b85dc24f5023f07d919ff5d8dc486e9:/test/python/test_cli_replication.py diff --git a/test/python/test_cli_replication.py b/test/python/test_cli_replication.py index dcaeaf25..8e47e96e 100644 --- a/test/python/test_cli_replication.py +++ b/test/python/test_cli_replication.py @@ -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