File size: 1,552 Bytes
4b03eed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# -*- coding: utf-8 -*-
"""Event test"""
from unittest.async_case import IsolatedAsyncioTestCase
from utils import AnyString
from agentscope.event import ReplyStartEvent


class EventTest(IsolatedAsyncioTestCase):
    """The event test case."""

    async def asyncSetUp(self) -> None:
        """The async setup method."""

    async def test_model_dump(self) -> None:
        """Test model dump."""
        event = ReplyStartEvent(
            session_id="test_session",
            reply_id="test_reply",
            name="Friday",
        ).model_dump()
        self.assertDictEqual(
            event,
            {
                "type": "REPLY_START",
                "id": AnyString(),
                "created_at": AnyString(),
                "metadata": {},
                "session_id": "test_session",
                "reply_id": "test_reply",
                "name": "Friday",
                "role": "assistant",
            },
        )
        self.assertIsInstance(event["type"], str)

    async def test_model_validate(self) -> None:
        """Test model validate."""
        data = {
            "type": "REPLY_START",
            "id": "test_id",
            "created_at": "2024-01-01T00:00:00",
            "session_id": "test_session",
            "reply_id": "test_reply",
            "name": "Friday",
            "role": "assistant",
        }
        ReplyStartEvent.model_validate(data)

    async def asyncTearDown(self) -> None:
        """The async teardown method."""