Files
devplacepy/tests/api/admin/game.py
T
retoorandClaude Sonnet 5.5 1a9201cb91 Admin pages: one shared specification, builders, fragments, caps and live refresh
Adds admin_sections registry, shared admin partials, WorkspaceList, admin CLAUDE.md spec,
capped node/flag listings, and api/unit tests enforcing the spec.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-15 01:50:50 +01:00

34 lines
1.1 KiB
Python

# retoor <retoor@molodetz.nl>
import re
import requests
from tests.conftest import BASE_URL
from devplacepy.database import get_table, refresh_snapshot
JSON = {"Accept": "application/json"}
HTML = {"Accept": "text/html"}
def _admin(seeded_db):
refresh_snapshot()
key = get_table("users").find_one(username="alice_test")["api_key"]
session = requests.Session()
session.headers.update({"X-API-KEY": key})
return session
def test_game_admin_json_face(seeded_db):
r = _admin(seeded_db).get(f"{BASE_URL}/admin/game", headers=JSON)
assert r.status_code == 200, r.text[:300]
assert "era_active" in r.json()
def test_game_admin_uses_the_admin_vocabulary(seeded_db):
r = _admin(seeded_db).get(f"{BASE_URL}/admin/game", headers=HTML)
assert r.status_code == 200
assert "admin-btn" in r.text
content = r.text.split('<main class="admin-content">', 1)[1].split("</main>", 1)[0]
tokens = {name for value in re.findall(r'class="([^"]*)"', content) for name in value.split()}
assert not tokens & {"btn", "btn-primary", "btn-danger", "hint-text"}