FastAPI backend (port 8522):
- Session lifecycle: POST /session/start, DELETE /session/{id}/end, GET /session/{id}
- SSE stream: GET /session/{id}/stream — per-subscriber asyncio.Queue fan-out, 15s heartbeat
- History: GET /session/{id}/history with min_confidence + limit filters
- Audio: WS /session/{id}/audio — binary PCM ingestion stub (real inference in v0.2.x)
- Export: GET /session/{id}/export — downloadable JSON session log
- ContextClassifier background task per session (CF_VOICE_MOCK=1 in dev)
- ToneEvent SSE wire format per cf-core#40 (locked field names)
- Tier gate: CFG-LNNT- prefix check, 402 for paid features
Vue 3 frontend (port 8521, Vite + UnoCSS + Pinia):
- NowPanel: affect-aware border tint, subtext, prosody flags, shift indicator
- HistoryStrip: horizontal scroll, last 8 events with affect color
- ComposeBar: start/stop session, SSE connection lifecycle
- useToneStream: EventSource composable
- useAudioCapture: AudioWorklet → Int16 PCM → WebSocket (v0.1.x stub)
- audio-processor.js: 100ms chunk accumulator in AudioWorklet thread
- Respects prefers-reduced-motion globally
26 tests passing, manage.sh, Dockerfile, compose.yml included.
74 lines
2.1 KiB
Python
74 lines
2.1 KiB
Python
# tests/test_session_lifecycle.py — session CRUD + history/export endpoints
|
|
from __future__ import annotations
|
|
|
|
|
|
def test_start_session(client):
|
|
resp = client.post("/session/start")
|
|
assert resp.status_code == 200
|
|
body = resp.json()
|
|
assert "session_id" in body
|
|
assert body["state"] == "running"
|
|
assert body["elcor"] is False
|
|
|
|
|
|
def test_start_session_elcor(client):
|
|
resp = client.post("/session/start", json={"elcor": True})
|
|
assert resp.status_code == 200
|
|
assert resp.json()["elcor"] is True
|
|
|
|
|
|
def test_get_session(client, session_id):
|
|
resp = client.get(f"/session/{session_id}")
|
|
assert resp.status_code == 200
|
|
assert resp.json()["session_id"] == session_id
|
|
|
|
|
|
def test_get_session_not_found(client):
|
|
resp = client.get("/session/no-such-session")
|
|
assert resp.status_code == 404
|
|
|
|
|
|
def test_end_session(client, session_id):
|
|
resp = client.delete(f"/session/{session_id}/end")
|
|
assert resp.status_code == 200
|
|
assert resp.json()["state"] == "stopped"
|
|
|
|
|
|
def test_end_session_not_found(client):
|
|
resp = client.delete("/session/ghost/end")
|
|
assert resp.status_code == 404
|
|
|
|
|
|
def test_history_empty(client, session_id):
|
|
resp = client.get(f"/session/{session_id}/history")
|
|
assert resp.status_code == 200
|
|
body = resp.json()
|
|
assert body["count"] == 0
|
|
assert body["events"] == []
|
|
|
|
|
|
def test_history_not_found(client):
|
|
resp = client.get("/session/ghost/history")
|
|
assert resp.status_code == 404
|
|
|
|
|
|
def test_export_empty(client, session_id):
|
|
resp = client.get(f"/session/{session_id}/export")
|
|
assert resp.status_code == 200
|
|
assert resp.headers["content-type"].startswith("application/json")
|
|
assert "attachment" in resp.headers["content-disposition"]
|
|
import json
|
|
body = json.loads(resp.content)
|
|
assert body["session_id"] == session_id
|
|
assert body["events"] == []
|
|
|
|
|
|
def test_export_not_found(client):
|
|
resp = client.get("/session/ghost/export")
|
|
assert resp.status_code == 404
|
|
|
|
|
|
def test_health(client):
|
|
resp = client.get("/health")
|
|
assert resp.status_code == 200
|
|
assert resp.json()["status"] == "ok"
|