e2e_tests/recipes/nextcloud/tests_nextcloud/tests_nextcloud.py
Daniel d1ff1183a5 refactoring (#13)
* general project refactoring

* various small improvements

* improve imap fixture with helper functions and typing

* add wordpress send email setup

* add wordpress receive email test

* add various documentation

Reviewed-on: local-it-infrastructure/e2e_tests#13
Co-authored-by: Daniel <d.brummerloh@gmail.com>
Co-committed-by: Daniel <d.brummerloh@gmail.com>
2023-12-08 18:17:31 +01:00

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, env_config: dict[str, str]):
"""Tests if the quota set in .env file matches the actual quota shown on the page within 10%"""
if env_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 = env_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, env_config: dict[str, str]):
for app in env_config["nc_apps"]:
expect(nextcloud_admin_page.get_by_role("link", name=app)).to_be_visible()