X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/9d103503f71eef5dc6c5f85f5b84b11410f52cdb..73953cbac95847740339d7a5ee3c0e5f142d93c5:/test/python/test_tools_refresh_create_functions.py diff --git a/test/python/test_tools_refresh_create_functions.py b/test/python/test_tools_refresh_create_functions.py index 40d4c81a..00b863ab 100644 --- a/test/python/test_tools_refresh_create_functions.py +++ b/test/python/test_tools_refresh_create_functions.py @@ -6,14 +6,17 @@ import pytest from nominatim.tools.refresh import create_functions @pytest.fixture -def conn(temp_db_conn, table_factory, monkeypatch): - monkeypatch.setenv('NOMINATIM_DATABASE_MODULE_PATH', '.') - table_factory('country_name', 'partition INT', (0, 1, 2)) +def sql_tmp_path(tmp_path, def_config): + def_config.lib_dir.sql = tmp_path + return tmp_path + +@pytest.fixture +def conn(sql_preprocessor, temp_db_conn): return temp_db_conn -def test_create_functions(temp_db_cursor, conn, def_config, tmp_path): - sqlfile = tmp_path / 'functions.sql' +def test_create_functions(temp_db_cursor, conn, def_config, sql_tmp_path): + sqlfile = sql_tmp_path / 'functions.sql' sqlfile.write_text("""CREATE OR REPLACE FUNCTION test() RETURNS INTEGER AS $$ BEGIN @@ -22,14 +25,15 @@ def test_create_functions(temp_db_cursor, conn, def_config, tmp_path): $$ LANGUAGE plpgsql IMMUTABLE; """) - create_functions(conn, def_config, tmp_path) + create_functions(conn, def_config) assert temp_db_cursor.scalar('SELECT test()') == 43 @pytest.mark.parametrize("dbg,ret", ((True, 43), (False, 22))) -def test_create_functions_with_template(temp_db_cursor, conn, def_config, tmp_path, dbg, ret): - sqlfile = tmp_path / 'functions.sql' +def test_create_functions_with_template(temp_db_cursor, conn, def_config, sql_tmp_path, + dbg, ret): + sqlfile = sql_tmp_path / 'functions.sql' sqlfile.write_text("""CREATE OR REPLACE FUNCTION test() RETURNS INTEGER AS $$ BEGIN @@ -42,6 +46,6 @@ def test_create_functions_with_template(temp_db_cursor, conn, def_config, tmp_pa $$ LANGUAGE plpgsql IMMUTABLE; """) - create_functions(conn, def_config, tmp_path, enable_debug=dbg) + create_functions(conn, def_config, enable_debug=dbg) assert temp_db_cursor.scalar('SELECT test()') == ret