Merge branch 'test-pytest-abra-rebase' into various
This commit is contained in:
commit
8868408793
4 changed files with 82 additions and 1 deletions
|
|
@ -9,6 +9,7 @@ from pytest_abra import BaseUrl, DirManager
|
|||
@pytest.fixture
|
||||
def authentik_admin_context(context: BrowserContext, DIR: DirManager) -> BrowserContext:
|
||||
state_file = DIR.STATES / "authentik_admin_state.json"
|
||||
assert state_file.is_file()
|
||||
storage_state = json.loads(state_file.read_bytes())
|
||||
context.add_cookies(storage_state["cookies"])
|
||||
return context
|
||||
|
|
@ -26,6 +27,7 @@ def authentik_admin_page(authentik_admin_context: BrowserContext, DIR: DirManage
|
|||
@pytest.fixture
|
||||
def authentik_user_context(context: BrowserContext, DIR: DirManager) -> BrowserContext:
|
||||
state_file = DIR.STATES / "authentik_user_state.json"
|
||||
assert state_file.is_file()
|
||||
storage_state = json.loads(state_file.read_bytes())
|
||||
context.add_cookies(storage_state["cookies"])
|
||||
return context
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ def test_authentik_blueprint_status(
|
|||
blueprints = api_request_context.get(URL.get("api/v3/managed/blueprints"))
|
||||
assert blueprints.ok
|
||||
blueprints_data = blueprints.json()
|
||||
ic(blueprints_data)
|
||||
# ic(blueprints_data)
|
||||
|
||||
# fake failed blueprint
|
||||
# blueprints_data["results"][10]["status"] = "failed"
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
import pytest
|
||||
from icecream import ic
|
||||
|
||||
from pytest_abra.custom_fixtures import Message
|
||||
|
||||
|
||||
@pytest.mark.skip
|
||||
def test_demo(imap_recent_messages: list[Message]):
|
||||
for message in imap_recent_messages:
|
||||
print(dir(message))
|
||||
|
|
|
|||
77
tests/test_pytest_abra.py
Normal file
77
tests/test_pytest_abra.py
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
import json
|
||||
import os
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def session_tmp_path_testout(tmp_path_factory: pytest.TempPathFactory) -> Path:
|
||||
return tmp_path_factory.mktemp("test_out")
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_abratest_cli_full_integration(session_tmp_path_testout: Path):
|
||||
"""run abratest against the dev instance"""
|
||||
|
||||
# --------------------- load credentials to env variables -------------------- #
|
||||
|
||||
cred_file = Path("credentials.json")
|
||||
with open(cred_file, "r") as f:
|
||||
CREDENTIALS = json.load(f)
|
||||
|
||||
for key, value in CREDENTIALS.items():
|
||||
os.environ[key] = value
|
||||
|
||||
# --------------------------------- env files -------------------------------- #
|
||||
|
||||
ENV_FILES_ROOT = Path("../envfiles").resolve()
|
||||
ENV_FILES = [
|
||||
ENV_FILES_ROOT / "login.test.dev.local-it.cloud.env", # authentik
|
||||
ENV_FILES_ROOT / "blog.test.dev.local-it.cloud.env", # wordpress
|
||||
ENV_FILES_ROOT / "files.test.dev.local-it.cloud.env", # nextcloud
|
||||
]
|
||||
ENV_PATHS = ";".join([x.as_posix() for x in ENV_FILES])
|
||||
|
||||
# ----------------------------------- dirs ----------------------------------- #
|
||||
|
||||
RECIPES_DIR = Path("../recipes").resolve()
|
||||
OUTPUT_DIR = Path("./test-output").resolve()
|
||||
# OUTPUT_DIR = session_tmp_path_testout.resolve()
|
||||
|
||||
# ------------------------------------ run ----------------------------------- #
|
||||
|
||||
result = subprocess.run(
|
||||
[
|
||||
"abratest",
|
||||
"--env_paths",
|
||||
ENV_PATHS,
|
||||
"--recipes_dir",
|
||||
RECIPES_DIR,
|
||||
"--output_dir",
|
||||
OUTPUT_DIR,
|
||||
],
|
||||
capture_output=True,
|
||||
)
|
||||
|
||||
with open(OUTPUT_DIR / "tempfile_stdout.txt", "w") as f:
|
||||
f.write(str(result.stdout))
|
||||
|
||||
with open(OUTPUT_DIR / "tempfile_stderr.txt", "w") as f:
|
||||
f.write(str(result.stderr))
|
||||
|
||||
# print(result)
|
||||
|
||||
assert result.returncode == 0
|
||||
|
||||
assert "failed" not in str(result.stdout)
|
||||
|
||||
# assert False
|
||||
|
||||
|
||||
# @pytest.mark.slow
|
||||
# def test_results_abra(session_tmp_path_testout: Path):
|
||||
# OUTPUT_DIR = Path("./test-output").resolve()
|
||||
# print(list(OUTPUT_DIR.rglob("*")))
|
||||
# assert False
|
||||
Loading…
Add table
Add a link
Reference in a new issue