32 lines
1.2 KiB
Python
32 lines
1.2 KiB
Python
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"""
|
|
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()
|