Exemplo n.º 1
0
 def test_open_url_set_url(self):
     open_url = OpenUrl(URL)
     open_url.set_url("https://www.zxcv.com/1/")
     self.assertDictEqual(open_url.as_data(), {
         "type": "Action.OpenUrl",
         "url": "https://www.zxcv.com/1/"
     })
Exemplo n.º 2
0
 def test_open_url_set_mode(self):
     action = OpenUrl(URL)
     action.set_mode(ActionMode.SECONDARY)
     self.assertDictEqual(action.as_data(), {
         "type": "Action.OpenUrl",
         "url": URL,
         "mode": "secondary"
     })
Exemplo n.º 3
0
 def test_open_url_set_is_enabled(self):
     action = OpenUrl(URL)
     action.set_is_enabled(False)
     self.assertDictEqual(action.as_data(), {
         "type": "Action.OpenUrl",
         "url": URL,
         "isEnabled": False
     })
Exemplo n.º 4
0
 def test_open_url_set_tooltip(self):
     action = OpenUrl(URL)
     action.set_tooltip("Vivamus ornare elit")
     self.assertDictEqual(action.as_data(), {
         "type": "Action.OpenUrl",
         "url": URL,
         "tooltip": "Vivamus ornare elit"
     })
 def test_image(self):
     image = Image(URL, alternate_text="Ut enim ad minim veniam", background_color="0f0f0f", height="50px",
                   horizontal_alignment=HorizontalAlignment.LEFT, select_action=OpenUrl("www.sample.com"),
                   size=ImageSize.SMALL, style=ImageStyle.PERSON, width="100px", fallback=FallbackOption.DROP,
                   separator=True, spacing=SpacingStyle.SMALL, item_id="id_image", is_visible=True,
                   requires=self.requires)
     self.assertDictEqual(image.as_data(), {
         "type": "Image",
         "url": URL,
         "altText": "Ut enim ad minim veniam",
         "backgroundColor": "0f0f0f",
         "height": "50px",
         "horizontalAlignment": "left",
         "selectAction": {
             "type": "Action.OpenUrl",
             "url": "www.sample.com"
         },
         "size": "small",
         "style": "person",
         "width": "100px",
         "fallback": "drop",
         "separator": True,
         "spacing": "small",
         "id": "id_image",
         "isVisible": True,
         "requires": self.requires
     })
 def test_text_run_set_select_action(self):
     text_run = TextRun(text="lorem ipsum")
     text_run.set_select_action(OpenUrl(URL))
     self.assertDictEqual(text_run.as_data(), {
         "type": "TextRun",
         "text": "lorem ipsum",
         "selectAction": {
             "type": "Action.OpenUrl",
             "url": URL
         }
     })
 def test_image_set_select_action(self):
     image = Image(URL)
     image.set_select_action(OpenUrl("www.click.me"))
     self.assertDictEqual(image.as_data(), {
         "type": "Image",
         "url": URL,
         "selectAction": {
             "type": "Action.OpenUrl",
             "url": "www.click.me"
         }
     })
Exemplo n.º 8
0
 def test_open_url(self):
     requires = {"parameter1": 1, "parameter2": "asdf"}
     open_url = OpenUrl(URL,
                        title="View",
                        icon_url="www.asdf.com",
                        style=ActionStyle.POSITIVE,
                        is_enabled=True,
                        mode=ActionMode.PRIMARY,
                        tooltip="Phasellus sodales leo",
                        fallback=FallbackOption.DROP,
                        requires=requires)
     self.assertDictEqual(
         open_url.as_data(), {
             "type": "Action.OpenUrl",
             "url": URL,
             "title": "View",
             "iconUrl": "www.asdf.com",
             "style": "positive",
             "fallback": "drop",
             "mode": "primary",
             "isEnabled": True,
             "tooltip": "Phasellus sodales leo",
             "requires": requires
         })
Exemplo n.º 9
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")
Exemplo n.º 10
0
restaurant = AdaptiveCard(version="1.0", schema=SCHEMA)
restaurant.add_elements([
    ColumnSet(columns=[
        Column(
            width=2,
            items=[
                TextBlock("Pizza"),
                TextBlock("Tom's Pie",
                          weight=FontWeight.BOLDER,
                          size=FontSize.EXTRA_LARGE,
                          spacing=SpacingStyle.NONE),
                TextBlock("4.2 ★★★☆ (93) · $$",
                          is_subtle=True,
                          spacing=SpacingStyle.NONE),
                TextBlock(
                    "**Matt H. said** \"I'm compelled to give this place 5 stars due to the number of times "
                    "I've chosen to eat here this past year!\"",
                    size=FontSize.SMALL,
                    wrap=True)
            ]),
        Column(width=1,
               items=[
                   Image("https://picsum.photos/300?image=882",
                         size=ImageSize.AUTO)
               ])
    ])
])
restaurant.add_actions(
    OpenUrl("https://www.youtube.com/watch?v=dQw4w9WgXcQ", title="More info"))
 def test_text_run(self):
     text_run = TextRun(text="Choro homero aliquando te vis", color=Color.ATTENTION, font_type=FontType.MONOSPACE,
                        highlight=True, is_subtle=True, italic=True, select_action=OpenUrl(URL), size=FontSize.SMALL,
                        strike_through=True, weight=FontWeight.BOLDER)
     self.assertDictEqual(text_run.as_data(), {
         "type": "TextRun",
         "text": "Choro homero aliquando te vis",
         "color": "attention",
         "fontType": "monospace",
         "highlight": True,
         "isSubtle": True,
         "italic": True,
         "selectAction": {
             "type": "Action.OpenUrl",
             "url": URL
         },
         "size": "small",
         "strikethrough": True,
         "weight": "bolder"
     })