Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SkillHandler doesn't return ResourceResponse when forwarding activities #1404

Merged
merged 2 commits into from
Oct 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 32 additions & 25 deletions libraries/botbuilder-core/tests/skills/test_skill_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -28,11 +33,6 @@
Transcript,
CallerIdConstants,
)
from botframework.connector.auth import (
AuthenticationConfiguration,
AuthenticationConstants,
ClaimsIdentity,
)


class ConversationIdFactoryForTest(ConversationIdFactoryBase):
Expand Down Expand Up @@ -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)

Expand All @@ -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(
Expand Down