add-resume (#12)
* add functionality to --resume flag. latest test will resume by running failed tests again * fix nextcloud setup -> all tests passing * fix expect timeout by moving it to its own fixture Reviewed-on: local-it-infrastructure/e2e_tests#12 Co-authored-by: Daniel <d.brummerloh@gmail.com> Co-committed-by: Daniel <d.brummerloh@gmail.com>
This commit is contained in:
parent
0b4e0a0c16
commit
41a042f07d
6 changed files with 33 additions and 6 deletions
1
main.py
1
main.py
|
|
@ -42,6 +42,7 @@ subprocess.run(
|
||||||
RECIPES_DIR,
|
RECIPES_DIR,
|
||||||
"--output_dir",
|
"--output_dir",
|
||||||
OUTPUT_DIR,
|
OUTPUT_DIR,
|
||||||
|
"--resume",
|
||||||
# "--debug",
|
# "--debug",
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,9 @@ def run():
|
||||||
|
|
||||||
session_id = "test-" + get_datetime_string()
|
session_id = "test-" + get_datetime_string()
|
||||||
if args.resume:
|
if args.resume:
|
||||||
# look for previous session_id
|
latest_session_id = DirManager.get_latest_session_id(args.output_dir)
|
||||||
pass
|
if latest_session_id:
|
||||||
# session_id = "abc"
|
session_id = DirManager.get_latest_session_id(args.output_dir)
|
||||||
|
|
||||||
# ------------------------------- setup logging ------------------------------ #
|
# ------------------------------- setup logging ------------------------------ #
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,12 @@ from pytest_abra.utils import rmtree
|
||||||
|
|
||||||
class Coordinator:
|
class Coordinator:
|
||||||
def __init__(
|
def __init__(
|
||||||
self, env_paths_list: list[Path], output_dir: Path, session_id: str, recipes_dir: Path, timeout: int
|
self,
|
||||||
|
env_paths_list: list[Path],
|
||||||
|
output_dir: Path,
|
||||||
|
session_id: str,
|
||||||
|
recipes_dir: Path,
|
||||||
|
timeout: int,
|
||||||
) -> None:
|
) -> None:
|
||||||
# logging
|
# logging
|
||||||
out_string = "".join([e.name + "\n" for e in env_paths_list])
|
out_string = "".join([e.name + "\n" for e in env_paths_list])
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
from dotenv import dotenv_values
|
from dotenv import dotenv_values
|
||||||
|
|
||||||
|
|
@ -76,3 +77,13 @@ class DirManager:
|
||||||
env_file = next(self.ENV_FILES.glob(f"*{search_string}*"))
|
env_file = next(self.ENV_FILES.glob(f"*{search_string}*"))
|
||||||
config: dict[str, str] = dotenv_values(env_file) # type: ignore
|
config: dict[str, str] = dotenv_values(env_file) # type: ignore
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_latest_session_id(output_dir: Path) -> Optional[str]:
|
||||||
|
"""returns the name of the newest dir inside of output_dir"""
|
||||||
|
all_dirs = [d for d in output_dir.iterdir() if d.is_dir()]
|
||||||
|
if all_dirs:
|
||||||
|
newest_dir: Path = max(all_dirs, key=lambda x: x.stat().st_ctime)
|
||||||
|
return newest_dir.name
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,12 @@ def pytest_addoption(parser: Parser):
|
||||||
parser.addoption("--timeout", action="store", type=int, default=20_000)
|
parser.addoption("--timeout", action="store", type=int, default=20_000)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(autouse=True)
|
||||||
|
def set_expect_timeout(request):
|
||||||
|
TIMEOUT = request.config.getoption("--timeout")
|
||||||
|
expect.set_options(timeout=TIMEOUT)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def context(context: BrowserContext, request) -> BrowserContext:
|
def context(context: BrowserContext, request) -> BrowserContext:
|
||||||
# note: because this has the existing context fixture as an argument, it is ensured
|
# note: because this has the existing context fixture as an argument, it is ensured
|
||||||
|
|
@ -33,7 +39,6 @@ def context(context: BrowserContext, request) -> BrowserContext:
|
||||||
|
|
||||||
context.set_default_timeout(TIMEOUT)
|
context.set_default_timeout(TIMEOUT)
|
||||||
context.set_extra_http_headers(LOCALE)
|
context.set_extra_http_headers(LOCALE)
|
||||||
expect.set_options(timeout=TIMEOUT)
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import re
|
||||||
|
|
||||||
from playwright.sync_api import Page, expect
|
from playwright.sync_api import Page, expect
|
||||||
|
|
||||||
from pytest_abra.dir_manager import DirManager
|
from pytest_abra.dir_manager import DirManager
|
||||||
|
|
@ -16,6 +18,9 @@ def setup_nextcloud_admin_session(authentik_admin_page: Page, DIR: DirManager, U
|
||||||
page_nextcloud = event_context.value
|
page_nextcloud = event_context.value
|
||||||
context = page_nextcloud.context
|
context = page_nextcloud.context
|
||||||
|
|
||||||
|
# expect quota stats on files page to confirm successful login
|
||||||
page_nextcloud.goto(URL.get("/apps/files"))
|
page_nextcloud.goto(URL.get("/apps/files"))
|
||||||
expect(page_nextcloud.get_by_role("link", name="Name")).to_be_visible()
|
quota_pattern = re.compile(r"\d*,\d .* (\d*,\d).")
|
||||||
|
expect(page_nextcloud.get_by_text(quota_pattern)).to_be_visible()
|
||||||
|
|
||||||
context.storage_state(path=DIR.STATES / "nextcloud_admin_state.json")
|
context.storage_state(path=DIR.STATES / "nextcloud_admin_state.json")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue