X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/2c909c1f0c7c6e6a176eb5cc15e8d6a45449ebe8..f5977dac75bde4ab5b7bddf0c1834e1b7c688d64:/test/python/test_tools_exec_utils.py diff --git a/test/python/test_tools_exec_utils.py b/test/python/test_tools_exec_utils.py index d9f80740..3abe9818 100644 --- a/test/python/test_tools_exec_utils.py +++ b/test/python/test_tools_exec_utils.py @@ -7,23 +7,17 @@ import tempfile import pytest -from nominatim.config import Configuration import nominatim.tools.exec_utils as exec_utils @pytest.fixture -def tmp_phplib_dir(): - with tempfile.TemporaryDirectory() as phpdir: - (Path(phpdir) / 'admin').mkdir() - - yield Path(phpdir) - -@pytest.fixture -def nominatim_env(tmp_phplib_dir): +def nominatim_env(tmp_phplib_dir, def_config): class _NominatimEnv: - config = Configuration(None, Path(__file__) / '..' / '..' / '..' / 'settings') + config = def_config phplib_dir = tmp_phplib_dir data_dir = Path('data') project_dir = Path('.') + sqllib_dir = Path('lib-sql') + config_dir = Path('settings') module_dir = 'module' osm2pgsql_path = 'osm2pgsql' @@ -64,8 +58,8 @@ def test_run_legacy_return_dont_throw_on_success(nominatim_env, test_script): assert 0 == exec_utils.run_legacy_script(fname, nominatim_env=nominatim_env, throw_on_fail=True) -def test_run_legacy_use_given__module_path(nominatim_env, test_script): - fname = test_script("exit($_SERVER['NOMINATIM_DATABASE_MODULE_PATH'] == 'module' ? 0 : 23);") +def test_run_legacy_use_given_module_path(nominatim_env, test_script): + fname = test_script("exit($_SERVER['NOMINATIM_DATABASE_MODULE_PATH'] == '' ? 0 : 23);") assert 0 == exec_utils.run_legacy_script(fname, nominatim_env=nominatim_env) @@ -100,3 +94,19 @@ def test_run_api_with_extra_env(tmp_project_dir): extra_env = dict(SCRIPT_FILENAME=str(tmp_project_dir / 'website' / 'test.php')) assert 0 == exec_utils.run_api_script('badname', tmp_project_dir, extra_env=extra_env) + + +### run_osm2pgsql + +def test_run_osm2pgsql(osm2pgsql_options): + osm2pgsql_options['append'] = False + osm2pgsql_options['import_file'] = 'foo.bar' + osm2pgsql_options['tablespaces']['osm_data'] = 'extra' + exec_utils.run_osm2pgsql(osm2pgsql_options) + + +def test_run_osm2pgsql_disable_jit(osm2pgsql_options): + osm2pgsql_options['append'] = True + osm2pgsql_options['import_file'] = 'foo.bar' + osm2pgsql_options['disable_jit'] = True + exec_utils.run_osm2pgsql(osm2pgsql_options)