22import unittest
33from io import BytesIO
44from pathlib import Path
5- from typing import Dict , Sequence , Union
5+ from typing import Dict
66
7- import pytest
87
98from slack_sdk .models .attachments import Attachment
109from slack_sdk .models .blocks import Block , DividerBlock
10+ from slack_sdk .models .messages .chunk import MarkdownTextChunk , TaskUpdateChunk
1111from slack_sdk .web .internal_utils import (
1212 _build_unexpected_body_error_message ,
13+ _get_url ,
14+ _next_cursor_is_present ,
1315 _parse_web_class_objects ,
1416 _to_v2_file_upload_item ,
15- _next_cursor_is_present ,
16- _get_url ,
1717)
1818
1919
@@ -57,6 +57,20 @@ def test_can_parse_sequence_of_attachments(self):
5757 for attachment in kwargs ["attachments" ]:
5858 assert isinstance (attachment , Dict )
5959
60+ def test_can_parse_sequence_of_chunks (self ):
61+ for chunks in [
62+ [MarkdownTextChunk (text = "fiz" ), TaskUpdateChunk (id = "001" , title = "baz" , status = "complete" )], # list
63+ (
64+ MarkdownTextChunk (text = "fiz" ),
65+ TaskUpdateChunk (id = "001" , title = "baz" , status = "complete" ),
66+ ), # tuple
67+ ]:
68+ kwargs = {"chunks" : chunks }
69+ _parse_web_class_objects (kwargs )
70+ assert kwargs ["chunks" ]
71+ for chunks in kwargs ["chunks" ]:
72+ assert isinstance (chunks , Dict )
73+
6074 def test_can_parse_str_blocks (self ):
6175 input = json .dumps ([Block (block_id = "42" ).to_dict (), Block (block_id = "24" ).to_dict ()])
6276 kwargs = {"blocks" : input }
@@ -71,6 +85,15 @@ def test_can_parse_str_attachments(self):
7185 assert isinstance (kwargs ["attachments" ], str )
7286 assert input == kwargs ["attachments" ]
7387
88+ def test_can_parse_str_chunks (self ):
89+ input = json .dumps (
90+ [MarkdownTextChunk (text = "fiz" ).to_dict (), TaskUpdateChunk (id = "001" , title = "baz" , status = "complete" ).to_dict ()]
91+ )
92+ kwargs = {"chunks" : input }
93+ _parse_web_class_objects (kwargs )
94+ assert isinstance (kwargs ["chunks" ], str )
95+ assert input == kwargs ["chunks" ]
96+
7497 def test_can_parse_user_auth_blocks (self ):
7598 kwargs = {
7699 "channel" : "C12345" ,
0 commit comments