"""客户端 Mock 实现测试.""" from src.ai.clients.content_client import ContentClientMock, QuestionInput from src.ai.clients.data_ana_client import DataAnaClientMock from src.ai.clients.iam_client import IamClientMock class TestContentClientMock: """ContentClientMock 测试.""" async def test_get_prerequisites(self) -> None: """查询前置知识点.""" client = ContentClientMock() result = await client.get_prerequisites("kp-1") assert len(result) == 1 assert result[0].id == "kp_base_001" async def test_get_learning_path(self) -> None: """查询学习路径.""" client = ContentClientMock() result = await client.get_learning_path("s-1", "math") assert len(result) == 2 async def test_create_questions(self) -> None: """批量创建题目.""" client = ContentClientMock() questions = [ QuestionInput( question="题1", answer="答1", explanation="解1", question_type="short_answer", difficulty="easy", knowledge_point_ids=["kp-1"], ), QuestionInput( question="题2", answer="答2", explanation="解2", question_type="single_choice", difficulty="hard", knowledge_point_ids=["kp-2"], ), ] result = await client.create_questions(questions, user_id="u-1") assert len(result) == 2 assert result[0].id.startswith("q_mock_") def test_is_available(self) -> None: """Mock 客户端始终可用.""" assert ContentClientMock().is_available() is True class TestDataAnaClientMock: """DataAnaClientMock 测试.""" async def test_get_student_weakness(self) -> None: """查询学生薄弱点.""" client = DataAnaClientMock() result = await client.get_student_weakness("s-1", "math") assert result.student_id == "s-1" assert len(result.weak_points) > 0 async def test_get_learning_trend(self) -> None: """查询学习趋势.""" client = DataAnaClientMock() result = await client.get_learning_trend("s-1") assert result.student_id == "s-1" assert len(result.points) > 0 async def test_get_class_performance(self) -> None: """查询班级表现.""" client = DataAnaClientMock() result = await client.get_class_performance("c-1", "math") assert result.class_id == "c-1" assert result.average_score > 0 def test_is_available(self) -> None: assert DataAnaClientMock().is_available() is True class TestIamClientMock: """IamClientMock 测试.""" async def test_get_effective_data_scope(self) -> None: """查询数据权限.""" client = IamClientMock() result = await client.get_effective_data_scope("u-1") assert result.user_id == "u-1" assert result.school_id == "school_mock_001" assert len(result.class_ids) > 0 def test_is_available(self) -> None: assert IamClientMock().is_available() is True