ForcePilot/backend/test/unit/gateway/protocol/test_version.py
Kris 3264900bc9 test: 新增多渠道单元测试用例并配置测试环境变量
新增了Twitch、Telegram、Discord、Slack、Mattermost、WeChat、Zalo等多渠道的单元测试用例,覆盖了令牌处理、速率限制、消息去重、会话解析、格式转换、安全策略等模块
同时在测试配置中添加了测试用的OpenAI API密钥环境变量
2026-05-12 00:56:47 +08:00

43 lines
1.2 KiB
Python

from __future__ import annotations
from yuxi.gateway.protocol.version import PROTOCOL_VERSION, negotiate_version
class TestProtocolVersion:
def test_protocol_version_is_one(self):
assert PROTOCOL_VERSION == 1
def test_protocol_version_is_int(self):
assert isinstance(PROTOCOL_VERSION, int)
class TestNegotiateVersion:
def test_both_v1_returns_1(self):
assert negotiate_version(1, 1) == 1
def test_client_supports_1_to_3_returns_1(self):
assert negotiate_version(1, 3) == 1
def test_client_too_new_returns_none(self):
assert negotiate_version(3, 5) is None
def test_client_expects_future_fails(self):
assert negotiate_version(2, 2) is None
def test_client_range_covers_server(self):
assert negotiate_version(1, 1) == 1
def test_result_is_int(self):
result = negotiate_version(1, 1)
assert isinstance(result, int)
def test_failure_is_none(self):
result = negotiate_version(3, 5)
assert result is None
def test_client_max_exceeds_server(self):
assert negotiate_version(1, 10) == 1
def test_client_min_exceeds_server(self):
assert negotiate_version(2, 10) is None