Skip to content

Commit

Permalink
added unit tests
Browse files Browse the repository at this point in the history
fix unit tests
  • Loading branch information
amaltaro committed Jul 8, 2020
1 parent f4e25e3 commit 98f0b5d
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions test/python/Utils_t/FileTools_t.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ def test_fileInfo(self):
silly = "This is a rather ridiculous string"
filename = os.path.join(self.testDir, 'fileInfo.test')

f = open(filename, 'w')
f.write(silly)
f.close()
with open(filename, 'w') as fObj:
fObj.write(silly)

info = FileTools.getFileInfo(filename=filename)
self.assertEqual(info['Name'], filename)
Expand All @@ -84,5 +83,26 @@ def test_getFullPath(self):
fullPath = FileTools.getFullPath("this_shouldnt_be")
self.assertEqual(fullPath, None)

def testChecksum(self):
"""
Test file checksums calculation
"""
filename = os.path.join(self.testDir, 'fileInfo.test')
with open(filename, 'w') as fObj:
fObj.write("")

(adler32, cksum) = FileTools.calculateChecksums(filename=filename)
self.assertEqual(adler32, "00000001")
self.assertEqual(cksum, "4294967295")

silly = "This is a rather ridiculous string"
with open(filename, 'w') as fObj:
fObj.write(silly * 100001)
(adler32, cksum) = FileTools.calculateChecksums(filename=filename)
self.assertEqual(adler32, "827db5b1")
self.assertEqual(cksum, "3774692924")
return


if __name__ == "__main__":
unittest.main()

0 comments on commit 98f0b5d

Please sign in to comment.