def test_text_run_set_text(self): text_run = TextRun(text="lorem ipsum") text_run.set_text("At sed sumo temporibus omittantur") self.assertDictEqual(text_run.as_data(), { "type": "TextRun", "text": "At sed sumo temporibus omittantur" })
def test_text_run_set_weight(self): text_run = TextRun(text="lorem ipsum") text_run.set_weight(FontWeight.LIGHTER) self.assertDictEqual(text_run.as_data(), { "type": "TextRun", "text": "lorem ipsum", "weight": "lighter" })
def test_text_run_set_size(self): text_run = TextRun(text="lorem ipsum") text_run.set_size(FontSize.LARGE) self.assertDictEqual(text_run.as_data(), { "type": "TextRun", "text": "lorem ipsum", "size": "large" })
def test_text_run_set_font_type(self): text_run = TextRun(text="lorem ipsum") text_run.set_font_type(FontType.DEFAULT) self.assertDictEqual(text_run.as_data(), { "type": "TextRun", "text": "lorem ipsum", "fontType": "default" })
def test_text_run_set_color(self): text_run = TextRun(text="lorem ipsum") text_run.set_color(Color.ACCENT) self.assertDictEqual(text_run.as_data(), { "type": "TextRun", "text": "lorem ipsum", "color": "accent" })
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_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" })
def test_rich_text_block_set_inlines(self): rich_text_block = RichTextBlock(inlines=["lorem ipsum", ]) rich_text_block.set_inlines([TextRun("Sed ea quod nominati, at vel", color=Color.GOOD), "Eos saepe phaedrum"]) self.assertDictEqual(rich_text_block.as_data(), { "type": "RichTextBlock", "inlines": [ { "type": "TextRun", "text": "Sed ea quod nominati, at vel", "color": "good" }, "Eos saepe phaedrum" ] })
def test_rich_text_block(self): inlines = ["Odio adipisci honestatis sea ad", TextRun(text="Ad duo graecis hendrerit", color=Color.ATTENTION)] rich_text_block = RichTextBlock(inlines=inlines, horizontal_alignment=HorizontalAlignment.CENTER, fallback=FallbackOption.DROP, separator=True, spacing=SpacingStyle.MEDIUM, item_id="id_image", is_visible=True, requires=self.requires) self.assertDictEqual(rich_text_block.as_data(), { "type": "RichTextBlock", "inlines": [ "Odio adipisci honestatis sea ad", { "type": "TextRun", "text": "Ad duo graecis hendrerit", "color": "attention" } ], "horizontalAlignment": "center", "fallback": "drop", "separator": True, "spacing": "medium", "id": "id_image", "isVisible": True, "requires": self.requires })
def test_text_run_set_strike_through(self): text_run = TextRun(text="lorem ipsum") text_run.set_strike_through(False) self.assertDictEqual(text_run.as_data(), { "type": "TextRun", "text": "lorem ipsum", "strikethrough": False }) text_run.set_strike_through(True) self.assertDictEqual(text_run.as_data(), { "type": "TextRun", "text": "lorem ipsum", "strikethrough": True }) text_run.set_strike_through() self.assertDictEqual(text_run.as_data(), { "type": "TextRun", "text": "lorem ipsum", "strikethrough": True })
def test_text_run_set_italic(self): text_run = TextRun(text="lorem ipsum") text_run.set_italic(False) self.assertDictEqual(text_run.as_data(), { "type": "TextRun", "text": "lorem ipsum", "italic": False }) text_run.set_italic(True) self.assertDictEqual(text_run.as_data(), { "type": "TextRun", "text": "lorem ipsum", "italic": True }) text_run.set_italic() self.assertDictEqual(text_run.as_data(), { "type": "TextRun", "text": "lorem ipsum", "italic": True })
def test_text_run_set_highlight(self): text_run = TextRun(text="lorem ipsum") text_run.set_highlight(False) self.assertDictEqual(text_run.as_data(), { "type": "TextRun", "text": "lorem ipsum", "highlight": False }) text_run.set_highlight(True) self.assertDictEqual(text_run.as_data(), { "type": "TextRun", "text": "lorem ipsum", "highlight": True }) text_run.set_highlight() self.assertDictEqual(text_run.as_data(), { "type": "TextRun", "text": "lorem ipsum", "highlight": True })