aboutsummaryrefslogtreecommitdiff
path: root/tests/conftest.py
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2022-12-15 23:23:14 +0100
committerDaniel Schadt <kingdread@gmx.de>2022-12-15 23:23:14 +0100
commitf431d0d82ddfd38f9a7e53042070a7e49ee67019 (patch)
tree464bd1670fea37c58c376b5337ceb41f9c39cb2e /tests/conftest.py
parent262b7d43a34af8ca6097b2e1874e6eb8ffefe185 (diff)
downloadfietsboek-f431d0d82ddfd38f9a7e53042070a7e49ee67019.tar.gz
fietsboek-f431d0d82ddfd38f9a7e53042070a7e49ee67019.tar.bz2
fietsboek-f431d0d82ddfd38f9a7e53042070a7e49ee67019.zip
fix integration & playwright tests
Diffstat (limited to 'tests/conftest.py')
-rw-r--r--tests/conftest.py24
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"))