8000 Merge branch 'master' into trboehre/httpclient-gov-credentials · Santhosh0505/botbuilder-python@0038211 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0038211

Browse files
authored
Merge branch 'master' into trboehre/httpclient-gov-credentials
2 parents 404ef6b + 27aa2a7 commit 0038211

File tree

7 files changed

+74
-13
lines changed

7 files changed

+74
-13
lines changed

libraries/botbuilder-ai/README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
BotBuilder-AI SDK for Python
44
============================
55

6-
.. image:: https://fuselabs.visualstudio.com/SDK_v4/_apis/build/status/Python/SDK_v4-Python-CI?branchName=master
7-
:target: https://fuselabs.visualstudio.com/SDK_v4/_apis/build/status/Python/SDK_v4-Python-CI
6+
.. image:: https://dev.azure.com/FuseLabs/SDK_v4/_apis/build/status/Python/Python-CI-PR-yaml?branchName=master
7+
:target: https://dev.azure.com/FuseLabs/SDK_v4/_apis/build/status/Python/Python-CI-PR-yaml?branchName=master
88
:align: right
99
:alt: Azure DevOps status for master branch
1010
.. image:: https://badge.fury.io/py/botbuilder-ai.svg

libraries/botbuilder-core/botbuilder/core/adapters/test_adapter.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import asyncio
99
import inspect
10+
import uuid
1011
from datetime import datetime
1112
from uuid import uuid4
1213
from typing import Awaitable, Coroutine, Dict, List, Callable, Union
@@ -215,6 +216,19 @@ async def continue_conversation(
215216
reference, callback, bot_id, claims_identity, audience
216217
)
217218

219+
async def create_conversation(
220+
self, channel_id: str, callback: Callable # pylint: disable=unused-argument
221+
):
222+
self.activity_buffer.clear()
223+
update = Activity(
224+
type=ActivityTypes.conversation_update,
225+
members_added=[],
226+
members_removed=[],
227+
conversation=ConversationAccount(id=str(uuid.uuid4())),
228+
)
229+
context = TurnContext(self, update)
230+
return await callback(context)
231+
218232
async def receive_activity(self, activity):
219233
"""
220234
INTERNAL: called by a `TestFlow` instance to simulate a user sending a message to the bot.

libraries/botbuilder-core/botbuilder/core/bot_framework_adapter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ async def create_conversation(
351351
if reference.conversation and reference.conversation.tenant_id:
352352
# Putting tenant_id in channel_data is a temporary while we wait for the Teams API to be updated
353353
parameters.channel_data = {
354-
"tenant": {"id": reference.conversation.tenant_id}
354+
"tenant": {"tenantId": reference.conversation.tenant_id}
355355
}
356356

357357
# Permanent solution is to put tenant_id in parameters.tenant_id

libraries/botbuilder-core/botbuilder/core/telemetry_logger_middleware.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,21 @@ async def fill_receive_event_properties(
160160
BotTelemetryClient.track_event method for the BotMessageReceived event.
161161
"""
162162
properties = {
163-
TelemetryConstants.FROM_ID_PROPERTY: activity.from_property.id,
163+
TelemetryConstants.FROM_ID_PROPERTY: activity.from_property.id
164+
if activity.from_property
165+
else None,
164166
TelemetryConstants.CONVERSATION_NAME_PROPERTY: activity.conversation.name,
165167
TelemetryConstants.LOCALE_PROPERTY: activity.locale,
166168
TelemetryConstants.RECIPIENT_ID_PROPERTY: activity.recipient.id,
167-
TelemetryConstants.RECIPIENT_NAME_PROPERTY: activity.from_property.name,
169+
TelemetryConstants.RECIPIENT_NAME_PROPERTY: activity.recipient.name,
168170
}
169171

170172
if self.log_personal_information:
171-
if activity.from_property.name and activity.from_property.name.strip():
173+
if (
174+
activity.from_property
175+
and activity.from_property.name
176+
and activity.from_property.name.strip()
177+
):
172178
properties[
173179
TelemetryConstants.FROM_NAME_PROPERTY
174180
] = activity.from_property.name

