# 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_unknown_returns_404(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")
    assert page.request.post(f"{BASE_URL}/admin/services/nope/stop").status == 404
