Files
sales-trainer/backend/tests/test_analysis_progress.py
Macky f63f1867f5 feat: trial follow-up drills, persona progress UI, LLM timeout 180s
- social trial: silent/gone follow-up outcomes with localized notice
  variants; gone is always a loss with possibility-framed debrief
- gone marker persists across judge outages; retries stay on the
  deterministic loss path (no roleplay reopen)
- bounded analysis_progress persisted during persona generation,
  exposed via safe serializer, polled + rendered as accessible UI
- LLM HTTP timeout 105s -> 180s for Qwen 3.8 (enable_thinking off)
- demo-account test clock made relative to current UTC
- regression coverage: follow-up branches, judge-failure retry,
  progress callback, timeout contract, progress serializer
- independent review finding verified stale against final tree

Tests: 532 backend, 29 frontend, prod build green
2026-10-02 12:53:59 +07:00

36 lines
1.3 KiB
Python

from app.api.group_routes import _safe_analysis_progress, serialize_group
def test_analysis_progress_serializer_keeps_only_bounded_public_fields():
assert _safe_analysis_progress({
"stage": "personas",
"completed": 4,
"total": 15,
"prompt": "private prompt",
"provider_error": "/private/path",
}) == {"stage": "personas", "completed": 4, "total": 15}
def test_analysis_progress_serializer_rejects_invalid_or_unknown_state():
assert _safe_analysis_progress({"stage": "secret", "completed": 1, "total": 1}) == {}
assert _safe_analysis_progress({"stage": "personas", "completed": True, "total": 15}) == {}
assert _safe_analysis_progress({"stage": "personas", "completed": 16, "total": 15}) == {}
def test_group_serializer_exposes_sanitized_analysis_progress_only():
view = serialize_group({
"id": "group-1",
"status": "analyzing",
"analysis_progress": {
"stage": "report",
"completed": 0,
"total": 1,
"error": "private provider detail",
},
"worker_input": "must not leak",
}, {"role": "user"})
assert view["analysis_progress"] == {"stage": "report", "completed": 0, "total": 1}
assert "worker_input" not in view
assert "private provider detail" not in str(view)