@@ -150,20 +150,26 @@ def test_to_v2_file_upload_item_can_accept_file_as_path(self):
150150 assert upload_item_path == upload_item_str
151151 assert upload_item_str .get ("filename" ) == "test_internal_utils.py"
152152
153- def test_to_v2_file_upload_item_raises_when_file_path_exceeds_1gb (self ):
154- with patch ("os.path.getsize" , return_value = 1_073_741_825 ):
153+ def test_to_v2_file_upload_item_raises_when_file_path_exceeds_max_size (self ):
154+ with patch ("slack_sdk.web.internal_utils.MAX_V2_FILE_SIZE" , 10 ), patch ( " os.path.getsize" , return_value = 11 ):
155155 with self .assertRaises (SlackRequestError ) as ctx :
156156 _to_v2_file_upload_item ({"file" : "tests/slack_sdk/web/test_internal_utils.py" })
157- self .assertIn ("Maximum upload file size is 1GB " , str (ctx .exception ))
158- self .assertIn ("1073741825 bytes" , str (ctx .exception ))
157+ self .assertIn ("Maximum upload file size is 10 bytes " , str (ctx .exception ))
158+ self .assertIn ("file size: 11 bytes" , str (ctx .exception ))
159159
160- def test_to_v2_file_upload_item_raises_when_content_exceeds_1gb (self ):
160+ def test_to_v2_file_upload_item_raises_when_content_exceeds_max_size (self ):
161161 with patch ("slack_sdk.web.internal_utils.MAX_V2_FILE_SIZE" , 10 ):
162162 with self .assertRaises (SlackRequestError ) as ctx :
163- _to_v2_file_upload_item ({"content" : "this content is longer than 10 bytes" , "filename" : "test.txt" })
164- self .assertIn ("Maximum upload file size is 1GB" , str (ctx .exception ))
163+ _to_v2_file_upload_item ({"content" : "x" * 11 , "filename" : "test.txt" })
164+ self .assertIn ("Maximum upload file size is 10 bytes" , str (ctx .exception ))
165+ self .assertIn ("file size: 11 bytes" , str (ctx .exception ))
165166 self .assertIn ("test.txt" , str (ctx .exception ))
166167
168+ def test_to_v2_file_upload_item_accepts_content_at_max_size (self ):
169+ with patch ("slack_sdk.web.internal_utils.MAX_V2_FILE_SIZE" , 10 ):
170+ item = _to_v2_file_upload_item ({"content" : "x" * 10 , "filename" : "test.txt" })
171+ self .assertEqual (item ["length" ], 10 )
172+
167173 def test_next_cursor_is_present (self ):
168174 assert _next_cursor_is_present ({"next_cursor" : "next-page" }) is True
169175 assert _next_cursor_is_present ({"next_cursor" : "" }) is False
0 commit comments