[WIP] Add new automated test framework (#1)

Co-authored-by: Daniel <d.brummerloh@gmail.com>
Co-committed-by: Daniel <d.brummerloh@gmail.com>
This commit is contained in:
Daniel 2023-11-22 21:40:13 +01:00 committed by dan
parent 859bd57006
commit 97ed87c79f
31 changed files with 769 additions and 6 deletions

64
src/conftest.py Normal file
View file

@ -0,0 +1,64 @@
# regarding conftest:
# If you have conftest.py files which do not reside in a python package directory
# (i.e. one containing an __init__.py) then “import conftest” can be ambiguous
# because there might be other conftest.py files as well on your PYTHONPATH or
# sys.path. It is thus good practise for projects to either put conftest.py under
# a package scope or to never import anything from a conftest.py file.
from pathlib import Path
import pytest
from dirmanager import DirManager
from dotenv import dotenv_values
pytest_plugins = [
"setup.setup_authentik",
]
def pytest_addoption(parser):
parser.addoption(
"--env_file",
action="store",
)
parser.addoption(
"--tests_dir",
action="store",
)
parser.addoption(
"--session_id",
action="store",
)
@pytest.fixture(scope="session", autouse=True)
def dirmanager(request) -> DirManager:
tests_dir = request.config.getoption("--tests_dir")
tests_dir = Path(tests_dir)
session_id = request.config.getoption("--session_id")
return DirManager(tests_dir=tests_dir, session_id=session_id)
@pytest.fixture(scope="session", autouse=True)
def dotenv_config(request) -> dict[str, str]:
dotenv_path = request.config.getoption("--env_file")
dotenv_path = Path(dotenv_path)
assert dotenv_path.is_file()
return dotenv_values(dotenv_path)
@pytest.fixture(scope="session", autouse=True)
def RECORDS(dirmanager) -> Path:
assert isinstance(dirmanager, DirManager)
return dirmanager.dirs["records"]
@pytest.fixture(scope="session", autouse=True)
def STATES(dirmanager) -> Path:
return dirmanager.dirs["states"]
@pytest.fixture(scope="session", autouse=True)
def RESULTS(dirmanager) -> Path:
return dirmanager.dirs["results"]