always return 0 for updates unless there is an error

This is more in line with previous behavioru than returning
a status code when no updates are available.
This commit is contained in:
Sarah Hoffmann
2021-02-11 10:01:31 +01:00
parent 24b13a7a87
commit 7cc4c53adb
2 changed files with 6 additions and 9 deletions

View File

@@ -154,8 +154,6 @@ class UpdateReplication:
LOG.warning("No new changes. Sleeping for %d sec.", recheck_interval) LOG.warning("No new changes. Sleeping for %d sec.", recheck_interval)
time.sleep(recheck_interval) time.sleep(recheck_interval)
return state.value
@staticmethod @staticmethod
def run(args): def run(args):
@@ -167,4 +165,5 @@ class UpdateReplication:
if args.check_for_updates: if args.check_for_updates:
return UpdateReplication._check_for_updates(args) return UpdateReplication._check_for_updates(args)
return UpdateReplication._update(args) UpdateReplication._update(args)
return 0

View File

@@ -186,17 +186,15 @@ def test_replication_update_bad_interval_for_geofabrik(monkeypatch, temp_db):
assert call_nominatim('replication') == 1 assert call_nominatim('replication') == 1
@pytest.mark.parametrize("state, retval", [ @pytest.mark.parametrize("state", [nominatim.tools.replication.UpdateState.UP_TO_DATE,
(nominatim.tools.replication.UpdateState.UP_TO_DATE, 0), nominatim.tools.replication.UpdateState.NO_CHANGES])
(nominatim.tools.replication.UpdateState.NO_CHANGES, 3)
])
def test_replication_update_once_no_index(monkeypatch, temp_db, temp_db_conn, def test_replication_update_once_no_index(monkeypatch, temp_db, temp_db_conn,
status_table, state, retval): status_table, state):
status.set_status(temp_db_conn, date=dt.datetime.now(dt.timezone.utc), seq=1) status.set_status(temp_db_conn, date=dt.datetime.now(dt.timezone.utc), seq=1)
func_mock = MockParamCapture(retval=state) func_mock = MockParamCapture(retval=state)
monkeypatch.setattr(nominatim.tools.replication, 'update', func_mock) monkeypatch.setattr(nominatim.tools.replication, 'update', func_mock)
assert retval == call_nominatim('replication', '--once', '--no-index') assert 0 == call_nominatim('replication', '--once', '--no-index')
def test_replication_update_continuous(monkeypatch, temp_db_conn, status_table): def test_replication_update_continuous(monkeypatch, temp_db_conn, status_table):