@@ -45,6 +45,29 @@ async def test_self_events(self):
4545 # The listener should not be executed
4646 assert self .mock_received_requests .get ("/chat.postMessage" ) is None
4747
48+ @pytest .mark .asyncio
49+ async def test_self_events_response_url (self ):
50+ app = AsyncApp (client = self .web_client )
51+ app .event ("message" )(whats_up )
52+ request = AsyncBoltRequest (body = response_url_message_event , mode = "socket_mode" )
53+ response = await app .async_dispatch (request )
54+ assert response .status == 200
55+ await assert_auth_test_count_async (self , 1 )
56+ await asyncio .sleep (1 ) # wait a bit after auto ack()
57+ # The listener should not be executed
58+ assert self .mock_received_requests .get ("/chat.postMessage" ) is None
59+
60+ @pytest .mark .asyncio
61+ async def test_not_self_events_response_url (self ):
62+ app = AsyncApp (client = self .web_client )
63+ app .event ("message" )(whats_up )
64+ request = AsyncBoltRequest (body = different_app_response_url_message_event , mode = "socket_mode" )
65+ response = await app .async_dispatch (request )
66+ assert response .status == 200
67+ await assert_auth_test_count_async (self , 1 )
68+ await asyncio .sleep (1 ) # wait a bit after auto ack()
69+ assert self .mock_received_requests .get ("/chat.postMessage" ) == 1
70+
4871 @pytest .mark .asyncio
4972 async def test_self_events_disabled (self ):
5073 app = AsyncApp (client = self .web_client , ignoring_self_events_enabled = False )
@@ -82,6 +105,50 @@ async def test_self_events_disabled(self):
82105}
83106
84107
108+ response_url_message_event = {
109+ "token" : "verification_token" ,
110+ "team_id" : "T111" ,
111+ "enterprise_id" : "E111" ,
112+ "api_app_id" : "A111" ,
113+ "event" : {
114+ "type" : "message" ,
115+ "subtype" : "bot_message" ,
116+ "text" : "Hi there! This is a reply using response_url." ,
117+ "ts" : "1658282075.825129" ,
118+ "bot_id" : "BZYBOTHED" ,
119+ "channel" : "C111" ,
120+ "event_ts" : "1658282075.825129" ,
121+ "channel_type" : "channel" ,
122+ },
123+ "type" : "event_callback" ,
124+ "event_id" : "Ev111" ,
125+ "event_time" : 1599616881 ,
126+ "authed_users" : ["W111" ],
127+ }
128+
129+
130+ different_app_response_url_message_event = {
131+ "token" : "verification_token" ,
132+ "team_id" : "T111" ,
133+ "enterprise_id" : "E111" ,
134+ "api_app_id" : "A111" ,
135+ "event" : {
136+ "type" : "message" ,
137+ "subtype" : "bot_message" ,
138+ "text" : "Hi there! This is a reply using response_url." ,
139+ "ts" : "1658282075.825129" ,
140+ "bot_id" : "B_DIFFERENT_ONE" ,
141+ "channel" : "C111" ,
142+ "event_ts" : "1658282075.825129" ,
143+ "channel_type" : "channel" ,
144+ },
145+ "type" : "event_callback" ,
146+ "event_id" : "Ev111" ,
147+ "event_time" : 1599616881 ,
148+ "authed_users" : ["W111" ],
149+ }
150+
151+
85152async def whats_up (body , say , payload , event ):
86153 assert body ["event" ] == payload
87154 assert payload == event
0 commit comments