@@ -64,10 +64,14 @@ def remove_temp_file(file):
64
64
pass
65
65
66
66
67
+ def is_travis ():
68
+ return os .environ ['QINIU_TEST_ENV' ] == 'travis'
69
+
70
+
67
71
class UtilsTest (unittest .TestCase ):
68
72
69
73
def test_urlsafe (self ):
70
- a = '你好 \x96 '
74
+ a = 'hello \x96 '
71
75
u = urlsafe_base64_encode (a )
72
76
assert b (a ) == urlsafe_base64_decode (u )
73
77
@@ -268,13 +272,14 @@ class UploaderTestCase(unittest.TestCase):
268
272
q = Auth (access_key , secret_key )
269
273
270
274
def test_put (self ):
271
- key = 'a\\ b\\ c"你好 '
275
+ key = 'a\\ b\\ c"hello '
272
276
data = 'hello bubby!'
273
277
token = self .q .upload_token (bucket_name )
274
278
ret , info = put_data (token , key , data )
275
279
print (info )
276
280
assert ret ['key' ] == key
277
281
282
+ def test_put_crc (self ):
278
283
key = ''
279
284
data = 'hello bubby!'
280
285
token = self .q .upload_token (bucket_name , key )
@@ -359,6 +364,39 @@ def test_hasRead_WithoutSeek_retry2(self):
359
364
assert ret is None
360
365
qiniu .set_default (default_zone = qiniu .config .zone0 )
361
366
367
+ def test_putData_without_fname (self ):
368
+ if is_travis ():
369
+ return
370
+ localfile = create_temp_file (30 * 1024 * 1024 )
371
+ key = 'test_putData_without_fname'
372
+ with open (localfile , 'rb' ) as input_stream :
373
+ token = self .q .upload_token (bucket_name )
374
+ ret , info = put_data (token , key , input_stream )
375
+ print (info )
376
+ assert ret is not None
377
+
378
+ def test_putData_without_fname1 (self ):
379
+ if is_travis ():
380
+ return
381
+ localfile = create_temp_file (30 * 1024 * 1024 )
382
+ key = 'test_putData_without_fname1'
383
+ with open (localfile , 'rb' ) as input_stream :
384
+ token = self .q .upload_token (bucket_name )
385
+ ret , info = put_data (token , key , input_stream , self .params , self .mime_type , False , None , "" )
386
+ print (info )
387
+ assert ret is not None
388
+
389
+ def test_putData_without_fname2 (self ):
390
+ if is_travis ():
391
+ return
392
+ localfile = create_temp_file (30 * 1024 * 1024 )
393
+ key = 'test_putData_without_fname2'
394
+ with open (localfile , 'rb' ) as input_stream :
395
+ token = self .q .upload_token (bucket_name )
396
+ ret , info = put_data (token , key , input_stream , self .params , self .mime_type , False , None , " " )
397
+ print (info )
398
+ assert ret is not None
399
+
362
400
363
401
class ResumableUploaderTestCase (unittest .TestCase ):
364
402
0 commit comments