Adam Litke has posted comments on this change.

Change subject: tests: Simplify DirectFile tests
......................................................................


Patch Set 3:

(6 comments)

Very nice reduction and simplification!  See comments about units and use of a 
constant.

https://gerrit.ovirt.org/#/c/54678/3/tests/fileUtilTests.py
File tests/fileUtilTests.py:

Line 30: 
Line 31: @expandPermutations
Line 32: class DirectFileTests(TestCaseBase):
Line 33: 
Line 34:     DATA = "a" * 512 + "b" * 512
Should we use a block size constant instead of a magic number here?
Line 35: 
Line 36:     @permutations([[0], [512], [1024], [1024 + 512]])
Line 37:     def testRead(self, size):
Line 38:         with temporaryPath(data=self.DATA) as srcPath, \


Line 32: class DirectFileTests(TestCaseBase):
Line 33: 
Line 34:     DATA = "a" * 512 + "b" * 512
Line 35: 
Line 36:     @permutations([[0], [512], [1024], [1024 + 512]])
perhaps the permutations could be a number of blocks.
Line 37:     def testRead(self, size):
Line 38:         with temporaryPath(data=self.DATA) as srcPath, \
Line 39:                 fileUtils.open_ex(srcPath, "dr") as f:
Line 40:             self.assertEquals(f.read(size), self.DATA[:size])


Line 38:         with temporaryPath(data=self.DATA) as srcPath, \
Line 39:                 fileUtils.open_ex(srcPath, "dr") as f:
Line 40:             self.assertEquals(f.read(size), self.DATA[:size])
Line 41: 
Line 42:     @permutations([[512], [1024]])
same.
Line 43:     def testSeekRead(self, offset):
Line 44:         with temporaryPath(data=self.DATA) as srcPath, \
Line 45:                 fileUtils.open_ex(srcPath, "dr") as f:
Line 46:             f.seek(offset)


Line 55:     def testSmallWrites(self):
Line 56:         with temporaryPath() as srcPath, \
Line 57:                 fileUtils.open_ex(srcPath, "dw") as f:
Line 58:             f.write(self.DATA[:512])
Line 59:             f.write(self.DATA[512:])
Use the constant.
Line 60: 
Line 61:             with fileUtils.open_ex(srcPath, "r") as f:
Line 62:                 self.assertEquals(f.read(), self.DATA)
Line 63: 


Line 63: 
Line 64:     def testUpdateRead(self):
Line 65:         with temporaryPath() as srcPath, \
Line 66:                 fileUtils.open_ex(srcPath, "wd") as f:
Line 67:             f.write(self.DATA[:512])
same.
Line 68: 
Line 69:             with fileUtils.open_ex(srcPath, "r+d") as f:
Line 70:                 f.seek(512)
Line 71:                 f.write(self.DATA[512:])


Line 67:             f.write(self.DATA[:512])
Line 68: 
Line 69:             with fileUtils.open_ex(srcPath, "r+d") as f:
Line 70:                 f.seek(512)
Line 71:                 f.write(self.DATA[512:])
same.
Line 72: 
Line 73:             with fileUtils.open_ex(srcPath, "r") as f:
Line 74:                 self.assertEquals(f.read(), self.DATA)
Line 75: 


-- 
To view, visit https://gerrit.ovirt.org/54678
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ic86b0fe22d5d5f1c9252b658ad76a13626de8246
Gerrit-PatchSet: 3
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <[email protected]>
Gerrit-Reviewer: Adam Litke <[email protected]>
Gerrit-Reviewer: Ala Hino <[email protected]>
Gerrit-Reviewer: Dan Kenigsberg <[email protected]>
Gerrit-Reviewer: Francesco Romani <[email protected]>
Gerrit-Reviewer: Freddy Rolland <[email protected]>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Nir Soffer <[email protected]>
Gerrit-Reviewer: gerrit-hooks <[email protected]>
Gerrit-HasComments: Yes
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to