예제 #1
0
    async def _show_choices(self, turn_context: TurnContext):
        choices = [
            Choice(
                value=QUICK_REPLIES_OPTION,
                action=CardAction(
                    title=QUICK_REPLIES_OPTION,
                    type=ActionTypes.post_back,
                    value=QUICK_REPLIES_OPTION,
                ),
            ),
            Choice(
                value=FACEBOOK_PAGEID_OPTION,
                action=CardAction(
                    title=FACEBOOK_PAGEID_OPTION,
                    type=ActionTypes.post_back,
                    value=FACEBOOK_PAGEID_OPTION,
                ),
            ),
            Choice(
                value=POSTBACK_OPTION,
                action=CardAction(
                    title=POSTBACK_OPTION,
                    type=ActionTypes.post_back,
                    value=POSTBACK_OPTION,
                ),
            ),
        ]

        message = ChoiceFactory.for_channel(
            turn_context.activity.channel_id,
            choices,
            "What Facebook feature would you like to try? Here are some quick replies to choose from!",
        )
        await turn_context.send_activity(message)
 def test_ShouldIncludeChoiceActionsInHeroCards(self):
     expected = Activity(
         type=ActivityTypes.message,
         input_hint=InputHints.expecting_input,
         attachment_layout=AttachmentLayoutTypes.list,
         attachments=[
             Attachment(
                 content=HeroCard(
                     text="select from:",
                     buttons=[
                         CardAction(
                             type=ActionTypes.im_back,
                             value="ImBack Value",
                             title="ImBack Action",
                         ),
                         CardAction(
                             type=ActionTypes.message_back,
                             value="MessageBack Value",
                             title="MessageBack Action",
                         ),
                         CardAction(
                             type=ActionTypes.post_back,
                             value="PostBack Value",
                             title="PostBack Action",
                         ),
                     ],
                 ),
                 content_type="application/vnd.microsoft.card.hero",
             )
         ],
     )
     activity = ChoiceFactory.hero_card(
         ChoiceFactoryTest.choices_with_actions, "select from:")
     self.assertEqual(expected, activity)
    def test_should_render_choices_as_hero_card(self):
        expected = Activity(
            type=ActivityTypes.message,
            input_hint=InputHints.expecting_input,
            attachment_layout=AttachmentLayoutTypes.list,
            attachments=[
                Attachment(
                    content=HeroCard(
                        text="select from:",
                        buttons=[
                            CardAction(type=ActionTypes.im_back,
                                       value="red",
                                       title="red"),
                            CardAction(type=ActionTypes.im_back,
                                       value="green",
                                       title="green"),
                            CardAction(type=ActionTypes.im_back,
                                       value="blue",
                                       title="blue"),
                        ],
                    ),
                    content_type="application/vnd.microsoft.card.hero",
                )
            ],
        )

        activity = ChoiceFactory.hero_card(ChoiceFactoryTest.color_choices,
                                           "select from:")

        self.assertEqual(expected, activity)
 def test_should_include_choice_actions_in_suggested_actions(self):
     expected = Activity(
         type=ActivityTypes.message,
         text="select from:",
         input_hint=InputHints.expecting_input,
         suggested_actions=SuggestedActions(actions=[
             CardAction(
                 type=ActionTypes.im_back,
                 value="ImBack Value",
                 title="ImBack Action",
             ),
             CardAction(
                 type=ActionTypes.message_back,
                 value="MessageBack Value",
                 title="MessageBack Action",
             ),
             CardAction(
                 type=ActionTypes.post_back,
                 value="PostBack Value",
                 title="PostBack Action",
             ),
         ]),
     )
     activity = ChoiceFactory.suggested_action(
         ChoiceFactoryTest.choices_with_actions, "select from:")
     self.assertEqual(expected, activity)
 def test_should_render_unincluded_numbers_choices_as_a_list(self):
     activity = ChoiceFactory.list(
         ChoiceFactoryTest.color_choices,
         "select from:",
         options=ChoiceFactoryOptions(include_numbers=False),
     )
     self.assertEqual("select from:\n\n   - red\n   - green\n   - blue",
                      activity.text)
    def test_should_render_choices_as_suggested_actions(self):
        expected = Activity(
            type=ActivityTypes.message,
            text="select from:",
            input_hint=InputHints.expecting_input,
            suggested_actions=SuggestedActions(actions=[
                CardAction(type=ActionTypes.im_back, value="red", title="red"),
                CardAction(
                    type=ActionTypes.im_back, value="green", title="green"),
                CardAction(
                    type=ActionTypes.im_back, value="blue", title="blue"),
            ]),
        )

        activity = ChoiceFactory.suggested_action(
            ChoiceFactoryTest.color_choices, "select from:")

        self.assertEqual(expected, activity)
    def test_should_automatically_choose_render_style_based_on_channel_type(
            self):
        expected = Activity(
            type=ActivityTypes.message,
            text="select from:",
            input_hint=InputHints.expecting_input,
            suggested_actions=SuggestedActions(actions=[
                CardAction(type=ActionTypes.im_back, value="red", title="red"),
                CardAction(
                    type=ActionTypes.im_back, value="green", title="green"),
                CardAction(
                    type=ActionTypes.im_back, value="blue", title="blue"),
            ]),
        )
        activity = ChoiceFactory.for_channel(Channels.emulator,
                                             ChoiceFactoryTest.color_choices,
                                             "select from:")

        self.assertEqual(expected, activity)
예제 #8
0
 def default() -> Activity:
     return ChoiceFactory.for_channel(channel_id, choices, text, None,
                                      options)
예제 #9
0
 def hero_card() -> Activity:
     return ChoiceFactory.hero_card(choices, text)
예제 #10
0
 def suggested_action() -> Activity:
     return ChoiceFactory.suggested_action(choices, text)
예제 #11
0
 def list_style() -> Activity:
     return ChoiceFactory.list_style(choices, text, None, options)
예제 #12
0
 def inline() -> Activity:
     return ChoiceFactory.inline(choices, text, None, options)
 def test_ShouldRenderChoicesAsAList(self):
     activity = ChoiceFactory.list(ChoiceFactoryTest.color_choices,
                                   "select from:")
     self.assertEqual("select from:\n\n   1. red\n   2. green\n   3. blue",
                      activity.text)
 def test_inline_should_render_choices_inline(self):
     activity = ChoiceFactory.inline(ChoiceFactoryTest.color_choices,
                                     "select from:")
     self.assertEqual("select from: (1) red, (2) green, or (3) blue",
                      activity.text)
예제 #15
0
 def test_should_render_choices_as_a_list(self):
     activity = ChoiceFactory.list_style(ChoiceFactoryTest.color_choices,
                                         "select from:")
     self.assertEqual("select from:\n\n   1. red\n   2. green\n   3. blue",
                      activity.text)