* make it so that the actual tests can be moved anywhere, for example in abra recipe repos -> major refactoring with pytest test discovery magic * create RUNNER_DICT dynamically with importlib -> none of the tests are hardcoded, more tests can be added by placing a folder * autoload fixtures with pytest plugins * add URL fixture to navigate on web pages. Includes url parser based on python urllib to generate correct links * fix nextcloud setups and tests * add email groundwork with imbox Reviewed-on: local-it-infrastructure/e2e_tests#7 Co-authored-by: Daniel <d.brummerloh@gmail.com> Co-committed-by: Daniel <d.brummerloh@gmail.com>
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()
|