from pathlib import Path ROOT = Path(__file__).resolve().parents[2] MAIN = ROOT / "apps" / "web" / "vue3" / "main.py" MAIN_SOURCE = MAIN.read_text(encoding="utf-8") def _rag_routes() -> str: start = MAIN_SOURCE.index('@app.post("/api/agent/rag")') end = MAIN_SOURCE.index("# ==================== DiagnosisAgent API", start) return MAIN_SOURCE[start:end] def test_rag_proxy_has_no_inline_150_second_timeout() -> None: routes = _rag_routes() assert "timeout=150.0" not in routes assert "complete QA exceeded 150 seconds" not in routes assert "完整知识图谱问答超过 150 秒" not in routes def test_rag_stream_proxy_preserves_upstream_sse_frames() -> None: routes = _rag_routes() assert "for frame in stream_dual_kb_qa(" in routes assert "yield frame" in routes assert 'media_type="text/event-stream"' in routes