19 lines
539 B
Python
19 lines
539 B
Python
|
|
"""Shared test helpers for BadNote tests."""
|
||
|
|
|
||
|
|
from httpx import AsyncClient
|
||
|
|
|
||
|
|
|
||
|
|
async def register_and_login(client: AsyncClient) -> tuple[str, str]:
|
||
|
|
"""Helper: register a user and return (token, user_id)."""
|
||
|
|
resp = await client.post(
|
||
|
|
"/api/auth/register",
|
||
|
|
json={"username": "testuser", "password": "testpass123"},
|
||
|
|
)
|
||
|
|
data = resp.json()
|
||
|
|
return data["token"], data["user_id"]
|
||
|
|
|
||
|
|
|
||
|
|
def auth_header(token: str) -> dict:
|
||
|
|
"""Return Authorization header dict."""
|
||
|
|
return {"Authorization": f"Bearer {token}"}
|