Repository: microsoft/botbuilder-python
Pull request #317 (2019-09-17 16:45:43)

[Parity w/ Dotnet] create_conversation tentant_id/channel_data
Parity:

* https://github.com/microsoft/botbuilder-dotnet/pull/2481
* https://github.com/microsoft/botbuilder-js/pull/1173

Keeps tentant_id & channel_data in create_conversation

**I'm not confident I wrote the test appropriately. It works, but I'm not sure I went about it the best way.** Let me know if you'd like something changed.

**Before Change**
![image](https://user-images.githubusercontent.com/40401643/65062075-2097fd00-d930-11e9-863b-5443c9214d23.png)


**After Change**
![image](https://user-images.githubusercontent.com/40401643/65062086-268dde00-d930-11e9-8d7d-82a91773316e.png)


cleemullins: @axelsrz Can you take a quick look? 
axelsrz: Because this PR is from a fork it won't trigger the coverage. I'm merging manually

Patch:
diff --git a/libraries/botbuilder-core/botbuilder/core/bot_framework_adapter.py b/libraries/botbuilder-core/botbuilder/core/bot_framework_adapter.py
index 00cc672c..aaac1119 100644
--- a/libraries/botbuilder-core/botbuilder/core/bot_framework_adapter.py
+++ b/libraries/botbuilder-core/botbuilder/core/bot_framework_adapter.py
@@ -180,7 +180,10 @@ class BotFrameworkAdapter(BotAdapter, UserTokenProvider):
             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
 


Test patch:
diff --git a/libraries/botbuilder-core/tests/test_bot_framework_adapter.py b/libraries/botbuilder-core/tests/test_bot_framework_adapter.py
index e0779df4..6532b1e5 100644
--- a/libraries/botbuilder-core/tests/test_bot_framework_adapter.py
+++ b/libraries/botbuilder-core/tests/test_bot_framework_adapter.py
@@ -4,6 +4,7 @@
 from copy import copy, deepcopy
 from unittest.mock import Mock
 import unittest
+import uuid
 import aiounittest
 
 from botbuilder.core import (
@@ -16,6 +17,7 @@ from botbuilder.schema import (
     ActivityTypes,
     ConversationAccount,
     ConversationReference,
+    ConversationResourceResponse,
     ChannelAccount,
 )
 from botframework.connector.aio import ConnectorClient
@@ -124,7 +126,12 @@ class AdapterUnderTest(BotFrameworkAdapter):
             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
@@ -247,3 +254,36 @@ class TestBotFrameworkAdapter(aiounittest.AsyncTestCase):
             )
 
         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.")