X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/b90e719da595b6760b39b7cd64ee29447de2d5e8..1f0796778754d8df0dfab9dd01302e26a397f064:/test/python/db/test_sql_preprocessor.py?ds=sidebyside diff --git a/test/python/db/test_sql_preprocessor.py b/test/python/db/test_sql_preprocessor.py index 2ca0c661..45109c70 100644 --- a/test/python/db/test_sql_preprocessor.py +++ b/test/python/db/test_sql_preprocessor.py @@ -1,9 +1,16 @@ +# 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. """ Tests for SQL preprocessing. """ import pytest +import pytest_asyncio -from nominatim.db.sql_preprocessor import SQLPreprocessor +from nominatim_db.db.sql_preprocessor import SQLPreprocessor @pytest.fixture def sql_factory(tmp_path): @@ -48,3 +55,17 @@ def test_load_file_with_params(sql_preprocessor, sql_factory, temp_db_conn, temp sql_preprocessor.run_sql_file(temp_db_conn, sqlfile, bar='XX', foo='ZZ') assert temp_db_cursor.scalar('SELECT test()') == 'ZZ XX' + + +@pytest.mark.asyncio +async def test_load_parallel_file(dsn, sql_preprocessor, tmp_path, temp_db_cursor): + (tmp_path / 'test.sql').write_text(""" + CREATE TABLE foo (a TEXT); + CREATE TABLE foo2(a TEXT);""" + + "\n---\nCREATE TABLE bar (b INT);") + + await sql_preprocessor.run_parallel_sql_file(dsn, 'test.sql', num_threads=4) + + assert temp_db_cursor.table_exists('foo') + assert temp_db_cursor.table_exists('foo2') + assert temp_db_cursor.table_exists('bar')