2026-05-12 00:56:47 +08:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
2026-05-13 16:43:01 +08:00
|
|
|
from yuxi.channels.adapters.wechat import __all__ as wechat_all
|
2026-05-12 00:56:47 +08:00
|
|
|
|
|
|
|
|
|
2026-05-13 16:43:01 +08:00
|
|
|
class TestWeChatModuleInit:
|
|
|
|
|
def test_module_exports_basic_components(self):
|
|
|
|
|
assert "WeChatAdapter" in wechat_all or "WECHAT_META" in wechat_all
|
2026-05-12 00:56:47 +08:00
|
|
|
|
2026-05-13 16:43:01 +08:00
|
|
|
def test_module_can_be_imported(self):
|
|
|
|
|
import yuxi.channels.adapters.wechat as wechat
|
|
|
|
|
assert wechat is not None
|
2026-05-12 00:56:47 +08:00
|
|
|
|
2026-05-13 16:43:01 +08:00
|
|
|
def test_errors_module_imports(self):
|
|
|
|
|
from yuxi.channels.adapters.wechat.errors import (
|
|
|
|
|
is_token_expired,
|
|
|
|
|
parse_mp_error,
|
|
|
|
|
parse_wecom_error,
|
2026-05-12 00:56:47 +08:00
|
|
|
)
|
2026-05-13 16:43:01 +08:00
|
|
|
assert callable(is_token_expired)
|
|
|
|
|
assert callable(parse_mp_error)
|
|
|
|
|
assert callable(parse_wecom_error)
|
2026-05-12 00:56:47 +08:00
|
|
|
|
2026-05-13 16:43:01 +08:00
|
|
|
def test_session_module_imports(self):
|
|
|
|
|
from yuxi.channels.adapters.wechat.session import (
|
|
|
|
|
build_session_route,
|
|
|
|
|
get_session_metadata,
|
2026-05-12 00:56:47 +08:00
|
|
|
)
|
2026-05-13 16:43:01 +08:00
|
|
|
assert callable(build_session_route)
|
|
|
|
|
assert callable(get_session_metadata)
|
2026-05-12 00:56:47 +08:00
|
|
|
|
2026-05-13 16:43:01 +08:00
|
|
|
def test_crypto_modules_import(self):
|
|
|
|
|
from yuxi.channels.adapters.wechat.mp.crypto import verify_signature as mp_verify
|
|
|
|
|
from yuxi.channels.adapters.wechat.wecom.crypto import verify_signature as wc_verify
|
|
|
|
|
assert callable(mp_verify)
|
|
|
|
|
assert callable(wc_verify)
|
2026-05-12 00:56:47 +08:00
|
|
|
|
2026-05-13 16:43:01 +08:00
|
|
|
def test_send_modules_import(self):
|
|
|
|
|
from yuxi.channels.adapters.wechat.wecom.send import build_wecom_text_payload
|
|
|
|
|
from yuxi.channels.adapters.wechat.mp.send import build_mp_news_payload
|
|
|
|
|
assert callable(build_wecom_text_payload)
|
|
|
|
|
assert callable(build_mp_news_payload)
|
2026-05-12 00:56:47 +08:00
|
|
|
|
2026-05-13 16:43:01 +08:00
|
|
|
def test_client_modules_import(self):
|
|
|
|
|
from yuxi.channels.adapters.wechat.mp.client import MPClient
|
|
|
|
|
from yuxi.channels.adapters.wechat.wecom.client import WeComClient
|
|
|
|
|
assert MPClient is not None
|
|
|
|
|
assert WeComClient is not None
|