Skip to content

Commit

Permalink
Merge pull request qiniu#199 from forrest-mao/master
Browse files Browse the repository at this point in the history
add etag unittest
  • Loading branch information
longbai committed Apr 30, 2016
2 parents fbe6c69 + e261887 commit 2ad9ad2
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test_qiniu.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,24 @@ def test_pfop(self):
assert ret['persistentId'] is not None


class EtagTestCase(unittest.TestCase):
def test_zero_size(self):
open("x", 'a').close()
hash = etag("x")
assert hash == 'Fto5o-5ea0sNMlW_75VgGJCv2AcJ'
remove_temp_file("x")
def test_small_size(self):
localfile = create_temp_file(1024 * 1024)
hash = etag(localfile)
assert hash == 'FnlAdmDasGTQOIgrU1QIZaGDv_1D'
remove_temp_file(localfile)
def test_large_size(self):
localfile = create_temp_file(4 * 1024 * 1024 + 1)
hash = etag(localfile)
assert hash == 'ljF323utglY3GI6AvLgawSJ4_dgk'
remove_temp_file(localfile)


class ReadWithoutSeek(object):
def __init__(self, str):
self.str = str
Expand Down

0 comments on commit 2ad9ad2

Please sign in to comment.