refactor for independent test dirs #7
1 changed files with 31 additions and 12 deletions
|
|
@ -1,13 +1,32 @@
|
|||
def test_nextcloud(nc_session):
|
||||
import re
|
||||
|
||||
import pytest
|
||||
from playwright.sync_api import Page, expect
|
||||
|
||||
|
||||
def test_nextcloud_quota(nextcloud_admin_page: Page, dotenv_config: dict[str, str]):
|
||||
"""Test Nextcloud"""
|
||||
context, page = nc_session
|
||||
# if page.query_selector('.close-icon'):
|
||||
# page.get_by_role("button", name="Close modal").click()
|
||||
if CONFIG.get("default_quota"):
|
||||
quota = int(
|
||||
page.get_by_role("listitem", name="Storage informations").get_by_role("link").inner_text().split()[3]
|
||||
)
|
||||
assert quota == CONFIG["default_quota"]
|
||||
for app in CONFIG["nc_apps"]:
|
||||
check_for(page.get_by_role("link", name=app))
|
||||
context.tracing.stop(path=f"{RECORDS}/nextcloud.zip")
|
||||
if dotenv_config.get("DEFAULT_QUOTA"):
|
||||
# get quota from website
|
||||
quota_string = nextcloud_admin_page.get_by_text(
|
||||
re.compile(r"\d*,\d .* \d*,\d")
|
||||
).inner_text() # "37,7 MB von 104,9 MB verwendet"
|
||||
out = re.search(r"\d*,\d .* (\d*,\d).", quota_string)
|
||||
out_number = out[1] # 104,9
|
||||
out_number = out_number.replace(",", ".")
|
||||
quota_website = float(out_number)
|
||||
|
||||
# get quota from env
|
||||
quota_config_string = dotenv_config["DEFAULT_QUOTA"] # "100 MB"
|
||||
assert "MB" in quota_config_string
|
||||
quota_config = float(quota_config_string.strip("MB"))
|
||||
|
||||
assert quota_website == pytest.approx(quota_config, rel=0.1) # within 10%
|
||||
else:
|
||||
pytest.skip("DEFAULT_QUOTA not defined in env file")
|
||||
|
||||
|
||||
@pytest.mark.skip
|
||||
def test_nextcloud_apps(nextcloud_admin_page: Page, dotenv_config: dict[str, str]):
|
||||
for app in dotenv_config["nc_apps"]:
|
||||
expect(nextcloud_admin_page.get_by_role("link", name=app)).to_be_visible()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue