various (#16)
* 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>
This commit is contained in:
parent
016b88a68d
commit
2dd765a974
36 changed files with 1145 additions and 432 deletions
|
|
@ -3,7 +3,8 @@
|
|||
|
||||
import os
|
||||
import re
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
# from datetime import datetime, timedelta
|
||||
from pathlib import Path
|
||||
from typing import Generator, Protocol, TypedDict
|
||||
|
||||
|
|
@ -11,7 +12,7 @@ import pytest
|
|||
from dotenv import dotenv_values
|
||||
from icecream import ic # type: ignore
|
||||
from imbox import Imbox # type: ignore
|
||||
from playwright.sync_api import APIRequestContext, BrowserContext, Playwright, expect
|
||||
from playwright.sync_api import BrowserContext, expect
|
||||
from pytest import Parser
|
||||
|
||||
from pytest_abra import BaseUrl, DirManager, EnvFile
|
||||
|
|
@ -49,9 +50,9 @@ def DIR(request) -> DirManager:
|
|||
|
||||
DIR.OUTPUT
|
||||
DIR.SESSION
|
||||
DIR.RECORDS
|
||||
DIR.STATES
|
||||
DIR.RESULTS"""
|
||||
DIR.RESULTS
|
||||
DIR.STATUS"""
|
||||
|
||||
output_dir = request.config.getoption("--output_dir")
|
||||
assert output_dir, "pytest argument --output_dir not set"
|
||||
|
|
@ -93,13 +94,13 @@ def URL(env_config: dict[str, str]) -> BaseUrl:
|
|||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def imap_client() -> None:
|
||||
def imap_client() -> Generator[Imbox, None, None]:
|
||||
"""imap email client using credentials from environment variables"""
|
||||
|
||||
assert os.environ["IMAP_HOST"]
|
||||
assert os.environ["IMAP_PORT"]
|
||||
assert os.environ["IMAP_USER"]
|
||||
assert os.environ["IMAP_PASS"]
|
||||
assert os.environ["IMAP_HOST"], "required environment variable is undefined"
|
||||
assert os.environ["IMAP_PORT"], "required environment variable is undefined"
|
||||
assert os.environ["IMAP_USER"], "required environment variable is undefined"
|
||||
assert os.environ["IMAP_PASS"], "required environment variable is undefined"
|
||||
|
||||
imbox = Imbox(
|
||||
hostname=os.environ["IMAP_HOST"],
|
||||
|
|
@ -138,9 +139,8 @@ def imap_recent_messages(imap_client: Imbox) -> list[Message]:
|
|||
for uid, message in messages:
|
||||
print(uid, message.subject, message.date)"""
|
||||
|
||||
N_MINUTES = 30
|
||||
|
||||
n_minutes_ago = datetime.now() - timedelta(minutes=N_MINUTES)
|
||||
# N_MINUTES = 30
|
||||
# n_minutes_ago = datetime.now() - timedelta(minutes=N_MINUTES)
|
||||
uids: list[bytes] = []
|
||||
messages: list[Message] = []
|
||||
# for uid, message in imap_client.messages(date__gt=n_minutes_ago):
|
||||
|
|
@ -150,14 +150,3 @@ def imap_recent_messages(imap_client: Imbox) -> list[Message]:
|
|||
messages.append(message)
|
||||
|
||||
return messages
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def api_request_context(
|
||||
playwright: Playwright,
|
||||
DIR: DirManager,
|
||||
) -> Generator[APIRequestContext, None, None]:
|
||||
state_file = DIR.STATES / "authentik_admin_state.json"
|
||||
request_context = playwright.request.new_context(storage_state=state_file)
|
||||
yield request_context
|
||||
request_context.dispose()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue