* add full integration test of cli / pytest_abra with all tests * save path of runner_*.py in runner subclass to improve test discovery -> allows for same test name in two different runners * reorganize output dir names * use URL fixture everywhere * rework coordinator interface * add --session_id to cli args * add log results table * plenty of refactoring * add assert messages * add plenty of tests * add /docs dir with plenty of documentation * fix authentik setup * add authentik cleanup, remove test user * add random test user credential generation and integrate into test routine. random creds are saved to STATES Reviewed-on: local-it-infrastructure/e2e_tests#16 Co-authored-by: Daniel <d.brummerloh@gmail.com> Co-committed-by: Daniel <d.brummerloh@gmail.com>
43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
import os
|
|
import shutil
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from pytest_abra.coordinator import Coordinator
|
|
from pytest_abra.dir_manager import DirManager
|
|
|
|
|
|
def test_load_test_credentials(tmp_path: Path):
|
|
assert "TEST_USER" not in os.environ
|
|
|
|
DIR = DirManager(output_dir=tmp_path, session_id="abc")
|
|
DIR.create_all_dirs()
|
|
|
|
Coordinator.load_test_credentials(DIR)
|
|
assert (DIR.STATES / "credentials_test.json").is_file()
|
|
|
|
assert "TEST_USER" in os.environ
|
|
test_user_before = os.environ["TEST_USER"]
|
|
|
|
# os.environ.clear() # this breaks pytest!
|
|
del os.environ["TEST_USER"]
|
|
assert "TEST_USER" not in os.environ
|
|
|
|
Coordinator.load_test_credentials(DIR)
|
|
assert test_user_before == os.environ["TEST_USER"]
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def tmp_recipes(tmp_path_factory: pytest.TempPathFactory) -> Path:
|
|
tmp_recipes_target = tmp_path_factory.mktemp("recipes")
|
|
recipes_dir_source = Path("recipes")
|
|
shutil.copytree(recipes_dir_source, tmp_recipes_target, dirs_exist_ok=True)
|
|
return tmp_recipes_target
|
|
|
|
|
|
def test_runner_runner_dict_import(tmp_recipes: Path):
|
|
"""import from recipes dict should work, because create_runner_dict has sys.path.append"""
|
|
|
|
RUNNER_DICT = Coordinator.create_runner_dict(tmp_recipes)
|
|
assert len(RUNNER_DICT.keys()) > 0
|