mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-14 18:37:58 +00:00
when adding Tiger data, check first if database is in frozen state
This commit is contained in:
@@ -30,6 +30,8 @@ def test_drop_tables(temp_db_conn, temp_db_cursor, table_factory):
|
||||
for table in NOMINATIM_RUNTIME_TABLES + NOMINATIM_DROP_TABLES:
|
||||
table_factory(table)
|
||||
|
||||
assert not freeze.is_frozen(temp_db_conn)
|
||||
|
||||
freeze.drop_update_tables(temp_db_conn)
|
||||
|
||||
for table in NOMINATIM_RUNTIME_TABLES:
|
||||
@@ -38,6 +40,8 @@ def test_drop_tables(temp_db_conn, temp_db_cursor, table_factory):
|
||||
for table in NOMINATIM_DROP_TABLES:
|
||||
assert not temp_db_cursor.table_exists(table)
|
||||
|
||||
assert freeze.is_frozen(temp_db_conn)
|
||||
|
||||
def test_drop_flatnode_file_no_file():
|
||||
freeze.drop_flatnode_file(None)
|
||||
|
||||
@@ -46,7 +50,7 @@ def test_drop_flatnode_file_file_already_gone(tmp_path):
|
||||
freeze.drop_flatnode_file(tmp_path / 'something.store')
|
||||
|
||||
|
||||
def test_drop_flatnode_file_delte(tmp_path):
|
||||
def test_drop_flatnode_file_delete(tmp_path):
|
||||
flatfile = tmp_path / 'flatnode.store'
|
||||
flatfile.write_text('Some content')
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ from textwrap import dedent
|
||||
|
||||
import pytest
|
||||
|
||||
from nominatim.tools import tiger_data
|
||||
from nominatim.tools import tiger_data, freeze
|
||||
from nominatim.errors import UsageError
|
||||
|
||||
class MockTigerTable:
|
||||
@@ -27,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")
|
||||
@@ -80,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())
|
||||
|
||||
Reference in New Issue
Block a user