新增了Twitch、Telegram、Discord、Slack、Mattermost、WeChat、Zalo等多渠道的单元测试用例,覆盖了令牌处理、速率限制、消息去重、会话解析、格式转换、安全策略等模块 同时在测试配置中添加了测试用的OpenAI API密钥环境变量
30 lines
900 B
Python
30 lines
900 B
Python
from __future__ import annotations
|
|
|
|
from yuxi.channels.adapters.twitch.token_utils import ensure_oauth_prefix, normalize_token
|
|
|
|
|
|
class TestEnsureOAuthPrefix:
|
|
|
|
def test_already_has_prefix(self):
|
|
assert ensure_oauth_prefix("oauth:abc123") == "oauth:abc123"
|
|
|
|
def test_adds_prefix_when_missing(self):
|
|
assert ensure_oauth_prefix("abc123") == "oauth:abc123"
|
|
|
|
def test_strips_whitespace(self):
|
|
assert ensure_oauth_prefix(" oauth:abc123 ") == "oauth:abc123"
|
|
|
|
def test_strips_and_adds(self):
|
|
assert ensure_oauth_prefix(" abc123 ") == "oauth:abc123"
|
|
|
|
def test_empty_token(self):
|
|
assert ensure_oauth_prefix("") == "oauth:"
|
|
|
|
|
|
class TestNormalizeToken:
|
|
|
|
def test_returns_prefixed(self):
|
|
assert normalize_token("abc") == "oauth:abc"
|
|
|
|
def test_preserves_existing_prefix(self):
|
|
assert normalize_token("oauth:abc") == "oauth:abc" |