From 0d26abc0b28b38be39b4ea3db70a49d90b1e55bb Mon Sep 17 00:00:00 2001 From: tracyboehrer Date: Thu, 8 Oct 2020 12:38:08 -0500 Subject: [PATCH] SkillHandler doesn't return ResourceResponse when forwarding activities --- .../tests/skills/test_skill_handler.py | 57 +++++++++++-------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/libraries/botbuilder-core/tests/skills/test_skill_handler.py b/libraries/botbuilder-core/tests/skills/test_skill_handler.py index 77b8728af..f6a7649db 100644 --- a/libraries/botbuilder-core/tests/skills/test_skill_handler.py +++ b/libraries/botbuilder-core/tests/skills/test_skill_handler.py @@ -2,11 +2,16 @@ import json from uuid import uuid4 from asyncio import Future -from typing import Dict, List +from typing import Dict, List, Callable from unittest.mock import Mock, MagicMock import aiounittest +from botframework.connector.auth import ( + AuthenticationConfiguration, + AuthenticationConstants, + ClaimsIdentity, +) from botbuilder.core import ( TurnContext, BotActionNotImplementedError, @@ -28,11 +33,6 @@ Transcript, CallerIdConstants, ) -from botframework.connector.auth import ( - AuthenticationConfiguration, - AuthenticationConstants, - ClaimsIdentity, -) class ConversationIdFactoryForTest(ConversationIdFactoryBase): @@ -206,10 +206,30 @@ async def test_on_send_to_conversation(self): ) mock_adapter = Mock() - mock_adapter.continue_conversation = MagicMock(return_value=Future()) - mock_adapter.continue_conversation.return_value.set_result(Mock()) - mock_adapter.send_activities = MagicMock(return_value=Future()) - mock_adapter.send_activities.return_value.set_result([]) + + async def continue_conversation( + reference: ConversationReference, + callback: Callable, + bot_id: str = None, + claims_identity: ClaimsIdentity = None, + audience: str = None, + ): # pylint: disable=unused-argument + await callback( + TurnContext( + mock_adapter, + conversation_reference_extension.get_continuation_activity( + self._conversation_reference + ), + ) + ) + + async def send_activities( + context: TurnContext, activities: List[Activity] + ): # pylint: disable=unused-argument + return [ResourceResponse(id="resourceId")] + + mock_adapter.continue_conversation = continue_conversation + mock_adapter.send_activities = send_activities sut = self.create_skill_handler_for_testing(mock_adapter) @@ -218,25 +238,12 @@ async def test_on_send_to_conversation(self): assert not activity.caller_id - await sut.test_on_send_to_conversation( + resource_response = await sut.test_on_send_to_conversation( self._claims_identity, self._conversation_id, activity ) - args, kwargs = mock_adapter.continue_conversation.call_args_list[0] - - assert isinstance(args[0], ConversationReference) - assert callable(args[1]) - assert isinstance(kwargs["claims_identity"], ClaimsIdentity) - - await args[1]( - TurnContext( - mock_adapter, - conversation_reference_extension.get_continuation_activity( - self._conversation_reference - ), - ) - ) assert activity.caller_id is None + assert resource_response.id == "resourceId" async def test_forwarding_on_send_to_conversation(self): self._conversation_id = await self._test_id_factory.create_skill_conversation_id(