12
12
import binascii
13
13
import urllib
14
14
import shutil
15
+ import StringIO
15
16
16
17
from qiniu import conf
17
18
from qiniu .auth import up
@@ -80,11 +81,11 @@ def test_put(self):
80
81
key = "sdk_py_resumable_block_5_%s" % r (9 )
81
82
localfile = dst .name
82
83
ret , err = resumable_io .put_file (policy .token (), key , localfile , extra )
83
- assert ret .get ("x:foo" ) == "test" , "return data not contains 'x:foo'"
84
84
dst .close ()
85
85
os .remove (tmpf )
86
86
87
87
assert err is None , err
88
+ assert ret .get ("x:foo" ) == "test" , "return data not contains 'x:foo'"
88
89
self .assertEqual (
89
90
ret ["hash" ], "FnyTMUqPNRTdk1Wou7oLqDHkBm_p" , "hash not match" )
90
91
rs .Client ().delete (bucket , key )
@@ -108,15 +109,34 @@ def test_put_4m(self):
108
109
key = "sdk_py_resumable_block_6_%s" % r (9 )
109
110
localfile = dst .name
110
111
ret , err = resumable_io .put_file (policy .token (), key , localfile , extra )
111
- assert ret .get ("x:foo" ) == "test" , "return data not contains 'x:foo'"
112
112
dst .close ()
113
113
os .remove (tmpf )
114
114
115
115
assert err is None , err
116
+ assert ret .get ("x:foo" ) == "test" , "return data not contains 'x:foo'"
116
117
self .assertEqual (
117
118
ret ["hash" ], "FnIVmMd_oaUV3MLDM6F9in4RMz2U" , "hash not match" )
118
119
rs .Client ().delete (bucket , key )
119
120
121
+ def test_put_0 (self ):
122
+ if is_travis :
123
+ return
124
+
125
+ f = StringIO .StringIO ('' )
126
+
127
+ policy = rs .PutPolicy (bucket )
128
+ extra = resumable_io .PutExtra (bucket )
129
+ extra .bucket = bucket
130
+ extra .params = {"x:foo" : "test" }
131
+ key = "sdk_py_resumable_block_7_%s" % r (9 )
132
+ ret , err = resumable_io .put (policy .token (), key , f , 0 , extra )
133
+
134
+ assert err is None , err
135
+ assert ret .get ("x:foo" ) == "test" , "return data not contains 'x:foo'"
136
+ self .assertEqual (
137
+ ret ["hash" ], "Fg==" , "hash not match" )
138
+ rs .Client ().delete (bucket , key )
139
+
120
140
121
141
if __name__ == "__main__" :
122
142
if not is_travis :
0 commit comments