Change in vdsm[master]: clientif: add initial tests

nsoffer at redhat.com nsoffer at redhat.com
Tue Feb 18 09:03:09 UTC 2014


Nir Soffer has posted comments on this change.

Change subject: clientif: add initial tests
......................................................................


Patch Set 1:

(2 comments)

How to monkeypatch clientIF.supervdsm.

http://gerrit.ovirt.org/#/c/24614/1/tests/clientifTests.py
File tests/clientifTests.py:

Line 47: 
Line 48: 
Line 49: class FakeClientIF(clientIF.clientIF):
Line 50:     def __init__(self, supervdsm):
Line 51:         self.supervdsm = supervdsm
Sorry, looking at your old code, I thought that clientIF was having an instance or class variable with supervdsm, but checking the code, we just use the module. So you don't need this supervdsm instance variable and parameter.
Line 52:         self.irs = None  # just to make sure nothing ever happens
Line 53:         self.log = logging.getLogger('ClientIFTests')
Line 54: 
Line 55: 


Line 97:         def getFakeProxy():
Line 98:             return self.supervdsm
Line 99:         clientIF.supervdsm.getProxy = getFakeProxy
Line 100:         # the supervdsm module uses a global to implement the singleton
Line 101:         # pattern. We need to override the getter function.
> Are you sure that we need this here?
What you want here is to monkeypatch clientIF module with your face supervdsm. To do this, you can use the monkeypatch module.

    @MonkeyPatch(clientIF, 'supervdsm', FakeSuperVdsm())
    def testFoo(self):
        # You can access clientIF.supervdsm for checking results or modify the object.

And then you don't need self.supervdsm instance variable.
Line 102: 
Line 103:     def assertCalled(self, funcName):
Line 104:         name, args, kwargs = self.supervdsm.calls[0]
Line 105:         self.assertEquals(name, funcName)


-- 
To view, visit http://gerrit.ovirt.org/24614
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Iad652aed46b9fe985d7143052bd26320970502b5
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Allon Mureinik <amureini at redhat.com>
Gerrit-Reviewer: Antoni Segura Puimedon <asegurap at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Eduardo <ewarszaw at redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Martin Polednik <mpoledni at redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: Vinzenz Feenstra <vfeenstr at redhat.com>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes


More information about the vdsm-patches mailing list