Exemplo n.º 1
0
 def test_submit_set_is_enabled(self):
     action = Submit()
     action.set_is_enabled(False)
     self.assertDictEqual(action.as_data(), {
         "type": "Action.Submit",
         "isEnabled": False
     })
Exemplo n.º 2
0
 def test_submit_set_mode(self):
     action = Submit()
     action.set_mode(ActionMode.SECONDARY)
     self.assertDictEqual(action.as_data(), {
         "type": "Action.Submit",
         "mode": "secondary"
     })
Exemplo n.º 3
0
 def test_submit_set_tooltip(self):
     action = Submit()
     action.set_tooltip("Volutpat nec pharetra")
     self.assertDictEqual(action.as_data(), {
         "type": "Action.Submit",
         "tooltip": "Volutpat nec pharetra"
     })
Exemplo n.º 4
0
 def test_submit(self):
     requires = {"parameter1": 1, "parameter2": "asdf"}
     submit = Submit({
         "x": 0,
         "y": 1,
         "z": "2"
     },
                     title="Submit me",
                     icon_url=URL,
                     style=ActionStyle.DESTRUCTIVE,
                     fallback=FallbackOption.DROP,
                     tooltip="Morbi felis arcu",
                     is_enabled=True,
                     mode=ActionMode.SECONDARY,
                     requires=requires)
     self.assertDictEqual(
         submit.as_data(), {
             "type": "Action.Submit",
             "title": "Submit me",
             "iconUrl": URL,
             "style": "destructive",
             "fallback": "drop",
             "requires": requires,
             "data": {
                 "x": 0,
                 "y": 1,
                 "z": "2"
             },
             "tooltip": "Morbi felis arcu",
             "mode": "secondary",
             "isEnabled": True
         })
Exemplo n.º 5
0
 def test_submit_set_data(self):
     submit = Submit()
     data = {"name": "John", "age": 99, "city": "Nowhere"}
     submit.set_data(data)
     self.assertDictEqual(submit.as_data(), {
         "type": "Action.Submit",
         "data": data
     })
Exemplo n.º 6
0
 def test_show_card(self):
     adaptive_card = AdaptiveCard()
     adaptive_card.add_elements(TextBlock(text="Sample text"))
     adaptive_card.add_actions(Submit(title="Vote"))
     show_card = ShowCard(card=adaptive_card,
                          tooltip="Etiam venenatis",
                          is_enabled=True,
                          mode=ActionMode.PRIMARY)
     self.assertDictEqual(
         show_card.as_data(), {
             "type": "Action.ShowCard",
             "card": {
                 "type": "AdaptiveCard",
                 "body": [{
                     "type": "TextBlock",
                     "text": "Sample text"
                 }],
                 "actions": [{
                     "type": "Action.Submit",
                     "title": "Vote"
                 }]
             },
             "tooltip": "Etiam venenatis",
             "mode": "primary",
             "isEnabled": True
         })
Exemplo n.º 7
0
 def test_show_card_set_card(self):
     show_card = ShowCard()
     self.assertDictEqual(show_card.as_data(), {"type": "Action.ShowCard"})
     adaptive_card = AdaptiveCard()
     adaptive_card.add_actions(Submit(title="Something"))
     show_card.set_card(adaptive_card)
     self.assertDictEqual(
         show_card.as_data(), {
             "type": "Action.ShowCard",
             "card": {
                 "type": "AdaptiveCard",
                 "actions": [{
                     "type": "Action.Submit",
                     "title": "Something"
                 }]
             }
         })
Exemplo n.º 8
0
 def test_fallback_type(self):
     action = Submit(fallback=OpenUrl(URL))
     self.assertDictEqual(
         action.as_data(), {
             "type": "Action.Submit",
             "fallback": {
                 "type": "Action.OpenUrl",
                 "url": URL
             }
         })
     action = Submit(fallback=FallbackOption.DROP)
     self.assertDictEqual(action.as_data(), {
         "type": "Action.Submit",
         "fallback": "drop"
     })
     with self.assertRaisesMessage(CardException, "Invalid fallback type"):
         Submit(fallback="invalid")
                   TextBlock("Created {{DATE(2017-02-14T06:08:39Z, SHORT)}",
                             spacing=SpacingStyle.NONE,
                             is_subtle=True,
                             wrap=True)
               ])
    ]))
