2 Tests for creating PL/pgSQL functions for Nominatim.
6 from nominatim.tools.refresh import create_functions
9 def sql_tmp_path(tmp_path, def_config):
10 def_config.lib_dir.sql = tmp_path
14 def conn(sql_preprocessor, temp_db_conn):
18 def test_create_functions(temp_db_cursor, conn, def_config, sql_tmp_path):
19 sqlfile = sql_tmp_path / 'functions.sql'
20 sqlfile.write_text("""CREATE OR REPLACE FUNCTION test() RETURNS INTEGER
25 $$ LANGUAGE plpgsql IMMUTABLE;
28 create_functions(conn, def_config)
30 assert temp_db_cursor.scalar('SELECT test()') == 43
33 @pytest.mark.parametrize("dbg,ret", ((True, 43), (False, 22)))
34 def test_create_functions_with_template(temp_db_cursor, conn, def_config, sql_tmp_path, dbg, ret):
35 sqlfile = sql_tmp_path / 'functions.sql'
36 sqlfile.write_text("""CREATE OR REPLACE FUNCTION test() RETURNS INTEGER
45 $$ LANGUAGE plpgsql IMMUTABLE;
48 create_functions(conn, def_config, enable_debug=dbg)
50 assert temp_db_cursor.scalar('SELECT test()') == ret