ForcePilot/backend/test/unit/channel/message/test_models.py
Kris bab30f2715
Some checks failed
Deploy VitePress site to Pages / build (push) Has been cancelled
Ruff Format Check / Ruff Format & Lint (push) Has been cancelled
Deploy VitePress site to Pages / Deploy (push) Has been cancelled
feat:0715
2026-07-15 12:30:58 +08:00

65 lines
2.0 KiB
Python

from __future__ import annotations
from yuxi.channel.constants import InboundRejectionReason
from yuxi.channel.message.models import RunAcceptedResponse
from yuxi.channel.plugins.protocol import InboundMessage
def test_run_accepted_response_defaults():
response = RunAcceptedResponse(accepted=True)
assert response.accepted is True
assert response.run_id is None
assert response.reason is None
assert response.pairing_code is None
def test_run_accepted_response_with_rejection_reason():
response = RunAcceptedResponse(
accepted=False,
reason=InboundRejectionReason.DUPLICATE,
)
assert response.accepted is False
assert response.reason == InboundRejectionReason.DUPLICATE
def test_run_accepted_response_with_pairing_code():
response = RunAcceptedResponse(
accepted=False,
reason=InboundRejectionReason.DM_PAIRING_REQUIRED,
pairing_code="pair-123",
)
assert response.pairing_code == "pair-123"
def test_inbound_message_defaults():
message = InboundMessage(channel_type="feishu", account_id="acc-1")
assert message.channel_type == "feishu"
assert message.account_id == "acc-1"
assert message.content == ""
assert message.content_type == "text"
assert message.media == []
assert message.raw_event == {}
assert message.mentioned_user_ids == []
def test_inbound_message_with_media():
message = InboundMessage(
channel_type="feishu",
account_id="acc-1",
channel_message_id="msg-1",
sender_id="user-1",
content="hello",
content_type="text",
)
assert message.channel_message_id == "msg-1"
assert message.sender_id == "user-1"
assert message.content == "hello"
def test_models_all_exports_inbound_message():
# RunAcceptedResponse 显式导入 InboundMessage 并通过 __all__ 暴露
from yuxi.channel.message.models import __all__
assert "InboundMessage" in __all__
assert "RunAcceptedResponse" in __all__