"""Shared test helpers built only on public endpoints.""" import uuid import httpx PASSWORD = "correct-horse-9" def bearer(token: str) -> dict[str, str]: return {"Authorization": f"Bearer {token}"} async def register(client: httpx.AsyncClient, *, role: str = "player", email: str | None = None) -> dict: """Creates an account; returns {"user", "tokens", "headers"}.""" email = email or f"{role}-{uuid.uuid4().hex[:10]}@example.com" response = await client.post("/v1/auth/register", json={"email": email, "password": PASSWORD, "role": role}) assert response.status_code == 201, response.text body = response.json() return {**body, "headers": bearer(body["tokens"]["access_token"])}