X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/5a245e33e08d3b0b825cb8f9b47214e1b221118e..4cc788f69e1191d2dd985aeac143597566529f24:/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 5d65fafb..f7dfe32e 100644 --- a/test/python/tools/test_tiger_data.py +++ b/test/python/tools/test_tiger_data.py @@ -2,7 +2,7 @@ # # This file is part of Nominatim. (https://nominatim.org) # -# Copyright (C) 2024 by the Nominatim developer community. +# Copyright (C) 2025 by the Nominatim developer community. # For a full list of authors see the git log. """ Test for tiger data function @@ -11,12 +11,13 @@ import tarfile from textwrap import dedent import pytest -import pytest_asyncio +import pytest_asyncio # noqa: F401 from nominatim_db.db.connection import execute_scalar from nominatim_db.tools import tiger_data, freeze from nominatim_db.errors import UsageError + class MockTigerTable: def __init__(self, conn): @@ -40,6 +41,7 @@ class MockTigerTable: cur.execute("SELECT * FROM tiger LIMIT 1") return cur.fetchone() + @pytest.fixture def tiger_table(def_config, temp_db_conn, sql_preprocessor, temp_db_with_extensions, tmp_path): @@ -87,7 +89,7 @@ async def test_add_tiger_data(def_config, src_dir, tiger_table, tokenizer_mock, @pytest.mark.asyncio async def test_add_tiger_data_database_frozen(def_config, temp_db_conn, tiger_table, tokenizer_mock, - tmp_path): + tmp_path): freeze.drop_update_tables(temp_db_conn) with pytest.raises(UsageError) as excinfo: @@ -100,7 +102,7 @@ async def test_add_tiger_data_database_frozen(def_config, temp_db_conn, tiger_ta @pytest.mark.asyncio async def test_add_tiger_data_no_files(def_config, tiger_table, tokenizer_mock, - tmp_path): + tmp_path): await tiger_data.add_tiger_data(str(tmp_path), def_config, 1, tokenizer_mock()) assert tiger_table.count() == 0 @@ -108,7 +110,7 @@ async def test_add_tiger_data_no_files(def_config, tiger_table, tokenizer_mock, @pytest.mark.asyncio async def test_add_tiger_data_bad_file(def_config, tiger_table, tokenizer_mock, - tmp_path): + tmp_path): sqlfile = tmp_path / '1010.csv' sqlfile.write_text("""Random text""") @@ -119,7 +121,7 @@ async def test_add_tiger_data_bad_file(def_config, tiger_table, tokenizer_mock, @pytest.mark.asyncio async def test_add_tiger_data_hnr_nan(def_config, tiger_table, tokenizer_mock, - csv_factory, tmp_path): + csv_factory, tmp_path): csv_factory('file1', hnr_from=99) csv_factory('file2', hnr_from='L12') csv_factory('file3', hnr_to='12.4') @@ -133,7 +135,7 @@ async def test_add_tiger_data_hnr_nan(def_config, tiger_table, tokenizer_mock, @pytest.mark.parametrize("threads", (1, 5)) @pytest.mark.asyncio async def test_add_tiger_data_tarfile(def_config, tiger_table, tokenizer_mock, - tmp_path, src_dir, threads): + tmp_path, src_dir, threads): tar = tarfile.open(str(tmp_path / 'sample.tar.gz'), "w:gz") tar.add(str(src_dir / 'test' / 'testdb' / 'tiger' / '01001.csv')) tar.close() @@ -146,7 +148,7 @@ async def test_add_tiger_data_tarfile(def_config, tiger_table, tokenizer_mock, @pytest.mark.asyncio async def test_add_tiger_data_bad_tarfile(def_config, tiger_table, tokenizer_mock, - tmp_path): + tmp_path): tarfile = tmp_path / 'sample.tar.gz' tarfile.write_text("""Random text""") @@ -156,7 +158,7 @@ async def test_add_tiger_data_bad_tarfile(def_config, tiger_table, tokenizer_moc @pytest.mark.asyncio async def test_add_tiger_data_empty_tarfile(def_config, tiger_table, tokenizer_mock, - tmp_path): + tmp_path): tar = tarfile.open(str(tmp_path / 'sample.tar.gz'), "w:gz") tar.add(__file__) tar.close()