From: Sarah Hoffmann Date: Wed, 1 Dec 2021 13:23:51 +0000 (+0100) Subject: more tests for exec utilities X-Git-Tag: v4.1.0~108^2~7 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/a24f25c0d81a63d2e7b688ff36e83f19170420a1 more tests for exec utilities --- diff --git a/test/python/tools/test_exec_utils.py b/test/python/tools/test_exec_utils.py index 25ccf163..e6289135 100644 --- a/test/python/tools/test_exec_utils.py +++ b/test/python/tools/test_exec_utils.py @@ -69,6 +69,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 +106,26 @@ 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): + (tmp_path / 'website' / 'bad.php').write_text("