refactor(managers): 重构单例管理器实现并优化代码结构
feat(ws_pool): 新增 WebSocket 连接池实现 perf(json): 使用 orjson 替代标准 json 库提升性能 style: 清理未使用的导入和冗余代码 docs: 更新架构文档和开发规范 test: 添加 WebSocket 连接池测试用例 fix(plugins): 修复自动审批插件 API 调用参数格式
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
import pytest
|
||||
import asyncio
|
||||
from unittest.mock import MagicMock, AsyncMock, patch
|
||||
from core.ws import WS
|
||||
from core.bot import Bot
|
||||
from models.objects import GroupInfo, StrangerInfo
|
||||
|
||||
|
||||
class TestWS:
|
||||
@@ -38,7 +36,7 @@ class TestWS:
|
||||
# 测试 WebSocket 未初始化的情况
|
||||
result = await ws.call_api("send_group_msg", {"group_id": 123456, "message": "test"})
|
||||
assert result["code"] == 2002 # WS_DISCONNECTED
|
||||
assert result["success"] == False
|
||||
assert not result["success"]
|
||||
assert "WebSocket未初始化" in result["message"]
|
||||
|
||||
# 测试 WebSocket 已初始化但未连接的情况
|
||||
@@ -47,7 +45,7 @@ class TestWS:
|
||||
ws.ws = mock_ws
|
||||
result = await ws.call_api("send_group_msg", {"group_id": 123456, "message": "test"})
|
||||
assert result["code"] == 2002 # WS_DISCONNECTED
|
||||
assert result["success"] == False
|
||||
assert not result["success"]
|
||||
assert "WebSocket连接未打开" in result["message"]
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in New Issue
Block a user