libraries/botbuilder-core/tests/test_bot_framework_adapter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ async def aux_func_assert_valid_conversation(context):
303303
"request has invalid tenant_id on conversation",
304304
)
305305
self.assertEqual(
306-
context.activity.channel_data["tenant"]["id"],
306+
context.activity.channel_data["tenant"]["tenantId"],
307307
tenant_id,
308308
"request has invalid tenant_id in channel_data",
309309
)

libraries/botbuilder-core/tests/test_telemetry_middleware.py

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
# pylint: disable=line-too-long,missing-docstring,unused-variable
55
import copy
6+
import uuid
67
from typing import Dict
78
from unittest.mock import Mock
89
import aiounittest
@@ -28,6 +29,47 @@ async def test_create_middleware(self):
2829
my_logger = TelemetryLoggerMiddleware(telemetry, True)
2930
assert my_logger
3031

32+
async def test_do_not_throw_on_null_from(self):
33+
telemetry = Mock()
34+
my_logger = TelemetryLoggerMiddleware(telemetry, False)
35+
36+
adapter = TestAdapter(
37+
template_or_conversation=Activity(
38+
channel_id="test",
39+
recipient=ChannelAccount(id="bot", name="Bot"),
40+
conversation=ConversationAccount(id=str(uuid.uuid4())),
41+
)
42+
)
43+
adapter.use(my_logger)
44+
45+
async def send_proactive(context: TurnContext):
46+
await context.send_activity("proactive")
47+
48+
async def logic(context: TurnContext):
49+
await adapter.create_conversation(
50+
context.activity.channel_id, send_proactive,
51+
)
52+
53+
adapter.logic = logic
54+
55+
test_flow = TestFlow(None, adapter)
56+
await test_flow.send("foo")
57+
await test_flow.assert_reply("proactive")
58+
59+
telemetry_calls = [
60+
(
61+
TelemetryLoggerConstants.BOT_MSG_RECEIVE_EVENT,
62+
{
63+
"fromId": None,
64+
"conversationName": None,
65+
"locale": None,
66+
"recipientId": "bot",
67+
"recipientName": "Bot",
68+
},
69+
),
70+
]
71+
self.assert_telemetry_calls(telemetry, telemetry_calls)
72+
3173
async def test_should_send_receive(self):
3274
telemetry = Mock()
3375
my_logger = TelemetryLoggerMiddleware(telemetry, True)
@@ -55,7 +97,7 @@ async def logic(context: TurnContext):
5597
"conversationName": None,
5698
"locale": None,
5799
"recipientId": "bot",
58-
"recipientName": "user",
100+
"recipientName": "Bot",
59101
},
60102
),
61103
(
@@ -76,7 +118,7 @@ async def logic(context: TurnContext):
76118
"conversationName": None,
77119
"locale": None,
78120
"recipientId": "bot",
79-
"recipientName": "user",
121+
"recipientName": "Bot",
80122
"fromName": "user",
81123
},
82124
),
@@ -147,7 +189,7 @@ async def process(context: TurnContext) -> None:
147189
"conversationName": None,
148190
"locale": None,
149191
"recipientId": "bot",
150-
"recipientName": "user",
192+
"recipientName": "Bot",
151193
},
152194
),
153195
(
@@ -169,7 +211,7 @@ async def process(context: TurnContext) -> None:
169211
"conversationName": None,
170212
"locale": None,
171213
"recipientId": "bot",
172-
"recipientName": "user",
214+
"recipientName": "Bot",
173215
"fromName": "user",
174216
},
175217
),

libraries/botbuilder-integration-aiohttp/botbuilder/integration/aiohttp/bot_framework_http_client.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ async def post_activity(
116116
data = (await resp.read()).decode()
117117
content = json.loads(data) if data else None
118118

119-
if content:
120-
return InvokeResponse(status=resp.status, body=content)
119+
return InvokeResponse(status=resp.status, body=content)
121120

122121
finally:
123122
# Restore activity properties.

0 commit comments

Comments
 (0)
0