From 28b1af57a664aa87f7907c090651106a5848ae1c Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 6 Dec 2023 23:26:20 +0100 Subject: [PATCH] add more arguments and move everything from cli to main --- main.py | 27 +++++++++++++++++++++++++++ pytest_abra/cli.py | 32 +++++++++++--------------------- 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/main.py b/main.py index f91d0e3..84017e0 100644 --- a/main.py +++ b/main.py @@ -12,10 +12,37 @@ with open(cred_file, "r") as f: for key, value in CREDENTIALS.items(): os.environ[key] = value +# --------------------------------- env files -------------------------------- # + +# This list of env files is the input to testing framework. each env file +# triggers the execution of one test Runner and provides configuration to the +# tests inside the runner. + +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() + + +# exit() subprocess.run( [ "pytest-abra", + "--env_paths", + ENV_PATHS, + "--recipes_dir", + RECIPES_DIR, + "--output_dir", + OUTPUT_DIR, # "--debug", ] ) diff --git a/pytest_abra/cli.py b/pytest_abra/cli.py index 3d98853..5d1d414 100644 --- a/pytest_abra/cli.py +++ b/pytest_abra/cli.py @@ -11,32 +11,22 @@ from pytest_abra.utils import get_datetime_string def run(): parser = argparse.ArgumentParser() + parser.add_argument("--env_paths", type=str, help="List of loaded env files separated with ;") + parser.add_argument("--recipes_dir", type=str, help="List of loaded env files separated with ;") + parser.add_argument("--output_dir", type=str, help="List of loaded env files separated with ;") + parser.add_argument("--debug", action="store_true", help="Enable Playwright debug mode") - parser.add_argument("--repeat", action="store_true", help="Re-run the most recent test") + parser.add_argument( + "--resume", action="store_true", help="Re-run the most recent test, only running tests without status 'passed'" + ) args = parser.parse_args() - # ----------------------------- lookup env files ----------------------------- # - - # This list of env files is the input to testing framework. each env file - # triggers the execution of one test Runner and provides configuration to the - # tests inside the runner. There can be dependencies, for example wordpress - # requires that authentik ran first to create the admin session and the user - # session. At the moment, wrong ordering results in unsuccessful test - # (wrong ordering would be wordpress env file is before authentik env file). - # At the moment, functionailty is only guaranteed if each env file use - # a unique TYPE var. - - 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_FILES = [Path(s) for s in args.env_paths.split(";")] # ----------------------------- define ouptut dir ---------------------------- # - OUTPUT_DIR = Path("./test-output").resolve() - RECIPES_DIR = Path("../recipes").resolve() + RECIPES_DIR = Path(args.recipes_dir) + OUTPUT_DIR = Path(args.output_dir) # -------------------------- enable playwright debug ------------------------- # @@ -46,7 +36,7 @@ def run(): # ----------------------------- define session_id ---------------------------- # session_id = "test-" + get_datetime_string() - if args.repeat: + if args.resume: # look for previous session_id pass # session_id = "abc"