from __future__ import annotations import pytest from yuxi.channel.domain.event.message_received import MessageReceived from yuxi.channel.domain.event.message_blocked import MessageBlocked from yuxi.channel.domain.event.message_replied import MessageReplied from yuxi.channel.domain.event.agent_error import AgentError from yuxi.channel.domain.event.gateway_shutdown import GatewayShutdown class TestMessageReceived: def test_creation(self): event = MessageReceived( message_id="msg123", channel_type="web", sender_id="user1", content="Hello", ) assert event.message_id == "msg123" assert event.channel_type == "web" assert event.sender_id == "user1" assert event.content == "Hello" def test_to_dict(self): event = MessageReceived( message_id="msg123", channel_type="web", sender_id="user1", content="Hello", ) d = event.to_dict() assert d["message_id"] == "msg123" assert d["channel_type"] == "web" class TestMessageBlocked: def test_creation(self): event = MessageBlocked( message_id="msg123", channel_type="web", reason="rate_limit", ) assert event.message_id == "msg123" assert event.reason == "rate_limit" def test_to_dict(self): event = MessageBlocked( message_id="msg123", channel_type="web", reason="rate_limit", ) d = event.to_dict() assert d["reason"] == "rate_limit" class TestMessageReplied: def test_creation(self): event = MessageReplied( message_id="msg123", channel_type="web", reply_content="Hello back", ) assert event.message_id == "msg123" assert event.reply_content == "Hello back" def test_to_dict(self): event = MessageReplied( message_id="msg123", channel_type="web", reply_content="Hello back", ) d = event.to_dict() assert d["reply_content"] == "Hello back" class TestAgentError: def test_creation(self): event = AgentError( message_id="msg123", channel_type="web", error="timeout", ) assert event.message_id == "msg123" assert event.error == "timeout" def test_to_dict(self): event = AgentError( message_id="msg123", channel_type="web", error="timeout", ) d = event.to_dict() assert d["error"] == "timeout" class TestGatewayShutdown: def test_creation(self): event = GatewayShutdown(reason="maintenance") assert event.reason == "maintenance" def test_to_dict(self): event = GatewayShutdown(reason="maintenance") d = event.to_dict() assert d["reason"] == "maintenance"