mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-14 18:37:58 +00:00
remove now unused run_legacy_script()
This commit is contained in:
@@ -59,13 +59,6 @@ def cli_call(src_dir):
|
||||
return _call_nominatim
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_run_legacy(monkeypatch):
|
||||
mock = MockParamCapture()
|
||||
monkeypatch.setattr(nominatim.cli, 'run_legacy_script', mock)
|
||||
return mock
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_func_factory(monkeypatch):
|
||||
def get_mock(module, func):
|
||||
|
||||
@@ -16,75 +16,6 @@ from nominatim.config import Configuration
|
||||
import nominatim.tools.exec_utils as exec_utils
|
||||
import nominatim.paths
|
||||
|
||||
class TestRunLegacyScript:
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup_nominatim_env(self, tmp_path, monkeypatch):
|
||||
tmp_phplib_dir = tmp_path / 'phplib'
|
||||
tmp_phplib_dir.mkdir()
|
||||
(tmp_phplib_dir / 'admin').mkdir()
|
||||
|
||||
monkeypatch.setattr(nominatim.paths, 'PHPLIB_DIR', tmp_phplib_dir)
|
||||
|
||||
self.phplib_dir = tmp_phplib_dir
|
||||
self.config = Configuration(tmp_path)
|
||||
self.config.set_libdirs(module='.', osm2pgsql='default_osm2pgsql',
|
||||
php=tmp_phplib_dir)
|
||||
|
||||
|
||||
def mk_script(self, code):
|
||||
codefile = self.phplib_dir / 'admin' / 't.php'
|
||||
codefile.write_text('<?php\n' + code + '\n')
|
||||
|
||||
return 't.php'
|
||||
|
||||
|
||||
@pytest.mark.parametrize("return_code", (0, 1, 15, 255))
|
||||
def test_run_legacy_return_exit_code(self, return_code):
|
||||
fname = self.mk_script('exit({});'.format(return_code))
|
||||
assert return_code == \
|
||||
exec_utils.run_legacy_script(fname, config=self.config)
|
||||
|
||||
|
||||
def test_run_legacy_return_throw_on_fail(self):
|
||||
fname = self.mk_script('exit(11);')
|
||||
with pytest.raises(subprocess.CalledProcessError):
|
||||
exec_utils.run_legacy_script(fname, config=self.config,
|
||||
throw_on_fail=True)
|
||||
|
||||
|
||||
def test_run_legacy_return_dont_throw_on_success(self):
|
||||
fname = self.mk_script('exit(0);')
|
||||
assert exec_utils.run_legacy_script(fname, config=self.config,
|
||||
throw_on_fail=True) == 0
|
||||
|
||||
def test_run_legacy_use_given_module_path(self):
|
||||
fname = self.mk_script("exit($_SERVER['NOMINATIM_DATABASE_MODULE_PATH'] == '' ? 0 : 23);")
|
||||
|
||||
assert exec_utils.run_legacy_script(fname, config=self.config) == 0
|
||||
|
||||
|
||||
def test_run_legacy_do_not_overwrite_module_path(self, monkeypatch):
|
||||
monkeypatch.setenv('NOMINATIM_DATABASE_MODULE_PATH', 'other')
|
||||
fname = self.mk_script(
|
||||
"exit($_SERVER['NOMINATIM_DATABASE_MODULE_PATH'] == 'other' ? 0 : 1);")
|
||||
|
||||
assert exec_utils.run_legacy_script(fname, config=self.config) == 0
|
||||
|
||||
|
||||
def test_run_legacy_default_osm2pgsql_binary(self, monkeypatch):
|
||||
fname = self.mk_script("exit($_SERVER['NOMINATIM_OSM2PGSQL_BINARY'] == 'default_osm2pgsql' ? 0 : 23);")
|
||||
|
||||
assert exec_utils.run_legacy_script(fname, config=self.config) == 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, config=self.config) == 0
|
||||
|
||||
|
||||
class TestRunApiScript:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user