]> git.openstreetmap.org Git - nominatim.git/blobdiff - test/python/cli/test_cmd_replication.py
don't even try heavily penalized searches
[nominatim.git] / test / python / cli / test_cmd_replication.py
index 6c8a0ef6ac33dfd7c931d6c53407e583590a885c..a22d077a9f94e11f5b4b263d839e2479191241e2 100644 (file)
@@ -1,3 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# This file is part of Nominatim. (https://nominatim.org)
+#
+# Copyright (C) 2022 by the Nominatim developer community.
+# For a full list of authors see the git log.
 """
 Tests for replication command of command-line interface wrapper.
 """
@@ -9,6 +15,7 @@ import pytest
 import nominatim.cli
 import nominatim.indexer.indexer
 import nominatim.tools.replication
+import nominatim.tools.refresh
 from nominatim.db import status
 
 @pytest.fixture
@@ -66,14 +73,20 @@ class TestCliReplication:
 
 
     @pytest.mark.parametrize("params,func", [
+                             (('--init',), 'init_replication'),
                              (('--init', '--no-update-functions'), 'init_replication'),
                              (('--check-for-updates',), 'check_for_updates')
                              ])
     def test_replication_command(self, mock_func_factory, params, func):
         func_mock = mock_func_factory(nominatim.tools.replication, func)
 
+        if params == ('--init',):
+            umock = mock_func_factory(nominatim.tools.refresh, 'create_functions')
+
         assert self.call_nominatim(*params) == 0
         assert func_mock.called == 1
+        if params == ('--init',):
+            assert umock.called == 1
 
 
     def test_replication_update_bad_interval(self, monkeypatch):
@@ -89,10 +102,13 @@ class TestCliReplication:
         assert self.call_nominatim() == 1
 
 
+    def test_replication_update_continuous_no_index(self):
+        assert self.call_nominatim('--no-index') == 1
+
     def test_replication_update_once_no_index(self, update_mock):
         assert self.call_nominatim('--once', '--no-index') == 0
 
-        assert str(update_mock.last_args[1]['osm2pgsql']) == 'OSM2PGSQL NOT AVAILABLE'
+        assert str(update_mock.last_args[1]['osm2pgsql']).endswith('OSM2PGSQL NOT AVAILABLE')
 
 
     def test_replication_update_custom_osm2pgsql(self, monkeypatch, update_mock):