2026-04-06 12:03:56 -07:00
|
|
|
"""Tests for Feishu/Lark domain configuration."""
|
|
|
|
|
from unittest.mock import MagicMock
|
|
|
|
|
|
|
|
|
|
from nanobot.bus.queue import MessageBus
|
2026-07-19 23:30:49 +08:00
|
|
|
from nanobot.channels.feishu.runtime import FeishuChannel, FeishuConfig
|
2026-04-06 12:03:56 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def _make_channel(domain: str = "feishu") -> FeishuChannel:
|
|
|
|
|
config = FeishuConfig(
|
|
|
|
|
enabled=True,
|
|
|
|
|
app_id="cli_test",
|
|
|
|
|
app_secret="secret",
|
|
|
|
|
allow_from=["*"],
|
|
|
|
|
domain=domain,
|
|
|
|
|
)
|
|
|
|
|
ch = FeishuChannel(config, MessageBus())
|
|
|
|
|
ch._client = MagicMock()
|
|
|
|
|
ch._loop = None
|
|
|
|
|
return ch
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestFeishuConfigDomain:
|
|
|
|
|
def test_domain_default_is_feishu(self):
|
|
|
|
|
config = FeishuConfig()
|
|
|
|
|
assert config.domain == "feishu"
|
|
|
|
|
|
|
|
|
|
def test_domain_accepts_lark(self):
|
|
|
|
|
config = FeishuConfig(domain="lark")
|
|
|
|
|
assert config.domain == "lark"
|
|
|
|
|
|
|
|
|
|
def test_domain_accepts_feishu(self):
|
|
|
|
|
config = FeishuConfig(domain="feishu")
|
|
|
|
|
assert config.domain == "feishu"
|
|
|
|
|
|
|
|
|
|
def test_default_config_includes_domain(self):
|
|
|
|
|
default_cfg = FeishuChannel.default_config()
|
|
|
|
|
assert "domain" in default_cfg
|
|
|
|
|
assert default_cfg["domain"] == "feishu"
|
|
|
|
|
|
|
|
|
|
def test_channel_persists_domain_from_config(self):
|
|
|
|
|
ch = _make_channel(domain="lark")
|
|
|
|
|
assert ch.config.domain == "lark"
|
|
|
|
|
|
|
|
|
|
def test_channel_persists_feishu_domain_from_config(self):
|
|
|
|
|
ch = _make_channel(domain="feishu")
|
|
|
|
|
assert ch.config.domain == "feishu"
|