8000 Adding directlinespeech & test channels in channels.py (#2143) · Attels/botbuilder-python@9a70940 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9a70940

Browse files
Adding directlinespeech & test channels in channels.py (microsoft#2143)
Co-authored-by: tracyboehrer <tracyboehrer@users.noreply.github.com>
1 parent a2cccb3 commit 9a70940
8000

File tree

18 files changed

+60
-32
lines changed

18 files changed

+60
-32
lines changed

libraries/botbuilder-adapters-slack/botbuilder/adapters/slack/slack_helper.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
ChannelAccount,
1616
ActivityTypes,
1717
)
18+
from botframework.connector import Channels
1819

1920
from .slack_message import SlackMessage
2021
from .slack_client import SlackClient
@@ -125,7 +126,7 @@ def payload_to_activity(payload: SlackPayload) -> Activity:
125126
raise Exception("payload is required")
126127

127128
activity = Activity(
128-
channel_id="slack",
129+
channel_id=Channels.slack,
129130
conversation=ConversationAccount(id=payload.channel["id"], properties={}),
130131
from_property=ChannelAccount(
131132
id=(
@@ -178,7 +179,7 @@ async def event_to_activity(event: SlackEvent, client: SlackClient) -> Activity:
178179

179180
activity = Activity(
180181
id=event.event_ts,
181-
channel_id="slack",
182+
channel_id=Channels.slack,
182183
conversation=ConversationAccount(
183184
id=event.channel if event.channel else event.channel_id, properties={}
184185
),
@@ -235,7 +236,7 @@ async def command_to_activity(
235236

236237
activity = Activity(
237238
id=body.trigger_id,
238-
channel_id="slack",
239+
channel_id=Channels.slack,
239240
conversation=ConversationAccount(id=body.channel_id, properties={}),
240241
from_property=ChannelAccount(id=body.user_id),
241242
recipient=ChannelAccount(id=None),

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from ..bot_adapter import BotAdapter
3232
from ..turn_context import TurnContext
3333
from ..oauth.extended_user_token_provider import ExtendedUserTokenProvider
34+
from botframework.connector import Channels
3435

3536

3637
class UserToken:
@@ -121,7 +122,7 @@ def __init__(
121122
template_or_conversation
122123
if isinstance(template_or_conversation, Activity)
123124
else Activity(
124-
channel_id="test",
125+
channel_id=Channels.test,
125126
service_url="https://test.com",
126127
from_property=ChannelAccount(id="User1", name="user"),
127128
recipient=ChannelAccount(id="bot", name="Bot"),
@@ -308,7 +309,7 @@ def create_conversation_reference(
308309
name: str, user: str = "User1", bot: str = "Bot"
309310
) -> ConversationReference:
310311
return ConversationReference(
311-
channel_id="test",
312+
channel_id=Channels.test,
312313
service_url="https://test.com",
313314
conversation=ConversationAccount(
314315
is_group=False,

libraries/botbuilder-core/tests/test_bot_framework_adapter.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
TokenExchangeInvokeRequest,
2828
TokenExchangeInvokeResponse,
2929
)
30+
from botframework.connector import Channels
3031
from botframework.connector.token_api.models import (
3132
TokenExchangeRequest,
3233
TokenResponse as ConnectorTokenResponse,
@@ -44,7 +45,7 @@
4445

4546
REFERENCE = ConversationReference(
4647
activity_id="1234",
47-
channel_id="test",
48+
channel_id=Channels.test,
4849
locale="en-uS", # Intentionally oddly-cased to check that it isn't defaulted somewhere, but tests stay in English
4950
service_url="https://example.org/channel",
5051
user=ChannelAccount(id="user", name="User Name"),
@@ -305,7 +306,7 @@ async def test_should_migrate_tenant_id_for_msteams(self):
305306
is_incoming=True,
306307
)
307308

308-
incoming.channel_id = "msteams"
309+
incoming.channel_id = Channels.ms_teams
309310
adapter = AdapterUnderTest()
310311

311312
async def aux_func_assert_tenant_id_copied(context):
@@ -501,7 +502,7 @@ async def callback(context: TurnContext):
501502
sut = BotFrameworkAdapter(settings)
502503
await sut.process_activity_with_identity(
503504
Activity(
504-
channel_id="emulator",
505+
channel_id=Channels.emulator,
505506
service_url=service_url,
506507
text="test",
507508
),
@@ -549,7 +550,7 @@ async def callback(context: TurnContext):
549550
sut = BotFrameworkAdapter(settings)
550551
await sut.process_activity_with_identity(
551552
Activity(
552-
channel_id="emulator",
553+
channel_id=Channels.emulator,
553554
service_url=service_url,
554555
text="test",
555556
),
@@ -709,7 +710,7 @@ async def callback(context: TurnContext):
709710

710711
inbound_activity = Activity(
711712
type=ActivityTypes.message,
712-
channel_id="emulator",
713+
channel_id=Channels.emulator,
713714
service_url="http://tempuri.org/whatever",
714715
delivery_mode=DeliveryModes.expect_replies,
715716
text="hello world",
@@ -754,7 +755,7 @@ async def callback(context: TurnContext):
754755

755756
inbound_activity = Activity(
756757
type=ActivityTypes.message,
757-
channel_id="emulator",
758+
channel_id=Channels.emulator,
758759
service_url="http://tempuri.org/whatever",
759760
delivery_mode=DeliveryModes.normal,
760761
text="hello world",

libraries/botbuilder-core/tests/test_conversation_state.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,25 @@
66
from botbuilder.core import TurnContext, MemoryStorage, ConversationState
77
from botbuilder.core.adapters import TestAdapter
88
from botbuilder.schema import Activity, ConversationAccount
9+
from botframework.connector import Channels
910

1011
RECEIVED_MESSAGE = Activity(
1112
type="message",
1213
text="received",
13-
channel_id="test",
14+
channel_id=Channels.test,
1415
conversation=ConversationAccount(id="convo"),
1516
)
1617
MISSING_CHANNEL_ID = Activity(
1718
type="message", text="received", conversation=ConversationAccount(id="convo")
1819
)
19-
MISSING_CONVERSATION = Activity(type="message", text="received", channel_id="test")
20+
MISSING_CONVERSATION = Activity(
21+
type="message",
22+
text="received",
23+
channel_id=Channels.test,
24+
)
2025
END_OF_CONVERSATION = Activity(
2126
type="endOfConversation",
22-
channel_id="test",
27+
channel_id=Channels.test,
2328
conversation=ConversationAccount(id="convo"),
2429
)
2530

libraries/botbuilder-core/tests/test_memory_transcript_store.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
ConversationAccount,
2626
ConversationReference,
2727
)
28+
from botframework.connector import Channels
2829

2930

3031
# pylint: disable=line-too-long,missing-docstring
@@ -98,7 +99,7 @@ def create_activities(self, conversation_id: str, date: datetime, count: int = 5
9899
timestamp=time_stamp,
99100
id=str(uuid.uuid4()),
100101
text=str(i),
101-
channel_id="test",
102+
channel_id=Channels.test,
102103
from_property=ChannelAccount(id=f"User{i}"),
103104
conversation=ConversationAccount(id=conversation_id),
104105
recipient=ChannelAccount(id="bot1", name="2"),
@@ -112,7 +113,7 @@ def create_activities(self, conversation_id: str, date: datetime, count: int = 5
112113
timestamp=date,
113114
id=str(uuid.uuid4()),
114115
text=str(i),
115-
channel_id="test",
116+
channel_id=Channels.test,
116117
from_property=ChannelAccount(id="Bot1", name="2"),
117118
conversation=ConversationAccount(id=conversation_id),
118119
recipient=ChannelAccount(id=f"User{i}"),

libraries/botbuilder-core/tests/test_private_conversation_state.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
from botbuilder.core import MemoryStorage, TurnContext, PrivateConversationState
77
from botbuilder.core.adapters import TestAdapter
88
from botbuilder.schema import Activity, ChannelAccount, ConversationAccount
9+
from botframework.connector import Channels
910

1011
RECEIVED_MESSAGE = Activity(
1112
text="received",
1213
type="message",
13-
channel_id="test",
14+
channel_id=Channels.test,
1415
conversation=ConversationAccount(id="convo"),
1516
from_property=ChannelAccount(id="user"),
1617
)

libraries/botbuilder-core/tests/test_telemetry_middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ async def test_do_not_throw_on_null_from(self):
4040

4141
adapter = TestAdapter(
4242
template_or_conversation=Activity(
43-
channel_id="test",
43+
channel_id=Channels.test,
4444
recipient=ChannelAccount(id="bot", name="Bot"),
4545
conversation=ConversationAccount(id=str(uuid.uuid4())),
4646
)

libraries/botbuilder-core/tests/test_test_adapter.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from botbuilder.core import TurnContext
88
from botbuilder.core.adapters import TestAdapter
99
from botbuilder.schema import Activity, ConversationReference, ChannelAccount
10+
from botframework.connector import Channels
1011

1112
RECEIVED_MESSAGE = Activity(type="message", text="received")
1213
UPDATED_ACTIVITY = Activity(type="message", text="update")
@@ -141,7 +142,7 @@ async def logic(context: TurnContext):
141142
async def test_get_user_token_returns_null(self):
142143
adapter = TestAdapter()
143144
activity = Activity(
144-
channel_id="directline", from_property=ChannelAccount(id="testuser")
145+
channel_id=Channels.direct_line, from_property=ChannelAccount(id="testuser")
145146
)
146147

147148
turn_context = TurnContext(adapter, activity)
@@ -158,7 +159,7 @@ async def test_get_user_token_returns_null(self):
158159
async def test_get_user_token_returns_null_with_code(self):
159160
adapter = TestAdapter()
160161
activity = Activity(
161-
channel_id="directline", from_property=ChannelAccount(id="testuser")
162+
channel_id=Channels.direct_line, from_property=ChannelAccount(id="testuser")
162163
)
163164

164165
turn_context = TurnContext(adapter, activity)
@@ -180,7 +181,7 @@ async def test_get_user_token_returns_null_with_code(self):
180181
async def test_get_user_token_returns_token(self):
181182
adapter = TestAdapter()
182183
connection_name = "myConnection"
183-
channel_id = "directline"
184+
channel_id = Channels.direct_line
184185
user_id = "testUser"
185186
token = "abc123"
186187
activity = Activity(
@@ -207,7 +208,7 @@ async def test_get_user_token_returns_token(self):
207208
async def test_get_user_token_returns_token_with_magice_code(self):
208209
adapter = TestAdapter()
209210
connection_name = "myConnection"
210-
channel_id = "directline"
211+
channel_id = Channels.direct_line
211212
user_id = "testUser"
212213
token = "abc123"
213214
magic_code = "888999"

libraries/botbuilder-core/tests/test_user_state.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,20 @@
66
from botbuilder.core import TurnContext, MemoryStorage, UserState
77
from botbuilder.core.adapters import TestAdapter
88
from botbuilder.schema import Activity, ChannelAccount
9+
from botframework.connector import Channels
910

1011
RECEIVED_MESSAGE = Activity(
1112
type="message",
1213
text="received",
13-
channel_id="test",
14+
channel_id=Channels.test,
1415
from_property=ChannelAccount(id="user"),
1516
)
1617
MISSING_CHANNEL_ID = Activity(
1718
type="message", text="received", from_property=ChannelAccount(id="user")
1819
)
19-
MISSING_FROM_PROPERTY = Activity(type="message", text="received", channel_id="test")
20+
MISSING_FROM_PROPERTY = Activity(
21+
type="message", text="received", channel_id=Channels.test
22+
)
2023

2124

2225
class TestUserState(aiounittest.AsyncTestCase):

libraries/botbuilder-dialogs/botbuilder/dialogs/choices/channel.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def supports_suggested_actions(channel_id: str, button_cnt: int = 100) -> bool:
3434
Channels.telegram: 100,
3535
Channels.emulator: 100,
3636
Channels.direct_line: 100,
37+
Channels.direct_line_speech: 100,
3738
Channels.webchat: 100,
3839
}
3940
return (
@@ -64,6 +65,7 @@ def supports_card_actions(channel_id: str, button_cnt: int = 100) -> bool:
6465
Channels.telegram: 100,
6566
Channels.emulator: 100,
6667
Channels.direct_line: 100,
68+
Channels.direct_line_speech: 100,
6769
Channels.webchat: 100,
6870
}
6971
return (

libraries/botbuilder-dialogs/tests/choices/test_channel.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def test_supports_suggested_actions_many(self):
2525
(Channels.kik, 21, False),
2626
(Channels.emulator, 100, True),
2727
(Channels.emulator, 101, False),
28+
(Channels.direct_line_speech, 100, True),
2829
]
2930

3031
for channel, button_cnt, expected in supports_suggested_actions_data:
@@ -41,6 +42,7 @@ def test_supports_card_actions_many(self):
4142
(Channels.slack, 100, True),
4243
(Channels.skype, 3, True),
4344
(Channels.skype, 5, False),
45+
(Channels.direct_line_speech, 99, True),
4446
]
4547

4648
for channel, button_cnt, expected in supports_card_action_data:

libraries/botbuilder-dialogs/tests/memory/scopes/test_memory_scopes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
ChannelAccount,
3333
ConversationAccount,
3434
)
35+
from botframework.connector import Channels
3536

3637

3738
class TestDialog(Dialog):
@@ -92,7 +93,7 @@ class MemoryScopesTests(aiounittest.AsyncTestCase):
9293
begin_message = Activity(
9394
text="begin",
9495
type=ActivityTypes.message,
95-
channel_id="test",
96+
channel_id=Channels.test,
9697
from_property=ChannelAccount(id="user"),
9798
recipient=ChannelAccount(id="bot"),
9899
conversation=ConversationAccount(id="convo1"),

libraries/botbuilder-dialogs/tests/test_dialog_manager.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
InputHints,
4343
)
4444
from botframework.connector.auth import AuthenticationConstants, ClaimsIdentity
45+
from botframework.connector import Channels
4546

4647

4748
class SkillFlowTestCase(str, Enum):
@@ -103,7 +104,7 @@ async def create_test_flow(
103104
user_state = UserState(storage)
104105

105106
activity = Activity(
106-
channel_id="test",
107+
channel_id=Channels.test,
107108
service_url="https://test.com",
108109
from_property=ChannelAccount(id="user1", name="User1"),
109110
recipient=ChannelAccount(id="bot", name="Bot"),

libraries/botframework-connector/botframework/connector/channels.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ class Channels(str, Enum):
1818
direct_line = "directline"
1919
"""Direct Line channel."""
2020

21+
direct_line_speech = "directlinespeech"
22+
"""Direct Line Speech channel."""
23+
2124
email = "email"
2225
"""Email channel."""
2326

@@ -54,5 +57,8 @@ class Channels(str, Enum):
5457
telegram = "telegram"
5558
"""Telegram channel."""
5659

60+
test = "test"
61+
"""Test channel."""
62+
5763
webchat = "webchat"
5864
"""WebChat channel."""

libraries/botframework-connector/tests/test_attachments.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88

99
import msrest
1010
from botbuilder.schema import AttachmentData, ErrorResponseException
11-
from botframework.connector import ConnectorClient
11+
from botframework.connector import ConnectorClient, Channels
1212
from botframework.connector.auth import MicrosoftAppCredentials
1313

1414
from authentication_stub import MicrosoftTokenAuthenticationStub
1515

1616
SERVICE_URL = "https://slack.botframework.com"
17-
CHANNEL_ID = "slack"
17+
CHANNEL_ID = Channels.slack
1818
BOT_NAME = "botbuilder-pc-bot"
1919
BOT_ID = "B21UTEF8S:T03CWQ0QB"
2020
RECIPIENT_ID = "U19KH8EHJ:T03CWQ0QB"

libraries/botframework-connector/tests/test_attachments_async.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
from botframework.connector.auth import MicrosoftAppCredentials
1313

1414
from authentication_stub import MicrosoftTokenAuthenticationStub
15+
from botframework.connector import Channels
1516

1617
SERVICE_URL = "https://slack.botframework.com"
17-
CHANNEL_ID = "slack"
18+
CHANNEL_ID = Channels.slack
1819
BOT_NAME = "botbuilder-pc-bot"
1920
BOT_ID = "B21UTEF8S:T03CWQ0QB"
2021
RECIPIENT_ID = "U19KH8EHJ:T03CWQ0QB"

libraries/botframework-connector/tests/test_conversations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
ErrorResponseException,
1616
HeroCard,
1717
)
18-
from botframework.connector import ConnectorClient
18+
from botframework.connector import ConnectorClient, Channels
1919
from botframework.connector.auth import MicrosoftAppCredentials
2020

2121
from authentication_stub import MicrosoftTokenAuthenticationStub
2222

2323
SERVICE_URL = "https://slack.botframework.com"
24-
CHANNEL_ID = "slack"
24+
CHANNEL_ID = Channels.slack
2525
BOT_NAME = "botbuilder-pc-bot"
2626
BOT_ID = "B21UTEF8S:T03CWQ0QB"
2727
RECIPIENT_ID = "U19KH8EHJ:T03CWQ0QB"

0 commit comments

Comments
 (0)
0