X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/b90e719da595b6760b39b7cd64ee29447de2d5e8..5877b69d51db2b0880bde6008089b52591989051:/test/python/tools/test_exec_utils.py diff --git a/test/python/tools/test_exec_utils.py b/test/python/tools/test_exec_utils.py index 25ccf163..26ea92b2 100644 --- a/test/python/tools/test_exec_utils.py +++ b/test/python/tools/test_exec_utils.py @@ -1,3 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# This file is part of Nominatim. (https://nominatim.org) +# +# Copyright (C) 2022 by the Nominatim developer community. +# For a full list of authors see the git log. """ Tests for tools.exec_utils module. """ @@ -69,6 +75,20 @@ class TestRunLegacyScript: assert exec_utils.run_legacy_script(fname, nominatim_env=self.testenv) == 0 + def test_run_legacy_default_osm2pgsql_binary(self, monkeypatch): + fname = self.mk_script("exit($_SERVER['NOMINATIM_OSM2PGSQL_BINARY'] == 'osm2pgsql' ? 0 : 23);") + + assert exec_utils.run_legacy_script(fname, nominatim_env=self.testenv) == 0 + + + def test_run_legacy_override_osm2pgsql_binary(self, monkeypatch): + monkeypatch.setenv('NOMINATIM_OSM2PGSQL_BINARY', 'somethingelse') + + fname = self.mk_script("exit($_SERVER['NOMINATIM_OSM2PGSQL_BINARY'] == 'somethingelse' ? 0 : 23);") + + assert exec_utils.run_legacy_script(fname, nominatim_env=self.testenv) == 0 + + class TestRunApiScript: @staticmethod @@ -92,13 +112,32 @@ class TestRunApiScript: extra_env = dict(SCRIPT_FILENAME=str(tmp_path / 'website' / 'test.php')) assert exec_utils.run_api_script('badname', tmp_path, extra_env=extra_env) == 0 + @staticmethod + def test_custom_phpcgi(tmp_path, capfd): + assert exec_utils.run_api_script('test', tmp_path, phpcgi_bin='env', + params={'q' : 'Berlin'}) == 0 + captured = capfd.readouterr() + + assert '?q=Berlin' in captured.out + + @staticmethod + def test_fail_on_error_output(tmp_path): + # Starting PHP 8 the PHP CLI no longer has STDERR defined as constant + php = """ +