X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/bb175cc95898de420781867973b38d033c187e81..fa1c402b47bdd1f76b8528885c0e3a5e90731cdc:/test/python/tools/test_tiger_data.py diff --git a/test/python/tools/test_tiger_data.py b/test/python/tools/test_tiger_data.py index 2e524087..7ef6a1e6 100644 --- a/test/python/tools/test_tiger_data.py +++ b/test/python/tools/test_tiger_data.py @@ -1,3 +1,9 @@ +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This file is part of Nominatim. (https://nominatim.org) +# +# Copyright (C) 2024 by the Nominatim developer community. +# For a full list of authors see the git log. """ Test for tiger data function """ @@ -6,8 +12,8 @@ from textwrap import dedent import pytest -from nominatim.tools import tiger_data -from nominatim.errors import UsageError +from nominatim_db.tools import tiger_data, freeze +from nominatim_db.errors import UsageError class MockTigerTable: @@ -21,6 +27,9 @@ class MockTigerTable: token_info JSONB, postcode TEXT)""") + # We need this table to determine if the database is frozen or not + cur.execute("CREATE TABLE place (number INTEGER)") + def count(self): with self.conn.cursor() as cur: return cur.scalar("SELECT count(*) FROM tiger") @@ -74,6 +83,17 @@ def test_add_tiger_data(def_config, src_dir, tiger_table, tokenizer_mock, thread assert tiger_table.count() == 6213 +def test_add_tiger_data_database_frozen(def_config, temp_db_conn, tiger_table, tokenizer_mock, + tmp_path): + freeze.drop_update_tables(temp_db_conn) + + with pytest.raises(UsageError) as excinfo: + tiger_data.add_tiger_data(str(tmp_path), def_config, 1, tokenizer_mock()) + + assert "database frozen" in str(excinfo.value) + + assert tiger_table.count() == 0 + def test_add_tiger_data_no_files(def_config, tiger_table, tokenizer_mock, tmp_path): tiger_data.add_tiger_data(str(tmp_path), def_config, 1, tokenizer_mock())