def test_parse(self):
        input = {
            "type": "section",
            "text": {
                "type":
                "mrkdwn",
                "text":
                "A message *with some bold text* and _some italicized text_.",
            },
            "unexpected_field": "test",
            "unexpected_fields": [1, 2, 3],
            "unexpected_object": {
                "something": "wrong"
            },
        }
        block = Block.parse(input)
        self.assertIsNotNone(block)

        self.assertDictEqual(
            {
                "type": "section",
                "text": {
                    "type":
                    "mrkdwn",
                    "text":
                    "A message *with some bold text* and _some italicized text_.",
                },
            },
            block.to_dict(),
        )
Exemple #2
0
 def test_with_real_payload(self):
     self.maxDiff = None
     input = {
         "type": "call",
         "call_id": "R00000000",
         "api_decoration_available": False,
         "call": {
             "v1": {
                 "id": "R00000000",
                 "app_id": "A00000000",
                 "app_icon_urls": {
                     "image_32": "https://www.example.com/",
                     "image_36": "https://www.example.com/",
                     "image_48": "https://www.example.com/",
                     "image_64": "https://www.example.com/",
                     "image_72": "https://www.example.com/",
                     "image_96": "https://www.example.com/",
                     "image_128": "https://www.example.com/",
                     "image_192": "https://www.example.com/",
                     "image_512": "https://www.example.com/",
                     "image_1024": "https://www.example.com/",
                     "image_original": "https://www.example.com/",
                 },
                 "date_start": 12345,
                 "active_participants": [
                     {"slack_id": "U00000000"},
                     {
                         "slack_id": "U00000000",
                         "external_id": "",
                         "avatar_url": "https://www.example.com/",
                         "display_name": "",
                     },
                 ],
                 "all_participants": [
                     {"slack_id": "U00000000"},
                     {
                         "slack_id": "U00000000",
                         "external_id": "",
                         "avatar_url": "https://www.example.com/",
                         "display_name": "",
                     },
                 ],
                 "display_id": "",
                 "join_url": "https://www.example.com/",
                 "name": "",
                 "created_by": "U00000000",
                 "date_end": 12345,
                 "channels": ["C00000000"],
                 "is_dm_call": False,
                 "was_rejected": False,
                 "was_missed": False,
                 "was_accepted": False,
                 "has_ended": False,
                 "desktop_app_join_url": "https://www.example.com/",
             }
         },
     }
     self.assertDictEqual(input, CallBlock(**input).to_dict())
     self.assertDictEqual(input, Block.parse(input).to_dict())
Exemple #3
0
 def test_document(self):
     input = {
         "type": "header",
         "block_id": "budget-header",
         "text": {"type": "plain_text", "text": "Budget Performance"},
     }
     self.assertDictEqual(input, HeaderBlock(**input).to_dict())
     self.assertDictEqual(input, Block.parse(input).to_dict())
 def __init__(
     self,
     # "modal", "home", and "workflow_step"
     type: str,  # skipcq: PYL-W0622
     id: Optional[str] = None,  # skipcq: PYL-W0622
     callback_id: Optional[str] = None,
     external_id: Optional[str] = None,
     team_id: Optional[str] = None,
     bot_id: Optional[str] = None,
     app_id: Optional[str] = None,
     root_view_id: Optional[str] = None,
     previous_view_id: Optional[str] = None,
     title: Union[str, dict, PlainTextObject] = None,
     submit: Optional[Union[str, dict, PlainTextObject]] = None,
     close: Optional[Union[str, dict, PlainTextObject]] = None,
     blocks: Optional[Sequence[Union[dict, Block]]] = None,
     private_metadata: Optional[str] = None,
     state: Optional[Union[dict, "ViewState"]] = None,
     hash: Optional[str] = None,  # skipcq: PYL-W0622
     clear_on_close: Optional[bool] = None,
     notify_on_close: Optional[bool] = None,
     **kwargs,
 ):
     self.type = type
     self.id = id
     self.callback_id = callback_id
     self.external_id = external_id
     self.team_id = team_id
     self.bot_id = bot_id
     self.app_id = app_id
     self.root_view_id = root_view_id
     self.previous_view_id = previous_view_id
     self.title = TextObject.parse(title, default_type=PlainTextObject.type)
     self.submit = TextObject.parse(submit,
                                    default_type=PlainTextObject.type)
     self.close = TextObject.parse(close, default_type=PlainTextObject.type)
     self.blocks = Block.parse_all(blocks)
     self.private_metadata = private_metadata
     self.state = state
     self.hash = hash
     self.clear_on_close = clear_on_close
     self.notify_on_close = notify_on_close
     self.additional_attributes = kwargs
Exemple #5
0
 def test_eq(self):
     self.assertEqual(Block(), Block())
     self.assertEqual(Block(type="test"), Block(type="test"))
     self.assertNotEqual(Block(type="test"), Block(type="another test"))