File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change
1
+ import contextlib
2
+ import io
1
3
import os
2
4
import unittest
3
5
4
6
import requests_mock
5
7
8
+ from tableauserverclient .config import BYTES_PER_MB , config
6
9
from tableauserverclient .server import Server
7
10
from ._utils import asset
8
11
11
14
FILEUPLOAD_APPEND = os .path .join (TEST_ASSET_DIR , "fileupload_append.xml" )
12
15
13
16
17
+ @contextlib .contextmanager
18
+ def set_env (** environ ):
19
+ old_environ = dict (os .environ )
20
+ os .environ .update (environ )
21
+ try :
22
+ yield
23
+ finally :
24
+ os .environ .clear ()
25
+ os .environ .update (old_environ )
26
+
27
+
14
28
class FileuploadsTests (unittest .TestCase ):
15
29
def setUp (self ):
16
30
self .server = Server ("http://test" , False )
@@ -62,3 +76,14 @@ def test_upload_chunks_file_object(self):
62
76
actual = self .server .fileuploads .upload (file_content )
63
77
64
78
self .assertEqual (upload_id , actual )
79
+
80
+ def test_upload_chunks_config (self ):
81
+ data = io .BytesIO ()
82
+ data .write (b"1" * (config .CHUNK_SIZE_MB * BYTES_PER_MB + 1 ))
83
+ data .seek (0 )
84
+ with set_env (TSC_CHUNK_SIZE_MB = "1" ):
85
+ chunker = self .server .fileuploads ._read_chunks (data )
86
+ chunk = next (chunker )
87
+ assert len (chunk ) == config .CHUNK_SIZE_MB * BYTES_PER_MB
88
+ data .seek (0 )
89
+ assert len (chunk ) < len (data .read ())
You can’t perform that action at this time.
0 commit comments