diff options
author | Daniel Schadt <kingdread@gmx.de> | 2022-12-20 20:17:59 +0100 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2022-12-20 20:17:59 +0100 |
commit | 7a60619d3f6fd523d42f50753436f3b7e7d72ca4 (patch) | |
tree | 5a5afe7dda6631100f2f52fac0d1935f7627026d /tests/conftest.py | |
parent | d5830f4000bf8f96d821fd3e93f04898af03132e (diff) | |
parent | 0e0a7e4326a592a6b99ad590e3397e6ddaeaf93a (diff) | |
download | fietsboek-7a60619d3f6fd523d42f50753436f3b7e7d72ca4.tar.gz fietsboek-7a60619d3f6fd523d42f50753436f3b7e7d72ca4.tar.bz2 fietsboek-7a60619d3f6fd523d42f50753436f3b7e7d72ca4.zip |
Merge branch 'gpx-exodus'
Diffstat (limited to 'tests/conftest.py')
-rw-r--r-- | tests/conftest.py | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/tests/conftest.py b/tests/conftest.py index 8f7f77c..a203775 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,7 +1,10 @@ +import os +import shutil +from pathlib import Path + import alembic import alembic.config import alembic.command -import os from pyramid.paster import get_appsettings from pyramid.scripting import prepare from pyramid.testing import DummyRequest, testConfig @@ -11,8 +14,8 @@ import webtest from sqlalchemy import delete, select -from fietsboek import main -from fietsboek import models +from fietsboek import main, models +from fietsboek.data import DataManager from fietsboek.models.meta import Base @@ -48,6 +51,21 @@ def dbengine(app_settings, ini_file): Base.metadata.drop_all(bind=engine) alembic.command.stamp(alembic_cfg, None, purge=True) +@pytest.fixture +def data_manager(app_settings): + return DataManager(Path(app_settings["fietsboek.data_dir"])) + +@pytest.fixture(autouse=True) +def _cleanup_data(app_settings): + yield + engine = models.get_engine(app_settings) + connection = engine.connect() + for table in reversed(Base.metadata.sorted_tables): + connection.execute(table.delete()) + data_dir = Path(app_settings["fietsboek.data_dir"]) + if (data_dir / "tracks").is_dir(): + shutil.rmtree(data_dir / "tracks") + @pytest.fixture(scope='session') def app(app_settings, dbengine, tmp_path_factory): app_settings["fietsboek.data_dir"] = str(tmp_path_factory.mktemp("data")) |