Spaces:
Sleeping
Sleeping
| from fastapi.testclient import TestClient | |
| from app.main import app | |
| client = TestClient(app) | |
| def test_read_root(): | |
| response = client.get("/") | |
| assert response.status_code == 200 | |
| assert response.json() == {"status": "ok", "service": "multidisciplinary-engine"} | |
| def test_toggle_mode(): | |
| response = client.post("/toggle-mode", json={"learner_id": "L1", "enabled": True}) | |
| assert response.status_code == 200 | |
| assert response.json()["mode_active"] is True | |
| assert response.json()["learner_id"] == "L1" | |
| def test_select_disciplines(): | |
| response = client.post("/select-disciplines?concept_id=inflation", json={"learner_id": "L1"}) # passing learner_profile as body | |
| assert response.status_code == 200 | |
| data = response.json() | |
| assert "economics" in data["ranked_disciplines"] | |
| assert "history" in data["ranked_disciplines"] | |
| def test_build_plan(): | |
| # Helper to enable mode first if needed (though service currently stateless/mocked) | |
| req_data = { | |
| "learner_id": "L1", | |
| "target_concept_id": "inflation", | |
| "goal": "understand", | |
| "level": "beginner", | |
| "time_budget_min": 30, | |
| "selected_disciplines": ["economics", "history", "geography"] | |
| } | |
| response = client.post("/plan", json=req_data) | |
| assert response.status_code == 200 | |
| data = response.json() | |
| assert data["target_concept_id"] == "inflation" | |
| assert len(data["lesson_outline"]) > 0 | |
| assert data["generated_by"] == "LearningOS" | |
| def test_generate_course(): | |
| # Mock plan | |
| plan = { | |
| "target_concept_id": "inflation", | |
| "disciplines": [{"name": "eco", "role": "core"}], | |
| "lesson_outline": [{"step": 1, "lens": "eco", "objective": "test"}], | |
| "generated_by": "LearningOS", | |
| "assets": [] | |
| } | |
| response = client.post("/generate", json=plan) | |
| assert response.status_code == 200 | |
| assert response.json()["status"] == "success" | |