Skip to content

DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.

fix: repair v1.4.6 CI failures (lint + RAG/partner test isolation)

Bingxi Zhao (Frank)7d3a06ca8f15
diff --git a/deeptutor/api/routers/partners.py b/deeptutor/api/routers/partners.py
index 4f7062561..154b1ac8a 100644
--- a/deeptutor/api/routers/partners.py
+++ b/deeptutor/api/routers/partners.py
@@ -912,6 +912,7 @@ async def partner_chat_ws(ws: WebSocket, partner_id: str):
if user_token is ws_auth_failed:
return
+ mgr = get_partner_manager()
disconnected = asyncio.Event()
async def _safe_send(payload: dict) -> bool:
diff --git a/tests/api/test_partners_router.py b/tests/api/test_partners_router.py
index 671bac928..45734767e 100644
--- a/tests/api/test_partners_router.py
+++ b/tests/api/test_partners_router.py
@@ -222,10 +222,15 @@ class TestHistory:
class TestChatAttachments:
def test_chat_does_not_auto_start_stopped_partner(self, client):
- assert _create(client, start=True).status_code == 200
- assert client.post("/api/v1/partners/ada/stop").status_code == 200
-
- res = client.post("/api/v1/partners/ada/chat", json={"content": "hello"})
+ # ``start=True`` spawns a real PartnerRunner task; drive every request
+ # through one shared event loop (context-managed TestClient) so the
+ # runner started by create can be cancelled by stop — otherwise each
+ # request runs on its own loop and the cancel raises a cross-loop error.
+ with client:
+ assert _create(client, start=True).status_code == 200
+ assert client.post("/api/v1/partners/ada/stop").status_code == 200
+
+ res = client.post("/api/v1/partners/ada/chat", json={"content": "hello"})
assert res.status_code == 409
from deeptutor.core.i18n import t
diff --git a/tests/services/rag/test_graphrag_pipeline.py b/tests/services/rag/test_graphrag_pipeline.py
index 0f6cd11a7..dd12867aa 100644
--- a/tests/services/rag/test_graphrag_pipeline.py
+++ b/tests/services/rag/test_graphrag_pipeline.py
@@ -261,6 +261,19 @@ def _stub_build(monkeypatch) -> list[dict]:
(out / "entities.parquet").write_bytes(b"")
monkeypatch.setattr(engine, "build", fake_build)
+
+ # initialize() -> write_settings() resolves the active chat + embedding
+ # models from the catalog; CI has none configured, so pin fakes here so the
+ # settings.yaml write succeeds. The build_settings <-> catalog bridge itself
+ # is covered by the test_build_settings_* tests above.
+ monkeypatch.setattr(
+ "deeptutor.services.config.resolve_llm_runtime_config",
+ lambda: _Cfg("gpt-4o-mini", "https://llm.test/v1", "sk-llm"),
+ )
+ monkeypatch.setattr(
+ "deeptutor.services.embedding.get_embedding_config",
+ lambda: _Cfg("emb-model", "https://emb.test/v1", "sk-emb"),
+ )
return calls
diff --git a/tests/services/rag/test_pageindex_pipeline.py b/tests/services/rag/test_pageindex_pipeline.py
index 9d3bf066d..22cb81551 100644
--- a/tests/services/rag/test_pageindex_pipeline.py
+++ b/tests/services/rag/test_pageindex_pipeline.py
@@ -147,7 +147,14 @@ def test_delete_drops_cloud_docs_and_local_dir(tmp_path) -> None:
assert not (tmp_path / "kb").exists()
-def test_factory_dispatches_by_provider(tmp_path) -> None:
+def test_factory_dispatches_by_provider(tmp_path, monkeypatch) -> None:
+ # Constructing a real LlamaIndexPipeline resolves the active embedding model
+ # from the catalog; CI has none, so stub the settings hook (the same way the
+ # llamaindex pipeline tests do) — this test only asserts factory routing.
+ from deeptutor.services.rag.pipelines.llamaindex.pipeline import LlamaIndexPipeline
+
+ monkeypatch.setattr(LlamaIndexPipeline, "_configure_settings", lambda self: None)
+
assert (
type(get_pipeline("pageindex", kb_base_dir=str(tmp_path))).__name__ == "PageIndexPipeline"
)