11import asyncio
2+
23import pytest
3- from typing import Callable , Awaitable , AsyncIterator
44
5- from coagent .core .types import Address , RawMessage , Channel , Subscription
5+ from coagent .core .types import Address
66from coagent .core .agent import BaseAgent , Context , handler
77from coagent .core .messages import Cancel , Message
88
99
10- class TestChannel (Channel ):
11- async def connect (self ) -> None :
12- pass
13-
14- async def close (self ) -> None :
15- pass
16-
17- async def publish (
18- self ,
19- addr : Address ,
20- msg : RawMessage ,
21- request : bool = False ,
22- reply : str = "" ,
23- timeout : float = 0.5 ,
24- probe : bool = True ,
25- ) -> RawMessage | None :
26- pass
27-
28- async def publish_multi (
29- self ,
30- addr : Address ,
31- msg : RawMessage ,
32- probe : bool = True ,
33- ) -> AsyncIterator [RawMessage ]:
34- pass
35-
36- async def subscribe (
37- self ,
38- addr : Address ,
39- handler : Callable [[RawMessage ], Awaitable [None ]],
40- queue : str = "" ,
41- ) -> Subscription :
42- pass
43-
44- async def new_reply_topic (self ) -> str :
45- pass
46-
47-
4810class Run (Message ):
4911 pass
5012
@@ -64,9 +26,9 @@ async def handle(self, msg: Run, ctx: Context) -> None:
6426
6527class TestBlockingAgent :
6628 @pytest .mark .asyncio
67- async def test_receive (self ):
29+ async def test_receive (self , test_channel ):
6830 agent = BlockingAgent ()
69- agent .init (TestChannel () , Address (name = "test" , id = "0" ))
31+ agent .init (test_channel , Address (name = "test" , id = "0" ))
7032 await agent .start ()
7133
7234 await agent .receive (Run ().encode ())
0 commit comments