2
2
import json
3
3
from uuid import uuid4
4
4
from asyncio import Future
5
- from typing import Dict , List
5
+ from typing import Dict , List , Callable
6
6
7
7
from unittest .mock import Mock , MagicMock
8
8
import aiounittest
9
9
10
+ from botframework .connector .auth import (
11
+ AuthenticationConfiguration ,
12
+ AuthenticationConstants ,
13
+ ClaimsIdentity ,
14
+ )
10
15
from botbuilder .core import (
11
16
TurnContext ,
12
17
BotActionNotImplementedError ,
28
33
Transcript ,
29
34
CallerIdConstants ,
30
35
)
31
- from botframework .connector .auth import (
32
- AuthenticationConfiguration ,
33
- AuthenticationConstants ,
34
- ClaimsIdentity ,
35
- )
36
36
37
37
38
38
class ConversationIdFactoryForTest (ConversationIdFactoryBase ):
@@ -206,10 +206,30 @@ async def test_on_send_to_conversation(self):
206
206
)
207
207
208
208
mock_adapter = Mock ()
209
- mock_adapter .continue_conversation = MagicMock (return_value = Future ())
210
- mock_adapter .continue_conversation .return_value .set_result (Mock ())
211
- mock_adapter .send_activities = MagicMock (return_value = Future ())
212
- mock_adapter .send_activities .return_value .set_result ([])
209
+
210
+ async def continue_conversation (
211
+ reference : ConversationReference ,
212
+ callback : Callable ,
213
+ bot_id : str = None ,
214
+ claims_identity : ClaimsIdentity = None ,
215
+ audience : str = None ,
216
+ ): # pylint: disable=unused-argument
217
+ await callback (
218
+ TurnContext (
219
+ mock_adapter ,
220
+ conversation_reference_extension .get_continuation_activity (
221
+ self ._conversation_reference
222
+ ),
223
+ )
224
+ )
225
+
226
+ async def send_activities (
227
+ context : TurnContext , activities : List [Activity ]
228
+ ): # pylint: disable=unused-argument
229
+ return [ResourceResponse (id = "resourceId" )]
230
+
231
+ mock_adapter .continue_conversation = continue_conversation
232
+ mock_adapter .send_activities = send_activities
213
233
214
234
sut = self .create_skill_handler_for_testing (mock_adapter )
215
235
@@ -218,25 +238,12 @@ async def test_on_send_to_conversation(self):
218
238
219
239
assert not activity .caller_id
220
240
221
- await sut .test_on_send_to_conversation (
241
+ resource_response = await sut .test_on_send_to_conversation (
222
242
self ._claims_identity , self ._conversation_id , activity
223
243
)
224
244
225
- args , kwargs = mock_adapter .continue_conversation .call_args_list [0 ]
226
-
227
- assert isinstance (args [0 ], ConversationReference )
228
- assert callable (args [1 ])
229
- assert isinstance (kwargs ["claims_identity" ], ClaimsIdentity )
230
-
231
- await args [1 ](
232
- TurnContext (
233
- mock_adapter ,
234
- conversation_reference_extension .get_continuation_activity (
235
- self ._conversation_reference
236
- ),
237
- )
238
- )
239
245
assert activity .caller_id is None
246
+ assert resource_response .id == "resourceId"
240
247
241
248
async def test_forwarding_on_send_to_conversation (self ):
242
249
self ._conversation_id = await self ._test_id_factory .create_skill_conversation_id (
0 commit comments