activity_update.add_elements(
    TextBlock(
        "Now that we have defined the main rules and features of the format, we need to produce a schema and publish it "
        "to GitHub. The schema will be the starting point of our reference documentation.",
        wrap=True))
activity_update.add_elements(
    FactSet([
        Fact("Board:", "Adaptive card"),
        Fact("List:", "Backing"),
        Fact("Assigned to:", "Matt Hidinger"),
        Fact("Due date:", "Not set")
    ]))
activity_update.add_actions(
    ShowCard(title="Set due date",
             card=AdaptiveCard(inputs=[DateInput(item_id="dueDate")],
                               actions=[Submit(title="OK")])))
activity_update.add_actions(
    ShowCard(title="Comment",
             card=AdaptiveCard(inputs=[
                 TextInput(item_id="comment",
                           is_multiline=True,
                           placeholder="Enter your comment")
             ],
                               actions=[Submit(title="OK")])))

adaptive_card1 = AdaptiveCard()
adaptive_card1.add_elements([
    TextBlock("How would you like your steak prepared?", size=FontSize.MEDIUM, wrap=True),
    ChoiceSetInput(
        item_id="SteakTemp",
        choices=[
            InputChoice("Rare", "rare"),
            InputChoice("Medium-rare", "medium-rare"),
            InputChoice("Well-done", "well-done")
        ]
    ),
    TextInput(item_id="SteakOther", is_multiline=True, placeholder="Any other preparation requests?")
])
adaptive_card1.add_actions(Submit(title="OK", data={"FoodChoice": "Steak"}))
adaptive_card2 = AdaptiveCard()
adaptive_card2.add_elements([
    TextBlock("Do you have any allergies?", size=FontSize.MEDIUM, wrap=True),
    ChoiceSetInput(
        item_id="ChickenAllergy",
        choices=[
            InputChoice("I'm allergic to peanuts", "peanut")
        ]
    ),
    TextInput(item_id="ChickenOther", is_multiline=True, placeholder="Any other preparation requests?")
])
adaptive_card2.add_actions(Submit(title="OK", data={"FoodChoice": "Chicken"}))
adaptive_card3 = AdaptiveCard()
adaptive_card3.add_elements([
    TextBlock("Would you like it prepared vegan?", size=FontSize.MEDIUM, wrap=True),
Exemplo n.º 11
0
https://adaptivecards.io/samples/CalendarReminder.html
"""

calendar_reminder = AdaptiveCard(version="1.0", schema=SCHEMA)
calendar_reminder.set_speak(
    "Your  meeting about \"Adaptive Card design session\" is starting at 12:30pm"
    "Do you want to snooze  or do you want to send a late notification to the attendees?"
)
calendar_reminder.add_elements(
    TextBlock("Adaptive Card design session",
              size=FontSize.LARGE,
              weight=FontWeight.BOLDER))
calendar_reminder.add_elements([
    TextBlock("Conf Room 112/3377 (10)", is_subtle=True),
    TextBlock("12:30 PM - 1:30 PM", is_subtle=True, spacing=SpacingStyle.NONE),
    TextBlock("Snooze for")
])
calendar_reminder.add_elements(
    ChoiceSetInput(item_id="snooze",
                   style=ChoiceInputStyle.COMPACT,
                   value="5",
                   choices=[
                       InputChoice("5 minutes", "5"),
                       InputChoice("15 minutes", "15"),
                       InputChoice("30 minutes", "30")
                   ]))
calendar_reminder.add_actions([
    Submit(title="Snooze", data={"x": "snooze"}),
    Submit(title="I'll be late", data={"x": "late"})
])