DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
test(lightrag): isolate role configuration in offline fixtures
NoxsMedia1eaa27e4f3b2
diff --git a/tests/knowledge/test_document_adder_provider.py b/tests/knowledge/test_document_adder_provider.pyindex 702a8379f..f16e5e4b2 100644--- a/tests/knowledge/test_document_adder_provider.py+++ b/tests/knowledge/test_document_adder_provider.py@@ -78,7 +78,26 @@ def test_document_adder_preserves_explicit_bound_provider(tmp_path: Path) -> Nonassert adder.rag_provider == "graphrag"-def test_document_adder_allows_empty_lightrag_kb_to_bootstrap(tmp_path: Path) -> None:+def test_document_adder_allows_empty_lightrag_kb_to_bootstrap(monkeypatch, tmp_path: Path) -> None:+ from deeptutor.services import config+ from deeptutor.services.llm.config import LLMConfig+ from deeptutor.services.rag.pipelines.lightrag import roles++ monkeypatch.setattr(+ config,+ "load_lightrag_settings",+ lambda: {+ "version": 2,+ "role_models": {"base": {"profile_id": "fixture", "model_id": "fixture"}},+ },+ )+ monkeypatch.setattr(+ roles,+ "resolve_selection",+ lambda *_args, **_kwargs: LLMConfig(+ model="fixture", binding="openai", api_key="offline-fixture"+ ),+ )(tmp_path / "empty-kb").mkdir()adder = DocumentAdder(@@ -89,6 +108,8 @@ def test_document_adder_allows_empty_lightrag_kb_to_bootstrap(tmp_path: Path) ->assert adder.rag_provider == "lightrag"assert adder.raw_dir.is_dir()+ assert adder.accepted_indexing_snapshot.extract.config.model == "fixture"+ assert adder.accepted_indexing_snapshot.vlm is Nonedef test_process_new_documents_returns_failures_without_marking_processed(diff --git a/tests/services/rag/test_lightrag_indexing_policy.py b/tests/services/rag/test_lightrag_indexing_policy.pyindex 8f43e7f4e..26c6ae885 100644--- a/tests/services/rag/test_lightrag_indexing_policy.py+++ b/tests/services/rag/test_lightrag_indexing_policy.py@@ -177,11 +177,13 @@ def test_default_snapshot_prefers_released_lightrag_selection(monkeypatch) -> Nodef test_default_snapshot_rejects_unreadable_released_setting(monkeypatch) -> None:+ from deeptutor.services import config as settings_configfrom deeptutor.services.rag.pipelines.lightrag import configdef fail():raise OSError("settings unreadable")+ monkeypatch.setattr(settings_config, "load_lightrag_settings", lambda: {"version": 1})monkeypatch.setattr(config, "lightrag_indexing_selection_from_settings", fail)with pytest.raises(indexing_policy.IndexingPolicyError, match="could not be resolved"):diff --git a/tests/services/rag/test_lightrag_native_smoke.py b/tests/services/rag/test_lightrag_native_smoke.pyindex 18dc0139a..7442cac1c 100644--- a/tests/services/rag/test_lightrag_native_smoke.py+++ b/tests/services/rag/test_lightrag_native_smoke.py@@ -11,9 +11,11 @@ import pytestEmbeddingFunc = pytest.importorskip("lightrag.utils").EmbeddingFunc+from deeptutor.services import config+from deeptutor.services.llm.config import LLMConfigfrom deeptutor.services.parsing.types import ParsedDocumentfrom deeptutor.services.rag.index_versioning import list_kb_versions-from deeptutor.services.rag.pipelines.lightrag import engine, ingress, storage+from deeptutor.services.rag.pipelines.lightrag import engine, ingress, roles, storageasync def _fake_llm(_prompt, **_kwargs) -> str:@@ -28,6 +30,23 @@ async def _fake_embedding(texts: list[str]) -> np.ndarray:def _configure_real_sdk(monkeypatch, llm=_fake_llm) -> None:+ # Resolve real role settings against a synthetic model instead of depending+ # on an existing developer settings file or a configured provider.+ monkeypatch.setattr(+ config,+ "load_lightrag_settings",+ lambda: {+ "version": 2,+ "role_models": {"base": {"profile_id": "fixture", "model_id": "fixture"}},+ },+ )+ monkeypatch.setattr(+ roles,+ "resolve_selection",+ lambda *_args, **_kwargs: LLMConfig(+ model="fixture", binding="openai", api_key="offline-fixture"+ ),+ )monkeypatch.setattr(engine, "build_llm_model_func", lambda **_kwargs: llm)monkeypatch.setattr(engine,