Nir Soffer has posted comments on this change.

Change subject: fix tests for qemuimg.convert() to allow additional 
capabilities checks
......................................................................


Patch Set 1:

(1 comment)

http://gerrit.ovirt.org/#/c/36366/1/tests/qemuimgTests.py
File tests/qemuimgTests.py:

Line 177:             self.assertEqual(cmd, expected)
Line 178:             return 0, '', ''
Line 179: 
Line 180:         with FakeCmd(qemuimg, '_supports_qcow2_compat',
Line 181:                      self.qcow2_compat_unsupported):
The direction is good, simplifying the tests. However FakeCmd is not a general 
mocking utility. You should use monkeypatch.MonkeyScope for this.

The function mocking _supports_xxx should do 2 things:
- assert that the command argument is correct
- return True or False

We can do something like this:

    def supports(self, command):
        def check(arg):
            self.assertEqual(command, arg)
            return True
        return check

    def test_supports...
        with MonkeyPatchScope(
            [(qemuimg, '_supports_xxx', self.supports("convert"))]):
            code that assumes _supports_xxx("convert") returns True...
Line 182:             with FakeCmd(utils, 'watchCmd', convert):
Line 183:                 qemuimg.convert('src', 'dst', True, dstFormat='qcow2')
Line 184: 
Line 185:     def test_qcow2_compat_supported(self):


-- 
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: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: 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-HasComments: Yes
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to