wip test_pytest_abra
This commit is contained in:
parent
68a810a808
commit
ed403954b6
1 changed files with 69 additions and 0 deletions
69
tests/test_pytest_abra.py
Normal file
69
tests/test_pytest_abra.py
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
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_pytest_abra(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,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
assert result.returncode == 0
|
||||||
|
|
||||||
|
assert "failed" not in str(result.stdout)
|
||||||
|
|
||||||
|
with open(OUTPUT_DIR / "tempfile.txt", "w") as f:
|
||||||
|
f.write(str(result.stdout))
|
||||||
|
|
||||||
|
|
||||||
|
# @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