22import time
33from urllib .parse import quote
44
5- import pytest
65from slack_sdk .web import WebClient
76
87from slack_bolt import App , BoltRequest , BoltContext
98from slack_bolt .context .say_stream .say_stream import SayStream
109from slack_bolt .middleware .assistant import Assistant
11- from slack_bolt .warning import ExperimentalWarning
1210from tests .mock_web_api_server import (
1311 setup_mock_web_api_server ,
1412 cleanup_mock_web_api_server ,
@@ -91,11 +89,14 @@ def test_say_stream_in_user_message(self):
9189 called = {"value" : False }
9290
9391 @app .message ("" )
94- def handle_user_message (say_stream : SayStream ):
92+ def handle_user_message (say_stream : SayStream , context : BoltContext ):
9593 assert say_stream is not None
9694 assert isinstance (say_stream , SayStream )
95+ assert say_stream == context .say_stream
9796 assert say_stream .channel == "C111"
9897 assert say_stream .thread_ts == "1610261659.001400"
98+ assert say_stream .recipient_team_id == context .team_id
99+ assert say_stream .recipient_user_id == context .user_id
99100 called ["value" ] = True
100101
101102 request = BoltRequest (body = user_message_event_payload , mode = "socket_mode" )
@@ -108,44 +109,35 @@ def test_say_stream_in_bot_message(self):
108109 called = {"value" : False }
109110
110111 @app .message ("" )
111- def handle_bot_message (say_stream : SayStream ):
112+ def handle_bot_message (say_stream : SayStream , context : BoltContext ):
112113 assert say_stream is not None
113114 assert isinstance (say_stream , SayStream )
115+ assert say_stream == context .say_stream
114116 assert say_stream .channel == "C111"
115117 assert say_stream .thread_ts == "1610261539.000900"
118+ assert say_stream .recipient_team_id == context .team_id
119+ assert say_stream .recipient_user_id == context .user_id
116120 called ["value" ] = True
117121
118122 request = BoltRequest (body = bot_message_event_payload , mode = "socket_mode" )
119123 response = app .dispatch (request )
120124 assert response .status == 200
121125 assert_target_called (called )
122126
123- def test_say_stream_kwarg_emits_experimental_warning (self ):
124- app = App (client = self .web_client )
125- called = {"value" : False }
126-
127- @app .event ("app_mention" )
128- def handle_mention (say_stream : SayStream ):
129- with pytest .warns (ExperimentalWarning , match = "say_stream is experimental" ):
130- say_stream ()
131- called ["value" ] = True
132-
133- request = BoltRequest (body = app_mention_event_body , mode = "socket_mode" )
134- response = app .dispatch (request )
135- assert response .status == 200
136- assert_target_called (called )
137-
138127 def test_say_stream_in_assistant_thread_started (self ):
139128 app = App (client = self .web_client )
140129 assistant = Assistant ()
141130 called = {"value" : False }
142131
143132 @assistant .thread_started
144- def start_thread (say_stream : SayStream ):
133+ def start_thread (say_stream : SayStream , context : BoltContext ):
145134 assert say_stream is not None
146135 assert isinstance (say_stream , SayStream )
136+ assert say_stream == context .say_stream
147137 assert say_stream .channel == "D111"
148138 assert say_stream .thread_ts == "1726133698.626339"
139+ assert say_stream .recipient_team_id == context .team_id
140+ assert say_stream .recipient_user_id == context .user_id
149141 called ["value" ] = True
150142
151143 app .assistant (assistant )
@@ -161,11 +153,14 @@ def test_say_stream_in_assistant_user_message(self):
161153 called = {"value" : False }
162154
163155 @assistant .user_message
164- def handle_user_message (say_stream : SayStream ):
156+ def handle_user_message (say_stream : SayStream , context : BoltContext ):
165157 assert say_stream is not None
166158 assert isinstance (say_stream , SayStream )
159+ assert say_stream == context .say_stream
167160 assert say_stream .channel == "D111"
168161 assert say_stream .thread_ts == "1726133698.626339"
162+ assert say_stream .recipient_team_id == context .team_id
163+ assert say_stream .recipient_user_id == context .user_id
169164 called ["value" ] = True
170165
171166 app .assistant (assistant )
0 commit comments