def test_getDeferInstance__listfail(self): n=self.mocker.replace("cxm.node.Node.__init__") n("node1") n("node2") self.mocker.throw(Exception()) self.mocker.replay() d=XenCluster.getDeferInstance(["node1","node2"]) return self.assertFailure(d, cxm.xencluster.InstantiationError)
def test_getDeferInstance__listok(self): n=self.mocker.replace("cxm.node.Node.__init__") n("node1") n("node2") self.mocker.replay() d=XenCluster.getDeferInstance(["node1","node2"]) d.addCallback(self.assertIsInstance, XenCluster) return d
def test_getDeferInstance__agentfail(self): a=self.mocker.replace("cxm.agent.Agent.__init__") a() getNodesList=self.mocker.replace("cxm.agent.Agent.getNodesList") getNodesList() self.mocker.result(defer.fail(Failure("some error",Exception))) self.mocker.replay() d=XenCluster.getDeferInstance() return self.assertFailure(d, Exception)
def test_getDeferInstance__agentok(self): a=self.mocker.replace("cxm.agent.Agent.__init__") a() getNodesList=self.mocker.replace("cxm.agent.Agent.getNodesList") getNodesList() self.mocker.result(defer.succeed(["node1","node2"])) n=self.mocker.replace("cxm.node.Node.__init__") n("node1") n("node2") self.mocker.replay() d=XenCluster.getDeferInstance() d.addCallback(self.assertIsInstance, XenCluster) return d