* 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>
54 lines
1.8 KiB
Python
54 lines
1.8 KiB
Python
import re
|
|
import time
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from pytest_abra import DirManager
|
|
from pytest_abra.utils import get_session_id
|
|
|
|
|
|
def test_get_session_id_random(tmp_path: Path):
|
|
args_output_dir = tmp_path
|
|
args_resume = False
|
|
args_session_id = None
|
|
session_id = get_session_id(args_output_dir, args_resume, args_session_id)
|
|
assert re.search(r"\d+-\d+-\d+", session_id)
|
|
|
|
|
|
def test_get_session_id_explicit1(tmp_path: Path):
|
|
args_output_dir = tmp_path
|
|
args_resume = False
|
|
args_session_id = "abc"
|
|
session_id = get_session_id(args_output_dir, args_resume, args_session_id)
|
|
assert session_id == "abc"
|
|
|
|
|
|
def test_get_session_id_explicit2(tmp_path: Path):
|
|
args_output_dir = tmp_path
|
|
args_resume = True
|
|
args_session_id = "abc"
|
|
session_id = get_session_id(args_output_dir, args_resume, args_session_id)
|
|
assert session_id == "abc"
|
|
|
|
|
|
@pytest.mark.slow
|
|
def test_get_session_id_integration(tmp_path: Path):
|
|
assert len(list(tmp_path.iterdir())) == 0
|
|
session_id_1 = get_session_id(args_output_dir=tmp_path, args_resume=False, args_session_id=None)
|
|
|
|
DIR = DirManager(output_dir=tmp_path, session_id=session_id_1)
|
|
DIR.create_all_dirs()
|
|
assert len(list(tmp_path.iterdir())) == 1
|
|
|
|
time.sleep(1.1) # get_session_id won't be unique if called without time passed
|
|
session_id_2 = get_session_id(args_output_dir=tmp_path, args_resume=False, args_session_id=None)
|
|
DIR = DirManager(output_dir=tmp_path, session_id=session_id_2)
|
|
DIR.create_all_dirs()
|
|
assert len(list(tmp_path.iterdir())) == 2
|
|
|
|
session_id_3 = get_session_id(args_output_dir=tmp_path, args_resume=True, args_session_id=None)
|
|
assert session_id_2 == session_id_3
|
|
|
|
session_id_4 = get_session_id(args_output_dir=tmp_path, args_resume=True, args_session_id="abc")
|
|
assert session_id_4 == "abc"
|