Skip to content

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

test(rag): exercise current image client and portable read failures

Bingxi Zhao (Frank)307f68c86f58
diff --git a/tests/services/rag/test_lightrag_workspace_meta.py b/tests/services/rag/test_lightrag_workspace_meta.py
index 6d461453c..864f56d0a 100644
--- a/tests/services/rag/test_lightrag_workspace_meta.py
+++ b/tests/services/rag/test_lightrag_workspace_meta.py
@@ -34,13 +34,20 @@ def test_corrupt_meta_json_warns_and_falls_back(
def test_unreadable_meta_json_warns_and_falls_back(
- tmp_path: Path, caplog: pytest.LogCaptureFixture
+ tmp_path: Path, caplog: pytest.LogCaptureFixture, monkeypatch: pytest.MonkeyPatch
) -> None:
meta = tmp_path / "meta.json"
meta.write_text(
json.dumps({"provider": "lightrag", "workspace": "deeptutor_abc"}), encoding="utf-8"
)
- meta.chmod(0o000)
+ read_text = Path.read_text
+
+ def denied_meta(path: Path, *args, **kwargs):
+ if path == meta:
+ raise PermissionError("cannot read meta.json")
+ return read_text(path, *args, **kwargs)
+
+ monkeypatch.setattr(Path, "read_text", denied_meta)
with caplog.at_level(logging.WARNING, logger=_ENGINE_LOGGER):
name = engine.workspace_for(tmp_path)
assert name == _hash_workspace(tmp_path)
diff --git a/tests/services/rag/test_llamaindex_document_loader.py b/tests/services/rag/test_llamaindex_document_loader.py
index 799872f5c..63ab686c4 100644
--- a/tests/services/rag/test_llamaindex_document_loader.py
+++ b/tests/services/rag/test_llamaindex_document_loader.py
@@ -566,7 +566,7 @@ def test_loader_logs_and_continues_when_image_progress_callback_fails(
return "Stub description."
monkeypatch.setattr(loader_module, "get_embedding_client", lambda: _MultimodalEmbeddingClient())
- monkeypatch.setattr(loader_module, "get_llm_client", lambda: _VisionClient())
+ monkeypatch.setattr(loader_module, "get_image_description_client", lambda: _VisionClient())
calls: list[tuple[int, int]] = []