Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@ async def create_conversation(
request = TurnContext.apply_conversation_reference(
Activity(), reference, is_incoming=True
)
request.conversation = ConversationAccount(id=resource_response.id)
request.conversation = ConversationAccount(
id=resource_response.id, tenant_id=parameters.tenant_id
)
request.channel_data = parameters.channel_data
if resource_response.service_url:
request.service_url = resource_response.service_url

Expand Down
42 changes: 41 additions & 1 deletion libraries/botbuilder-core/tests/test_bot_framework_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from copy import copy, deepcopy
from unittest.mock import Mock
import unittest
import uuid
import aiounittest

from botbuilder.core import (
Expand All @@ -16,6 +17,7 @@
ActivityTypes,
ConversationAccount,
ConversationReference,
ConversationResourceResponse,
ChannelAccount,
)
from botframework.connector.aio import ConnectorClient
Expand Down Expand Up @@ -124,7 +126,12 @@ async def mock_create_conversation(parameters):
self.tester.assertIsNotNone(
parameters, "create_conversation not passed parameters"
)
return not self.fail_auth
response = ConversationResourceResponse(
activity_id=REFERENCE.activity_id,
service_url=REFERENCE.service_url,
id=uuid.uuid4(),
)
return response

connector_client_mock.conversations.reply_to_activity.side_effect = (
mock_reply_to_activity
Expand Down Expand Up @@ -247,3 +254,36 @@ async def aux_func_assert_tenant_id_copied(context):
)

await adapter.process_activity(incoming, "", aux_func_assert_tenant_id_copied)

async def test_should_create_valid_conversation_for_msteams(self):

tenant_id = "testTenant"

reference = deepcopy(REFERENCE)
reference.conversation.tenant_id = tenant_id
reference.channel_data = {"tenant": {"id": tenant_id}}
adapter = AdapterUnderTest()

called = False

async def aux_func_assert_valid_conversation(context):
self.assertIsNotNone(context, "context not passed")
self.assertIsNotNone(context.activity, "context has no request")
self.assertIsNotNone(
context.activity.conversation, "request has invalid conversation"
)
self.assertEqual(
context.activity.conversation.tenant_id,
tenant_id,
"request has invalid tenant_id on conversation",
)
self.assertEqual(
context.activity.channel_data["tenant"]["id"],
tenant_id,
"request has invalid tenant_id in channel_data",
)
nonlocal called
called = True

await adapter.create_conversation(reference, aux_func_assert_valid_conversation)
self.assertTrue(called, "bot logic not called.")