refactor(managers): 重构单例管理器实现并优化代码结构

feat(ws_pool): 新增 WebSocket 连接池实现

perf(json): 使用 orjson 替代标准 json 库提升性能

style: 清理未使用的导入和冗余代码

docs: 更新架构文档和开发规范

test: 添加 WebSocket 连接池测试用例

fix(plugins): 修复自动审批插件 API 调用参数格式
This commit is contained in:
2026-01-22 16:23:03 +08:00
parent d7d732ff4d
commit caf5b06097
42 changed files with 1285 additions and 261 deletions

View File

@@ -2,7 +2,7 @@ import asyncio
import pytest
from unittest.mock import MagicMock, patch, AsyncMock
import docker
from core.utils.executor import CodeExecutor, initialize_executor
from core.utils.executor import CodeExecutor
# Mock 配置对象
@pytest.fixture
@@ -136,8 +136,10 @@ async def test_worker_docker_errors(executor):
await executor.task_queue.join()
callback.assert_called_with(f"执行失败:沙箱基础镜像 '{executor.sandbox_image}' 不存在,请联系管理员构建。")
worker_task.cancel()
try: await worker_task
except: pass
try:
await worker_task
except Exception:
pass
# ContainerError
executor._run_in_container = MagicMock(side_effect=docker.errors.ContainerError(
@@ -150,8 +152,10 @@ async def test_worker_docker_errors(executor):
await executor.task_queue.join()
callback.assert_called_with("代码执行出错:\nError output")
worker_task.cancel()
try: await worker_task
except: pass
try:
await worker_task
except Exception:
pass
def test_run_in_container_success(executor):
"""测试 _run_in_container 成功"""