@@ -80,7 +80,7 @@ class FakeBot(Bot):
8080
8181
8282@pytest .mark .asyncio
83- async def test_got_call (app : App ):
83+ async def test_got_call_api (app : App ):
8484 async with app .test_api () as ctx :
8585 adapter = ctx .create_adapter ()
8686 bot = ctx .create_bot (self_id = "test" , adapter = adapter )
@@ -92,6 +92,23 @@ async def test_got_call(app: App):
9292
9393 assert "test" not in get_bots ()
9494
95+ async with app .test_api () as ctx :
96+ adapter = ctx .create_adapter ()
97+ bot = ctx .create_bot (self_id = "test" , adapter = adapter )
98+ assert "test" in get_bots ()
99+ api = ctx .should_call_api (
100+ "test" , {"key" : "value" }, exception = RuntimeError (), adapter = adapter
101+ )
102+ with pytest .raises (RuntimeError ):
103+ result = await bot .call_api ("test" , key = "value" )
104+
105+ assert ctx .wait_list .empty ()
106+
107+ assert "test" not in get_bots ()
108+
109+
110+ @pytest .mark .asyncio
111+ async def test_got_call_send (app : App ):
95112 async with app .test_api () as ctx :
96113 bot = ctx .create_bot (self_id = "test" )
97114 assert "test" in get_bots ()
@@ -102,3 +119,17 @@ async def test_got_call(app: App):
102119 assert result == "result"
103120
104121 assert "test" not in get_bots ()
122+
123+ async with app .test_api () as ctx :
124+ bot = ctx .create_bot (self_id = "test" )
125+ assert "test" in get_bots ()
126+ event = make_fake_event ()()
127+ api = ctx .should_call_send (
128+ event , "test" , exception = RuntimeError (), bot = bot , key = "value"
129+ )
130+ with pytest .raises (RuntimeError ):
131+ result = await bot .send (event , "test" , key = "value" )
132+
133+ assert ctx .wait_list .empty ()
134+
135+ assert "test" not in get_bots ()
0 commit comments