Spaces:
Build error
Build error
File size: 2,620 Bytes
0827183 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import unittest
from typing import List, Tuple
from botbuilder.core import BotFrameworkAdapter, TurnContext
from botbuilder.dialogs.choices import Channel
from botbuilder.schema import Activity
from botframework.connector import Channels
class ChannelTest(unittest.TestCase):
def test_supports_suggested_actions(self):
actual = Channel.supports_suggested_actions(Channels.facebook, 5)
self.assertTrue(actual)
def test_supports_suggested_actions_many(self):
supports_suggested_actions_data: List[Tuple[Channels, int, bool]] = [
(Channels.line, 13, True),
(Channels.line, 14, False),
(Channels.skype, 10, True),
(Channels.skype, 11, False),
(Channels.kik, 20, True),
(Channels.kik, 21, False),
(Channels.emulator, 100, True),
(Channels.emulator, 101, False),
]
for channel, button_cnt, expected in supports_suggested_actions_data:
with self.subTest(
channel=channel, button_cnt=button_cnt, expected=expected
):
actual = Channel.supports_suggested_actions(channel, button_cnt)
self.assertEqual(expected, actual)
def test_supports_card_actions_many(self):
supports_card_action_data: List[Tuple[Channels, int, bool]] = [
(Channels.line, 99, True),
(Channels.line, 100, False),
(Channels.slack, 100, True),
(Channels.skype, 3, True),
(Channels.skype, 5, False),
]
for channel, button_cnt, expected in supports_card_action_data:
with self.subTest(
channel=channel, button_cnt=button_cnt, expected=expected
):
actual = Channel.supports_card_actions(channel, button_cnt)
self.assertEqual(expected, actual)
def test_should_return_channel_id_from_context_activity(self):
test_activity = Activity(channel_id=Channels.facebook)
test_context = TurnContext(BotFrameworkAdapter(settings=None), test_activity)
channel_id = Channel.get_channel_id(test_context)
self.assertEqual(Channels.facebook, channel_id)
def test_should_return_empty_from_context_activity_missing_channel(self):
test_activity = Activity(channel_id=None)
test_context = TurnContext(BotFrameworkAdapter(settings=None), test_activity)
channel_id = Channel.get_channel_id(test_context)
self.assertEqual("", channel_id)
|