Files
ilia 66818f500b
CI / secret-scan (pull_request) Successful in 32s
CI / python-ci (pull_request) Successful in 1m9s
Cap uploads, GC empty boards, drop classic UI
Close residual audit P2: 5 MiB recording limit, opportunistic orphan
board GC, and remove static/index.html.
2026-08-07 21:12:47 -04:00

50 lines
1.5 KiB
Python

"""Shared fixtures for Stork API tests."""
from __future__ import annotations
import importlib
from pathlib import Path
import pytest
from fastapi.testclient import TestClient
@pytest.fixture()
def client(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> TestClient:
monkeypatch.setenv("STORK_DATA", str(tmp_path / "data"))
monkeypatch.setenv("STORK_INVITE_TOKEN", "test-invite-token")
monkeypatch.setenv("STORK_ADMIN_TOKEN", "test-admin-token")
monkeypatch.setenv("STORK_COOKIE_SECURE", "false")
monkeypatch.delenv("STORK_READONLY_BOARD_IDS", raising=False)
monkeypatch.delenv("STORK_RL_BOARDS_PER_HOUR", raising=False)
monkeypatch.delenv("STORK_MAX_UPLOAD_BYTES", raising=False)
monkeypatch.delenv("STORK_ORPHAN_BOARD_HOURS", raising=False)
import stork.app as app_mod
import stork.rate_limit as rl_mod
importlib.reload(rl_mod)
importlib.reload(app_mod)
app_mod.limiter.reset()
with TestClient(app_mod.app) as test_client:
yield test_client
app_mod.store.close()
@pytest.fixture()
def family_board(client: TestClient) -> dict:
"""Bootstrap Family board id (from STORK_INVITE_TOKEN)."""
res = client.get("/api/resolve", params={"invite": "test-invite-token"})
assert res.status_code == 200
return res.json()
@pytest.fixture()
def authed(client: TestClient, family_board: dict) -> TestClient:
res = client.post(
"/api/session",
json={"board_id": family_board["id"], "display_name": "Aunt Mira"},
)
assert res.status_code == 200
return client