Revision 439e1d3f test/py/ganeti.backend_unittest.py
b/test/py/ganeti.backend_unittest.py | ||
---|---|---|
593 | 593 |
self._test_hv.ListInstances.assert_called_with(hvparams=fake_hvparams) |
594 | 594 |
|
595 | 595 |
|
596 |
class TestGetHvInfo(unittest.TestCase): |
|
597 |
|
|
598 |
def setUp(self): |
|
599 |
self._test_hv = self._TestHypervisor() |
|
600 |
self._test_hv.GetNodeInfo = mock.Mock() |
|
601 |
|
|
602 |
class _TestHypervisor(hypervisor.hv_base.BaseHypervisor): |
|
603 |
def __init__(self): |
|
604 |
hypervisor.hv_base.BaseHypervisor.__init__(self) |
|
605 |
|
|
606 |
def _GetHypervisor(self, name): |
|
607 |
return self._test_hv |
|
608 |
|
|
609 |
def testGetHvInfoAllNone(self): |
|
610 |
result = backend._GetHvInfoAll(None) |
|
611 |
self.assertTrue(result is None) |
|
612 |
|
|
613 |
def testGetHvInfoAll(self): |
|
614 |
hvname = constants.HT_XEN_PVM |
|
615 |
hvparams = {constants.HV_XEN_CMD: constants.XEN_CMD_XL} |
|
616 |
hv_specs = [(hvname, hvparams)] |
|
617 |
|
|
618 |
result = backend._GetHvInfoAll(hv_specs, self._GetHypervisor) |
|
619 |
self._test_hv.GetNodeInfo.assert_called_with(hvparams=hvparams) |
|
620 |
|
|
621 |
|
|
596 | 622 |
if __name__ == "__main__": |
597 | 623 |
testutils.GanetiTestProgram() |
Also available in: Unified diff