ForcePilot/backend/test/unit/channels/test_twitch_token_utils.py

30 lines
900 B
Python
Raw Normal View History

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"