LGTM, thanks
On Wed, Feb 6, 2013 at 2:59 PM, Michael Hanselmann <[email protected]>wrote: > This patch adds unit tests for success and failure of the “GetNodeInfo” > method for the Xen hypervisor abstractions. > --- > test/py/ganeti.hypervisor.hv_xen_unittest.py | 29 > ++++++++++++++++++++++++++++ > 1 file changed, 29 insertions(+) > > diff --git a/test/py/ganeti.hypervisor.hv_xen_unittest.py b/test/py/ > ganeti.hypervisor.hv_xen_unittest.py > index 057ac76..3679de4 100755 > --- a/test/py/ganeti.hypervisor.hv_xen_unittest.py > +++ b/test/py/ganeti.hypervisor.hv_xen_unittest.py > @@ -716,6 +716,35 @@ class _TestXenHypervisor(object): > > self.assertEqual(ping_fn.Count(), expected_pings) > > + def _GetNodeInfoCmd(self, fail, cmd): > + if cmd == [self.CMD, "info"]: > + if fail: > + return self._FailingCommand(cmd) > + else: > + output = testutils.ReadTestData("xen-xm-info-4.0.1.txt") > + elif cmd == [self.CMD, "list"]: > + if fail: > + self.fail("'xm list' shouldn't be called when 'xm info' failed") > + else: > + output = > testutils.ReadTestData("xen-xm-list-4.0.1-four-instances.txt") > + else: > + self.fail("Unhandled command: %s" % (cmd, )) > + > + return self._SuccessCommand(output, cmd) > + > + def testGetNodeInfo(self): > + run_cmd = compat.partial(self._GetNodeInfoCmd, False) > + hv = self._GetHv(run_cmd=run_cmd) > + result = hv.GetNodeInfo() > + > + self.assertEqual(result["hv_version"], (4, 0)) > + self.assertEqual(result["memory_free"], 8004) > + > + def testGetNodeInfoFailing(self): > + run_cmd = compat.partial(self._GetNodeInfoCmd, True) > + hv = self._GetHv(run_cmd=run_cmd) > + self.assertTrue(hv.GetNodeInfo() is None) > + > > def _MakeTestClass(cls, cmd): > """Makes a class for testing. > -- > 1.8.1 > >
