@@ -24,23 +24,21 @@ async def test_assistant_event_attaches_kwargs(self):
2424 middleware = AsyncAttachingAgentKwargs ()
2525 req = AsyncBoltRequest (body = thread_started_event_body , mode = "socket_mode" )
2626 req .context ["client" ] = AsyncWebClient (token = "xoxb-test" )
27- resp = BoltResponse (status = 404 )
2827
29- resp = await middleware .async_process (req = req , resp = resp , next = next )
28+ resp = await middleware .async_process (req = req , resp = BoltResponse ( status = 404 ) , next = next )
3029
3130 assert resp .status == 200
3231 for key in AGENT_KWARGS :
3332 assert key in req .context , f"{ key } should be set on context"
3433 assert req .context ["say" ].thread_ts == "1726133698.626339"
3534
3635 @pytest .mark .asyncio
37- async def test_user_message_assistant_event_attaches_kwargs (self ):
36+ async def test_user_message_event_attaches_kwargs (self ):
3837 middleware = AsyncAttachingAgentKwargs ()
3938 req = AsyncBoltRequest (body = user_message_event_body , mode = "socket_mode" )
4039 req .context ["client" ] = AsyncWebClient (token = "xoxb-test" )
41- resp = BoltResponse (status = 404 )
4240
43- resp = await middleware .async_process (req = req , resp = resp , next = next )
41+ resp = await middleware .async_process (req = req , resp = BoltResponse ( status = 404 ) , next = next )
4442
4543 assert resp .status == 200
4644 for key in AGENT_KWARGS :
@@ -52,43 +50,20 @@ async def test_non_assistant_event_does_not_attach_kwargs(self):
5250 middleware = AsyncAttachingAgentKwargs ()
5351 req = AsyncBoltRequest (body = channel_user_message_event_body , mode = "socket_mode" )
5452 req .context ["client" ] = AsyncWebClient (token = "xoxb-test" )
55- resp = BoltResponse (status = 404 )
5653
57- resp = await middleware .async_process (req = req , resp = resp , next = next )
54+ resp = await middleware .async_process (req = req , resp = BoltResponse ( status = 404 ) , next = next )
5855
5956 assert resp .status == 200
6057 for key in AGENT_KWARGS :
6158 assert key not in req .context , f"{ key } should not be set on context"
6259
6360 @pytest .mark .asyncio
64- async def test_non_event_body_does_not_attach_kwargs (self ):
61+ async def test_non_event_does_not_attach_kwargs (self ):
6562 middleware = AsyncAttachingAgentKwargs ()
6663 req = AsyncBoltRequest (body = "payload={}" , headers = {})
67- resp = BoltResponse (status = 404 )
6864
69- resp = await middleware .async_process (req = req , resp = resp , next = next )
65+ resp = await middleware .async_process (req = req , resp = BoltResponse ( status = 404 ) , next = next )
7066
7167 assert resp .status == 200
7268 for key in AGENT_KWARGS :
7369 assert key not in req .context , f"{ key } should not be set on context"
74-
75- @pytest .mark .asyncio
76- async def test_next_always_called (self ):
77- middleware = AsyncAttachingAgentKwargs ()
78- call_state = {"called" : False }
79-
80- async def tracking_next ():
81- call_state ["called" ] = True
82- return BoltResponse (status = 200 )
83-
84- # With assistant event
85- req = AsyncBoltRequest (body = thread_started_event_body , mode = "socket_mode" )
86- req .context ["client" ] = AsyncWebClient (token = "xoxb-test" )
87- await middleware .async_process (req = req , resp = BoltResponse (status = 404 ), next = tracking_next )
88- assert call_state ["called" ] is True
89-
90- # With non-event body
91- call_state ["called" ] = False
92- req = AsyncBoltRequest (body = "payload={}" , headers = {})
93- await middleware .async_process (req = req , resp = BoltResponse (status = 404 ), next = tracking_next )
94- assert call_state ["called" ] is True
0 commit comments