Code Duplication    Length = 10-11 lines in 4 locations

test_qiniu.py 4 locations

@@ 417-427 (lines=11) @@
414
            print(info)
415
            assert ret['key'] == key
416
417
    def test_big_file(self):
418
        key = 'big'
419
        token = self.q.upload_token(bucket_name, key)
420
        localfile = create_temp_file(4 * 1024 * 1024 + 1)
421
        progress_handler = lambda progress, total: progress
422
        qiniu.set_default(default_zone=Zone('a', 'upload.qiniu.com'))
423
        ret, info = put_file(token, key, localfile, self.params, self.mime_type, progress_handler=progress_handler)
424
        print(info)
425
        assert ret['key'] == key
426
        qiniu.set_default(default_zone=qiniu.config.zone0)
427
        remove_temp_file(localfile)
428
429
    def test_retry(self):
430
        localfile = __file__
@@ 429-438 (lines=10) @@
426
        qiniu.set_default(default_zone=qiniu.config.zone0)
427
        remove_temp_file(localfile)
428
429
    def test_retry(self):
430
        localfile = __file__
431
        key = 'test_file_r_retry'
432
        qiniu.set_default(default_zone=Zone('a', 'upload.qiniu.com'))
433
        token = self.q.upload_token(bucket_name, key)
434
        ret, info = put_file(token, key, localfile, self.params, self.mime_type)
435
        print(info)
436
        assert ret['key'] == key
437
        assert ret['hash'] == etag(localfile)
438
        qiniu.set_default(default_zone=qiniu.config.zone0)
439
440
441
class DownloadTestCase(unittest.TestCase):
@@ 336-345 (lines=10) @@
333
        assert ret['hash'] == 'FlYu0iBR1WpvYi4whKXiBuQpyLLk'
334
        qiniu.set_default(default_zone=qiniu.config.zone0)
335
336
    def test_hasRead_hasSeek_retry(self):
337
        key = 'withReadAndSeek_retry'
338
        data = StringIO('hello retry again!')
339
        set_default(default_zone=Zone('a', 'upload.qiniu.com'))
340
        token = self.q.upload_token(bucket_name)
341
        ret, info = put_data(token, key, data)
342
        print(info)
343
        assert ret['key'] == key
344
        assert ret['hash'] == 'FuEbdt6JP2BqwQJi7PezYhmuVYOo'
345
        qiniu.set_default(default_zone=qiniu.config.zone0)
346
347
    def test_hasRead_withoutSeek_retry(self):
348
        key = 'withReadAndWithoutSeek_retry'
@@ 325-334 (lines=10) @@
322
        assert ret is None
323
        assert info.status_code == 403  # key not match
324
325
    def test_withoutRead_withoutSeek_retry(self):
326
        key = 'retry'
327
        data = 'hello retry!'
328
        set_default(default_zone=Zone('a', 'upload.qiniu.com'))
329
        token = self.q.upload_token(bucket_name)
330
        ret, info = put_data(token, key, data)
331
        print(info)
332
        assert ret['key'] == key
333
        assert ret['hash'] == 'FlYu0iBR1WpvYi4whKXiBuQpyLLk'
334
        qiniu.set_default(default_zone=qiniu.config.zone0)
335
336
    def test_hasRead_hasSeek_retry(self):
337
        key = 'withReadAndSeek_retry'