def test_document(self): input = { "type": "overflow", "options": [ { "text": {"type": "plain_text", "text": "*this is plain_text text*"}, "value": "value-0", }, { "text": {"type": "plain_text", "text": "*this is plain_text text*"}, "value": "value-1", }, { "text": {"type": "plain_text", "text": "*this is plain_text text*"}, "value": "value-2", }, { "text": {"type": "plain_text", "text": "*this is plain_text text*"}, "value": "value-3", }, { "text": {"type": "plain_text", "text": "*this is plain_text text*"}, # https://api.slack.com/reference/block-kit/composition-objects#option "url": "https://www.example.com", }, ], "action_id": "overflow", } self.assertDictEqual(input, OverflowMenuElement(**input).to_dict())
def test_element_parsing(self): elements = [ ButtonElement(text="Click me", action_id="reg_button", value="1"), StaticSelectElement(options=[Option(value="SelectOption")]), ImageElement(image_url="url", alt_text="alt-text"), OverflowMenuElement( options=[Option(value="MenuOption1"), Option(value="MenuOption2")] ), ] input = { "type": "actions", "block_id": "actionblock789", "elements": [e.to_dict() for e in elements], } parsed_elements = ActionsBlock(**input).elements self.assertEqual(len(elements), len(parsed_elements)) for original, parsed in zip(elements, parsed_elements): self.assertEqual(type(original), type(parsed)) self.assertDictEqual(original.to_dict(), parsed.to_dict())