CourseDesign/tests/test_counselor_agent.py

40 lines
937 B
Python
Raw Permalink Normal View History

2026-01-09 14:30:23 +08:00
"""咨询师 Agent 测试"""
import os
2026-01-09 14:30:23 +08:00
import pytest
os.environ["DEEPSEEK_API_KEY"] = "dummy_key_for_testing"
2026-01-09 14:30:23 +08:00
from src.agent_app import AgentDeps, counselor_agent
from src.features import StudentFeatures
@pytest.fixture
def sample_deps() -> AgentDeps:
"""创建测试用依赖"""
return AgentDeps(
student=StudentFeatures(
study_hours=10,
sleep_hours=6,
attendance_rate=0.8,
stress_level=4,
study_type="Group",
)
)
@pytest.mark.asyncio
async def test_counselor_agent_structure():
2026-01-09 14:30:23 +08:00
"""测试咨询师 Agent 结构"""
assert counselor_agent is not None
2026-01-09 14:30:23 +08:00
assert hasattr(counselor_agent, "run")
assert hasattr(counselor_agent, "run_stream")
@pytest.mark.asyncio
2026-01-09 14:30:23 +08:00
async def test_counselor_agent_deps_type():
"""测试 Agent 依赖类型"""
# 验证 deps_type 设置正确
assert counselor_agent._deps_type == AgentDeps