1. 移除Telegram格式化测试中未使用的导入项 2. 修复Teams测试用例,添加monkeypatch参数并配置通配符开关 3. 更新钉钉适配器测试,替换弃用的流属性检查 4. 修正Twitch规范化测试,更新ROOMSTATE测试逻辑 5. 重构会话映射测试,完善数据库执行结果模拟 6. 格式化Slack块构建测试的长参数调用 7. 修复LINE适配器测试,更新能力断言和异步锁使用 8. 修正Slack会话解析测试,修复聊天类型判断错误 9. 更新能力测试,补充缺失的字段检查 10. 修复Matrix适配器测试,修正位置参数和配置校验逻辑 11. 为飞书分析模块测试添加跳过标记 12. 新增微信能力、限流、链接格式、会话路由等模块的单元测试 13. 修复Twitch适配器导入路径和测试断言 14. 新增Discord Webhook、Nextcloud Talk、Signal多账户等模块的单元测试 15. 修复Manager阶段测试的导入路径 16. 新增iMessage异常和命令处理的单元测试 17. 新增Nostr健康检查和相关模块的单元测试 18. 新增Signal守护进程和SSE重连相关测试
102 lines
3.1 KiB
Python
102 lines
3.1 KiB
Python
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
from yuxi.channels.adapters.imessage.exceptions import (
|
|
BlueBubblesAuthenticationError,
|
|
BlueBubblesConnectionError,
|
|
BlueBubblesHTTPError,
|
|
IMessageError,
|
|
TapbackError,
|
|
)
|
|
|
|
|
|
class TestIMessageError:
|
|
def test_default_values(self):
|
|
err = IMessageError("Something went wrong")
|
|
assert str(err) == "Something went wrong"
|
|
assert err.retryable is False
|
|
assert err.retry_after_ms == 0
|
|
|
|
def test_with_params(self):
|
|
err = IMessageError("Retry later", retryable=True, retry_after_ms=5000)
|
|
assert str(err) == "Retry later"
|
|
assert err.retryable is True
|
|
assert err.retry_after_ms == 5000
|
|
|
|
def test_is_channel_exception(self):
|
|
from yuxi.channels.exceptions import ChannelException
|
|
|
|
err = IMessageError("test")
|
|
assert isinstance(err, ChannelException)
|
|
assert isinstance(err, Exception)
|
|
|
|
|
|
class TestBlueBubblesHTTPError:
|
|
def test_basic_error(self):
|
|
err = BlueBubblesHTTPError(404, "Not found")
|
|
assert "404" in str(err)
|
|
assert "Not found" in str(err)
|
|
assert err.status_code == 404
|
|
assert err.retryable is False
|
|
|
|
def test_server_error_retryable(self):
|
|
err = BlueBubblesHTTPError(500, "Internal error")
|
|
assert err.retryable is True
|
|
|
|
def test_rate_limit_retryable(self):
|
|
err = BlueBubblesHTTPError(429, "Too many requests")
|
|
assert err.retryable is True
|
|
|
|
def test_client_error_not_retryable(self):
|
|
err = BlueBubblesHTTPError(400, "Bad request")
|
|
assert err.retryable is False
|
|
|
|
def test_is_iMessage_error(self):
|
|
err = BlueBubblesHTTPError(500)
|
|
assert isinstance(err, IMessageError)
|
|
|
|
def test_no_message(self):
|
|
err = BlueBubblesHTTPError(503)
|
|
assert "503" in str(err)
|
|
|
|
def test_custom_headers(self):
|
|
err = BlueBubblesHTTPError(401, "Unauthorized", headers={"Retry-After": "60"})
|
|
assert err.headers == {"Retry-After": "60"}
|
|
|
|
|
|
class TestBlueBubblesConnectionError:
|
|
def test_default_message(self):
|
|
err = BlueBubblesConnectionError()
|
|
assert "connection failed" in str(err).lower()
|
|
assert err.retryable is True
|
|
|
|
def test_custom_message(self):
|
|
err = BlueBubblesConnectionError("Custom connection error")
|
|
assert "Custom connection error" in str(err)
|
|
|
|
def test_retry_after(self):
|
|
err = BlueBubblesConnectionError()
|
|
assert err.retry_after_ms == 5000
|
|
|
|
|
|
class TestBlueBubblesAuthenticationError:
|
|
def test_default_message(self):
|
|
err = BlueBubblesAuthenticationError()
|
|
assert "authentication failed" in str(err).lower()
|
|
assert err.retryable is False
|
|
|
|
def test_custom_message(self):
|
|
err = BlueBubblesAuthenticationError("Invalid password")
|
|
assert "Invalid password" in str(err)
|
|
|
|
|
|
class TestTapbackError:
|
|
def test_default_message(self):
|
|
err = TapbackError()
|
|
assert "tapback" in str(err).lower()
|
|
assert err.retryable is False
|
|
|
|
def test_custom_message(self):
|
|
err = TapbackError("Unsupported emoji")
|
|
assert "Unsupported emoji" in str(err) |