diff options
author | Daniel Schadt <kingdread@gmx.de> | 2024-04-18 22:28:55 +0200 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2024-04-18 22:29:38 +0200 |
commit | 7f526efeed7b807a3b56f465637bee5dc8a27e3d (patch) | |
tree | c8f9129b47ca551e04aad9a50fe48f7d6e6c3e78 | |
parent | 83e08799d6b55bc2119aff4f9749bad103b5f574 (diff) | |
download | fietsboek-7f526efeed7b807a3b56f465637bee5dc8a27e3d.tar.gz fietsboek-7f526efeed7b807a3b56f465637bee5dc8a27e3d.tar.bz2 fietsboek-7f526efeed7b807a3b56f465637bee5dc8a27e3d.zip |
have data_dir as a placeholder in testing.ini
-rw-r--r-- | testing.ini | 8 | ||||
-rw-r--r-- | tests/bootstrap/test_new_instance.py | 15 |
2 files changed, 18 insertions, 5 deletions
diff --git a/testing.ini b/testing.ini index 4cb95ba..82fddfd 100644 --- a/testing.ini +++ b/testing.ini @@ -13,9 +13,11 @@ pyramid.debug_routematch = false pyramid.default_locale_name = en sqlalchemy.url = sqlite:///%(here)s/testing.sqlite -# In the pytest tests, this is overwritten with a temporary directory, but we -# should still set a value for the bootstrapping test. -fietsboek.data_dir = %(here)s/data +# The pytest tests usually overwrite this with a temporary directory. Since +# this is cleaned on test teardown, we don't want to accidentally delete data +# that should not be deleted. Therefore, we specifically do not set a directory +# here, and leave a placeholder to be replaced properly by the tests. +# %% fietsboek.data_dir %% redis.url = redis://localhost fietsboek.default_tile_layers = diff --git a/tests/bootstrap/test_new_instance.py b/tests/bootstrap/test_new_instance.py index e136579..dc3076e 100644 --- a/tests/bootstrap/test_new_instance.py +++ b/tests/bootstrap/test_new_instance.py @@ -39,6 +39,18 @@ def install_fietsboek(venv_path: Path) -> Path: return venv_path / "bin" +def create_config(config_name: Path): + """Copies the testing.ini config and fills in the placeholders. + + :param config_name: Path to the resulting config. + """ + shutil.copy(REPO_BASE / "testing.ini", config_name) + config = config_name.read_text() + config = config.replace("# %% fietsboek.data_dir %%", "fietsboek.data_dir = %(here)s/data") + config_name.write_text(config) + Path("data").mkdir() + + def test_setup_via_fietsupdate(tmpdir): with chdir(tmpdir): # We create a new temporary virtual environment with a fresh install, just @@ -47,8 +59,7 @@ def test_setup_via_fietsupdate(tmpdir): binaries_path = install_fietsboek(tmpdir / "venv") LOGGER.info("Creating a test configuration") - shutil.copy(REPO_BASE / "testing.ini", "testing.ini") - Path("data").mkdir() + create_config(Path("testing.ini")) # Try to run the migrations subprocess.check_call( |