@@ -3470,11 +3470,6 @@ def test_cos_comm_misc():
34703470 r = format_path ('/test/path/to' )
34713471 assert r == 'test/path/to'
34723472
3473- def test_cosconfig_misc ():
3474- test_conf = CosConfig (Access_id = SECRET_ID , Access_key = SECRET_KEY )
3475- test_conf .set_ip_port ('10.0.0.1' , 80 )
3476- test_conf .set_credential (SecretId = SECRET_ID , SecretKey = SECRET_KEY , Token = None )
3477-
34783473def test_cos_exception_unknow ():
34793474 msg = '<Error></Error>'
34803475 e = CosServiceError ('GET' , msg , '400' )
@@ -3484,6 +3479,52 @@ def test_cos_exception_unknow():
34843479 assert e .get_trace_id () == 'Unknown'
34853480 assert e .get_request_id () == 'Unknown'
34863481
3482+ def test_check_multipart_upload ():
3483+ test_key = 'test_key'
3484+ test_data = 'x' * 1024 * 1024
3485+ with open (test_key , 'w' ) as f :
3486+ f .write (test_data )
3487+ response = client .create_multipart_upload (
3488+ Bucket = test_bucket ,
3489+ Key = test_key ,
3490+ )
3491+ uploadId = response ['UploadId' ]
3492+ response = client .upload_part (
3493+ Bucket = test_bucket ,
3494+ Key = test_key ,
3495+ Body = test_data ,
3496+ PartNumber = 1 ,
3497+ UploadId = uploadId
3498+ )
3499+ response = client .list_parts (
3500+ Bucket = test_bucket ,
3501+ Key = test_key ,
3502+ UploadId = uploadId
3503+ )
3504+
3505+ tmp_file = 'tmp_file'
3506+ record = {'bucket' : test_bucket , 'key' : test_key , 'tmp_filename' : tmp_file ,
3507+ 'mtime' : response ['Part' ][0 ]['LastModified' ], 'etag' : response ['Part' ][0 ]['ETag' ],
3508+ 'file_size' : response ['Part' ][0 ]['Size' ], 'part_size' : response ['Part' ][0 ]['Size' ], 'parts' : []}
3509+ with open (tmp_file , 'w' ) as f :
3510+ json .dump (record , f )
3511+ r = client ._check_all_upload_parts (
3512+ bucket = test_bucket ,
3513+ key = test_key ,
3514+ uploadid = uploadId ,
3515+ local_path = test_key ,
3516+ parts_num = 1 ,
3517+ part_size = int (response ['Part' ][0 ]['Size' ]),
3518+ last_size = int (response ['Part' ][0 ]['Size' ]),
3519+ already_exist_parts = {}
3520+ )
3521+ assert r
3522+ response = client .abort_multipart_upload (
3523+ Bucket = test_bucket ,
3524+ Key = test_key ,
3525+ UploadId = uploadId
3526+ )
3527+
34873528if __name__ == "__main__" :
34883529 setUp ()
34893530 """
0 commit comments