Skip to content

Commit 2ad9ad2

Browse files
committed
Merge pull request #199 from forrest-mao/master
add etag unittest
2 parents fbe6c69 + e261887 commit 2ad9ad2

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test_qiniu.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,24 @@ def test_pfop(self):
383383
assert ret['persistentId'] is not None
384384

385385

386+
class EtagTestCase(unittest.TestCase):
387+
def test_zero_size(self):
388+
open("x", 'a').close()
389+
hash = etag("x")
390+
assert hash == 'Fto5o-5ea0sNMlW_75VgGJCv2AcJ'
391+
remove_temp_file("x")
392+
def test_small_size(self):
393+
localfile = create_temp_file(1024 * 1024)
394+
hash = etag(localfile)
395+
assert hash == 'FnlAdmDasGTQOIgrU1QIZaGDv_1D'
396+
remove_temp_file(localfile)
397+
def test_large_size(self):
398+
localfile = create_temp_file(4 * 1024 * 1024 + 1)
399+
hash = etag(localfile)
400+
assert hash == 'ljF323utglY3GI6AvLgawSJ4_dgk'
401+
remove_temp_file(localfile)
402+
403+
386404
class ReadWithoutSeek(object):
387405
def __init__(self, str):
388406
self.str = str

0 commit comments

Comments
 (0)