fad458b2a7
- UIUX 文档:填充 19 个缺口(多主体画像/健康度/AI+看板/增长域/洞察域/创始人端/OODA/助推/商密) - UIUX 文档:插入 6 个新章节(十四~十九),旧章节重编号为二十~三十一,更新目录和交叉引用 - 作业指导书 x5:导航改为 6 域分组,新增 Context Bar/工作模式/Insight Rail/决策线程/多工作区等 UI 概念 - 新建 docs/2-task-uiux.md:50 个代码落地开发任务,按 P0-P6 分优先级 + 8 Sprint 规划 - 后端/前端:大量新增模型、路由、组件(来自之前 Phase 开发)
65 lines
2.3 KiB
Python
65 lines
2.3 KiB
Python
"""T4.8 Agent 编排引擎测试。
|
|
|
|
测试 L1-L4 分级自治的 Agent 编排。
|
|
"""
|
|
|
|
import pytest
|
|
|
|
from app.services.agent_orchestrator import AUTONOMY_LEVELS, orchestrate_agent
|
|
|
|
|
|
class TestOrchestrateAgent:
|
|
"""Agent 编排测试。"""
|
|
|
|
async def test_l1_requires_approval(self):
|
|
"""L1 级别需要人工审核。"""
|
|
result = await orchestrate_agent("test_agent", "L1", {"task": "测试任务"})
|
|
assert result["requires_approval"] is True
|
|
assert result["status"] == "pending_approval"
|
|
|
|
async def test_l2_requires_approval(self):
|
|
"""L2 级别需要人工确认。"""
|
|
result = await orchestrate_agent("test_agent", "L2", {"task": "测试任务"})
|
|
assert result["requires_approval"] is True
|
|
assert result["status"] == "pending_approval"
|
|
|
|
async def test_l3_post_review(self):
|
|
"""L3 级别事后审核。"""
|
|
result = await orchestrate_agent("test_agent", "L3", {"task": "测试任务"})
|
|
assert result["requires_approval"] is False
|
|
assert result["requires_post_review"] is True
|
|
assert result["status"] == "executed"
|
|
|
|
async def test_l4_requires_approval(self):
|
|
"""L4 级别人工决策。"""
|
|
result = await orchestrate_agent("test_agent", "L4", {"task": "测试任务"})
|
|
assert result["requires_approval"] is True
|
|
|
|
async def test_unknown_level_defaults_l1(self):
|
|
"""未知级别默认 L1。"""
|
|
result = await orchestrate_agent("test_agent", "L9", {"task": "测试任务"})
|
|
assert result["requires_approval"] is True
|
|
|
|
async def test_input_summary_truncated(self):
|
|
"""输入摘要被截断。"""
|
|
long_input = {"data": "x" * 500}
|
|
result = await orchestrate_agent("test_agent", "L1", long_input)
|
|
assert len(result["input_summary"]) <= 200
|
|
|
|
|
|
class TestAutonomyLevels:
|
|
"""自治级别配置测试。"""
|
|
|
|
def test_all_levels_defined(self):
|
|
"""L1-L4 全部定义。"""
|
|
assert "L1" in AUTONOMY_LEVELS
|
|
assert "L2" in AUTONOMY_LEVELS
|
|
assert "L3" in AUTONOMY_LEVELS
|
|
assert "L4" in AUTONOMY_LEVELS
|
|
|
|
def test_level_has_description(self):
|
|
"""每个级别有描述。"""
|
|
for level, config in AUTONOMY_LEVELS.items():
|
|
assert "description" in config
|
|
assert len(config["description"]) > 0
|