Nir Soffer has posted comments on this change. Change subject: Simplify tests for qemuimg to allow additional capabilities checks ......................................................................
Patch Set 5: (5 comments) http://gerrit.ovirt.org/#/c/36366/5//COMMIT_MSG Commit Message: Line 9: Tests are mocking execCmd() to fake _supports_qcow2_compat(). To allow Line 10: other capabilities checks inside convert(), this patch is: Line 11: - Creating a new class for compat tests. Line 12: - Moving compat commands tests from create/convert iclass to compat class. Line 13: - Testing the_supports_qcow2_compat() itself. the_supports_qcow2_compat -> the supports_qcow2_compat Line 14: - Removing the need of mocking execCmd() inside convert tests. Line 15: - Mocking _supports_qcow2_compat() for convert and create tests. Line 16: Line 17: Change-Id: I386772bf2a25a880b5ad387f284679eed81c5615 http://gerrit.ovirt.org/#/c/36366/5/tests/qemuimgTests.py File tests/qemuimgTests.py: Line 42: def __exit__(self, t=None, v=None, tb=None): Line 43: self.patch.revert() Line 44: Line 45: Line 46: class TestCaseBase(TestCaseBase): This is legal but evil - you want to give this class its own name, like CommandTests. Line 47: Line 48: def supported(self, command, result): Line 49: def check(arg): Line 50: self.assertEqual(command, arg) Line 258: qemuimg.convert('src', 'dst', None, dstFormat='qcow2', Line 259: backing='bak', backingFormat='qcow2') Line 260: Line 261: Line 262: class CompatTests(TestCaseBase): We can call this SupportsQcow2ComaptTests, and then we can shorten the tests names: def test_create_supported(self): ... def test_create_unsupported(self): ... Line 263: Line 264: def test_create_command(self, **kw): Line 265: def create(cmd, **kw): Line 266: expected = [QEMU_IMG, 'create', '-f', 'qcow2', '-o', '?', Line 268: self.assertEqual(cmd, expected) Line 269: return 0, '', '' Line 270: Line 271: with FakeCmd(utils, 'execCmd', create): Line 272: qemuimg._supports_qcow2_compat('create') Why do we need this test? This is already tested above in CreateTests and ConvertTests. This class is about testing the _supports_qcow2_compat function - right? Line 273: Line 274: def test_convert_command(self, **kw): Line 275: def convert(cmd, **kw): Line 276: expected = [QEMU_IMG, 'convert', '-O', 'qcow2', '-o', '?', Line 278: self.assertEqual(cmd, expected) Line 279: return 0, '', '' Line 280: Line 281: with FakeCmd(utils, 'execCmd', convert): Line 282: qemuimg._supports_qcow2_compat('convert') Same Line 283: Line 284: def test_create_qcow2_compat_supported(self, **kw): Line 285: with FakeCmd(utils, 'execCmd', self.qcow2_compat_supported): Line 286: self.assertTrue(qemuimg._supports_qcow2_compat('create')) -- To view, visit http://gerrit.ovirt.org/36366 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I386772bf2a25a880b5ad387f284679eed81c5615 Gerrit-PatchSet: 5 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Amador Pahim <[email protected]> Gerrit-Reviewer: Amador Pahim <[email protected]> Gerrit-Reviewer: Dan Kenigsberg <[email protected]> Gerrit-Reviewer: Federico Simoncelli <[email protected]> Gerrit-Reviewer: Nir Soffer <[email protected]> Gerrit-Reviewer: [email protected] Gerrit-Reviewer: oVirt Jenkins CI Server Gerrit-HasComments: Yes _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
