59 lines
1.8 KiB
Python
59 lines
1.8 KiB
Python
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
import pytest
|
||
|
|
|
||
|
|
from yuxi.channels.adapters.wechat.capabilities import (
|
||
|
|
WECHAT_CAPABILITIES,
|
||
|
|
WECHAT_MESSAGE_CAPABILITIES,
|
||
|
|
WECHAT_META,
|
||
|
|
get_capabilities,
|
||
|
|
get_message_capabilities,
|
||
|
|
get_meta,
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
class TestCapabilities:
|
||
|
|
def test_get_meta_returns_correct_channel(self):
|
||
|
|
meta = get_meta()
|
||
|
|
assert meta.id == "wechat"
|
||
|
|
assert meta.label == "微信"
|
||
|
|
assert "微信" in meta.selection_label
|
||
|
|
|
||
|
|
def test_get_meta_returns_same_singleton(self):
|
||
|
|
meta1 = get_meta()
|
||
|
|
meta2 = get_meta()
|
||
|
|
assert meta1.id == meta2.id
|
||
|
|
assert meta1 is meta2
|
||
|
|
|
||
|
|
def test_get_capabilities_returns_copy(self):
|
||
|
|
caps = get_capabilities()
|
||
|
|
assert caps["chatTypes"] == ["direct", "group"]
|
||
|
|
assert caps["polls"] is False
|
||
|
|
assert caps["reply"] is True
|
||
|
|
assert caps["streaming"] is False
|
||
|
|
caps["reply"] = False
|
||
|
|
assert WECHAT_CAPABILITIES["reply"] is True
|
||
|
|
|
||
|
|
def test_get_capabilities_has_media(self):
|
||
|
|
caps = get_capabilities()
|
||
|
|
assert caps["media"] is True
|
||
|
|
|
||
|
|
def test_get_capabilities_has_tts(self):
|
||
|
|
caps = get_capabilities()
|
||
|
|
assert caps["tts"]["voice"]["enabled"] is True
|
||
|
|
|
||
|
|
def test_get_message_capabilities_returns_copy(self):
|
||
|
|
caps = get_message_capabilities()
|
||
|
|
assert caps["presentation"] is False
|
||
|
|
assert caps["delivery-pin"] is False
|
||
|
|
caps["presentation"] = True
|
||
|
|
assert WECHAT_MESSAGE_CAPABILITIES["presentation"] is False
|
||
|
|
|
||
|
|
def test_meta_aliases(self):
|
||
|
|
meta = get_meta()
|
||
|
|
assert "weixin" in meta.aliases
|
||
|
|
assert "WeChat" in meta.aliases
|
||
|
|
|
||
|
|
def test_meta_docs_path(self):
|
||
|
|
meta = get_meta()
|
||
|
|
assert meta.docs_path == "docs/channels/wechat"
|