add api testing (#14)
* add fixture to make api calls with authentification * add authentik test that checks the status of all blueprints * add option to append any kind of data to html report Reviewed-on: local-it-infrastructure/e2e_tests#14 Co-authored-by: Daniel <d.brummerloh@gmail.com> Co-committed-by: Daniel <d.brummerloh@gmail.com>
This commit is contained in:
parent
d1ff1183a5
commit
873bf73ae8
8 changed files with 89 additions and 19 deletions
|
|
@ -1,5 +1,6 @@
|
|||
from pytest_abra.coordinator import Coordinator
|
||||
from pytest_abra.dir_manager import DirManager
|
||||
from pytest_abra.env_manager import EnvFile
|
||||
from pytest_abra.runner import ConditionArgs, Runner, Test
|
||||
from pytest_abra.utils import BaseUrl
|
||||
|
||||
|
|
@ -10,4 +11,5 @@ __all__ = [
|
|||
"Test",
|
||||
"DirManager",
|
||||
"BaseUrl",
|
||||
"EnvFile",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -5,18 +5,16 @@ import os
|
|||
import re
|
||||
from datetime import datetime, timedelta
|
||||
from pathlib import Path
|
||||
from typing import Protocol, TypedDict
|
||||
from typing import Generator, Protocol, TypedDict
|
||||
|
||||
import pytest
|
||||
from dotenv import dotenv_values
|
||||
from icecream import ic
|
||||
from icecream import ic # type: ignore
|
||||
from imbox import Imbox # type: ignore
|
||||
from playwright.sync_api import BrowserContext, expect
|
||||
from playwright.sync_api import APIRequestContext, BrowserContext, Playwright, expect
|
||||
from pytest import Parser
|
||||
|
||||
from pytest_abra.dir_manager import DirManager
|
||||
from pytest_abra.env_manager import EnvFile
|
||||
from pytest_abra.utils import BaseUrl
|
||||
from pytest_abra import BaseUrl, DirManager, EnvFile
|
||||
|
||||
|
||||
def pytest_addoption(parser: Parser):
|
||||
|
|
@ -152,3 +150,14 @@ 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()
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import os
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, Callable, NamedTuple
|
||||
|
|
@ -134,7 +135,6 @@ class Runner:
|
|||
# command_arguments.append("--traceconfig")
|
||||
|
||||
command_arguments.append("-v")
|
||||
# command_arguments.append("-rx")
|
||||
command_arguments.append(str(full_test_path))
|
||||
|
||||
command_arguments.append("--runner_index")
|
||||
|
|
@ -158,12 +158,13 @@ class Runner:
|
|||
command_arguments.append(str(self.DIR.RECORDS / "traces" / full_test_path.stem))
|
||||
|
||||
# tracing
|
||||
command_arguments.append("--tracing")
|
||||
command_arguments.append("--tracing") # "on", "off", "retain-on-failure"
|
||||
command_arguments.append("retain-on-failure")
|
||||
# command_arguments.append("on")
|
||||
|
||||
# Disable capturing. With -s set, prints will go to console as if pytest is not there.
|
||||
# command_arguments.append("-s")
|
||||
if os.environ.get("PWDEBUG") == "1":
|
||||
command_arguments.append("-s")
|
||||
command_arguments.append("-s")
|
||||
|
||||
# headed
|
||||
# command_arguments.append("--headed")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue