Files
devplacepy/tests/e2e/admin/services/start.py
T
retoor 43f4011005 chore: reorganize test files into domain-specific subdirectories under tests/
Split the monolithic test directory into three tiers (unit, api, e2e) with a path-mirroring directory structure. Added corresponding Makefile targets (test-unit, test-api, test-e2e) and updated all documentation references (CLAUDE.md, README.md, testing-cicd.html, testing-framework.html, testing-make.html) to reflect the new layout and naming conventions.
2026-06-13 14:32:33 +00:00

29 lines
1.2 KiB
Python

# retoor <retoor@molodetz.nl>
from tests.conftest import BASE_URL, login_user
from devplacepy.database import get_table
def _promote_to_admin(username: str) -> None:
users = get_table("users")
user = users.find_one(username=username)
if user:
users.update({"uid": user["uid"], "role": "Admin"}, ["uid"])
def test_services_start_stop_toggles_enabled(page, seeded_db):
user = seeded_db["alice"]
_promote_to_admin(user["username"])
login_user(page, user)
page.goto(f"{BASE_URL}/admin/services", wait_until="domcontentloaded")
try:
assert page.request.post(f"{BASE_URL}/admin/services/news/stop").ok
data = page.request.get(f"{BASE_URL}/admin/services/data").json()
news = next(s for s in data["services"] if s["name"] == "news")
assert news["enabled"] is False
assert news["status"] == "stopped"
assert page.request.post(f"{BASE_URL}/admin/services/news/start").ok
data = page.request.get(f"{BASE_URL}/admin/services/data").json()
news = next(s for s in data["services"] if s["name"] == "news")
assert news["enabled"] is True
finally:
page.request.post(f"{BASE_URL}/admin/services/news/start")