```
feat(engine): 优化智能体循环中的助手消息处理逻辑 - 在没有工具调用时才添加助手消息到上下文 - 确保工具调用响应正确添加到消息上下文中 - 修复了消息构建的条件逻辑 fix(cron): 改进定时任务调度的时间解析功能 - 添加正则表达式导入用于时间显示解析 - 实现从显示文本中提取毫秒间隔的功能 - 增强整数转换的安全性,避免类型错误 - 优化定时任务配置的解析逻辑 feat(outlook): 增强Outlook集成的功能和稳定性 - 将默认超时时间从10秒增加到180秒 - 为状态检查函数添加可选的验证参数 - 串行执行邮件概览获取操作而非并行 - 改进连接状态验证逻辑 feat(channel): 添加设备名称作为会话标识的选项 - 为终端WebSocket适配器添加新的配置选项 - 实现基于设备名称生成会话对等ID的功能 - 记录原始对等ID和设备名称的元数据 - 支持从设备名称创建会话对等ID feat(skills): 完善技能学习评估系统和进度跟踪 - 在应用启动时自动调度待评估的技能草稿 - 为技能评估工作创建独立的循环工厂 - 实现异步技能评估任务的取消和清理机制 - 添加技能评估进度报告和状态跟踪功能 - 扩展会话列表API以包含更多详细信息 - 防止对不存在的会话进行操作 - 优化技能草稿提交和评估的业务逻辑 perf(skills): 提升技能评估的并发性能 - 实现并行技能案例评估以提高效率 - 添加最大并行案例数的环境变量控制 - 实现实时评估进度更新和回调机制 - 优化评估过程中的资源管理和同步 refactor(services): 创建隔离的智能体循环实例 - 添加创建独立智能体循环的工厂方法 - 确保新循环继承运行时服务配置 - 支持技能评估等需要隔离环境的场景 ```
This commit is contained in:
71
app-instance/backend/tests/unit/test_outlook_integration.py
Normal file
71
app-instance/backend/tests/unit/test_outlook_integration.py
Normal file
@ -0,0 +1,71 @@
|
||||
import asyncio
|
||||
|
||||
import pytest
|
||||
|
||||
from beaver.foundation.config.schema import AuthzConfig, BackendIdentityConfig, BeaverConfig
|
||||
from beaver.integrations import outlook
|
||||
|
||||
|
||||
class _FakeAuthzClient:
|
||||
async def get_outlook_settings(self, backend_id: str) -> dict:
|
||||
assert backend_id == "steven"
|
||||
return {
|
||||
"configured": True,
|
||||
"email": "steven.yx.li@boardware.com",
|
||||
"server": "mail.boardware.com.mo",
|
||||
}
|
||||
|
||||
|
||||
def _authz_config() -> BeaverConfig:
|
||||
return BeaverConfig(
|
||||
authz=AuthzConfig(
|
||||
enabled=True,
|
||||
base_url="http://authz.example",
|
||||
outlook_mcp_url="http://outlook-mcp.example/mcp",
|
||||
),
|
||||
backend_identity=BackendIdentityConfig(
|
||||
backend_id="steven",
|
||||
client_id="steven",
|
||||
client_secret="secret",
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def test_outlook_status_does_not_probe_mcp_by_default(monkeypatch: pytest.MonkeyPatch, tmp_path) -> None:
|
||||
monkeypatch.setattr(outlook, "_authz_client", lambda _config: _FakeAuthzClient())
|
||||
|
||||
async def fail_if_called(*_args, **_kwargs):
|
||||
raise AssertionError("status should not call Outlook MCP by default")
|
||||
|
||||
monkeypatch.setattr(outlook, "_call_outlook_mcp_tool", fail_if_called)
|
||||
|
||||
result = asyncio.run(outlook.outlook_status(_authz_config(), tmp_path))
|
||||
|
||||
assert result["configured"] is True
|
||||
assert result["connected"] is False
|
||||
assert result["auth_status"] is None
|
||||
assert result["error"] is None
|
||||
|
||||
|
||||
def test_outlook_overview_loads_sections_serially(monkeypatch: pytest.MonkeyPatch, tmp_path) -> None:
|
||||
monkeypatch.setattr(outlook, "_authz_client", lambda _config: _FakeAuthzClient())
|
||||
active_calls = 0
|
||||
max_active_calls = 0
|
||||
tool_names: list[str] = []
|
||||
|
||||
async def fake_call(_config, tool_name: str, _arguments, **_kwargs):
|
||||
nonlocal active_calls, max_active_calls
|
||||
tool_names.append(tool_name)
|
||||
active_calls += 1
|
||||
max_active_calls = max(max_active_calls, active_calls)
|
||||
await asyncio.sleep(0.01)
|
||||
active_calls -= 1
|
||||
return {"value": []}
|
||||
|
||||
monkeypatch.setattr(outlook, "_call_outlook_mcp_tool", fake_call)
|
||||
|
||||
result = asyncio.run(outlook.get_overview(_authz_config(), tmp_path))
|
||||
|
||||
assert result["warnings"] == []
|
||||
assert tool_names == ["mail_list_messages", "mail_list_messages", "calendar_list_events"]
|
||||
assert max_active_calls == 1
|
||||
Reference in New Issue
Block a user