X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/bb175cc95898de420781867973b38d033c187e81..332de72045ec0f52c322a595a35a1306ea8a5efb:/test/python/db/test_status.py diff --git a/test/python/db/test_status.py b/test/python/db/test_status.py index b6f5a7b1..05fb2c7f 100644 --- a/test/python/db/test_status.py +++ b/test/python/db/test_status.py @@ -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 status table manipulation. """ @@ -25,6 +31,22 @@ def setup_status_table(status_table): pass +@pytest.mark.parametrize('offline', [True, False]) +def test_compute_database_date_from_osm2pgsql(table_factory, temp_db_conn, offline): + table_factory('osm2pgsql_properties', 'property TEXT, value TEXT', + content=(('current_timestamp', '2024-01-03T23:45:54Z'), )) + + date = nominatim.db.status.compute_database_date(temp_db_conn, offline=offline) + assert date == iso_date('2024-01-03T23:45:54') + + +def test_compute_database_date_from_osm2pgsql_nodata(table_factory, temp_db_conn): + table_factory('osm2pgsql_properties', 'property TEXT, value TEXT') + + with pytest.raises(UsageError, match='Cannot determine database date from data in offline mode'): + nominatim.db.status.compute_database_date(temp_db_conn, offline=True) + + def test_compute_database_date_place_empty(place_table, temp_db_conn): with pytest.raises(UsageError): nominatim.db.status.compute_database_date(temp_db_conn)