Skip to content

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

fix: update tests for list_progress {summaries, errors} format and RAG tuple

unknown95f584e307a5
diff --git a/deeptutor/learning/tests/test_api_endpoints.py b/deeptutor/learning/tests/test_api_endpoints.py
index 47d1e20a0..b6e2e0aad 100644
--- a/deeptutor/learning/tests/test_api_endpoints.py
+++ b/deeptutor/learning/tests/test_api_endpoints.py
@@ -37,7 +37,9 @@ class TestListProgress:
def test_list_empty(self, client):
resp = client.get("/api/v1/learning/progress")
assert resp.status_code == 200
- assert resp.json() == []
+ data = resp.json()
+ assert data["summaries"] == []
+ assert data["errors"] == []
def test_list_with_data(self, client):
client.post("/api/v1/learning/progress/testbook/init-modules",
@@ -46,7 +48,8 @@ class TestListProgress:
"type": "concept", "module_id": "m1"}]}]})
resp = client.get("/api/v1/learning/progress")
assert resp.status_code == 200
- book_ids = [p["book_id"] for p in resp.json()]
+ data = resp.json()
+ book_ids = [p["book_id"] for p in data["summaries"]]
assert "testbook" in book_ids
def test_list_name_from_first_module(self, client):
@@ -59,7 +62,7 @@ class TestListProgress:
]})
resp = client.get("/api/v1/learning/progress")
assert resp.status_code == 200
- for p in resp.json():
+ for p in resp.json()["summaries"]:
if p["book_id"] == "named":
assert p["name"] == "线性代数"
break
@@ -72,7 +75,7 @@ class TestListProgress:
json={"modules": []})
resp = client.get("/api/v1/learning/progress")
assert resp.status_code == 200
- for p in resp.json():
+ for p in resp.json()["summaries"]:
if p["book_id"] == "empty_mods":
assert p["name"] == "empty_mods", f"expected book_id fallback, got {p['name']}"
break
diff --git a/deeptutor/learning/tests/test_llm_integration.py b/deeptutor/learning/tests/test_llm_integration.py
index 323ad6311..6904cbaf0 100644
--- a/deeptutor/learning/tests/test_llm_integration.py
+++ b/deeptutor/learning/tests/test_llm_integration.py
@@ -42,10 +42,10 @@ class TestRAGIntegration:
@pytest.mark.asyncio
async def test_retrieve_context_no_kb(self):
- """Without kb_name, _retrieve_context returns empty string."""
+ """Without kb_name, _retrieve_context returns (content, error) tuple with empty strings."""
cap = GuidedLearningCapability()
result = await cap._retrieve_context("test query")
- assert result == ""
+ assert result == ("", "")
def test_kb_params_stored(self):
"""kb_name and kb_base_dir should be stored as instance attrs."""