Revision 0ba177e2 test/ganeti.cmdlib_unittest.py
b/test/ganeti.cmdlib_unittest.py | ||
---|---|---|
521 | 521 |
cmdlib._UpdateAndVerifySubDict, {}, test, self.type_check) |
522 | 522 |
|
523 | 523 |
|
524 |
class TestHvStateHelper(unittest.TestCase): |
|
525 |
def testWithoutOpData(self): |
|
526 |
self.assertEqual(cmdlib._MergeAndVerifyHvState(None, NotImplemented), None) |
|
527 |
|
|
528 |
def testWithoutOldData(self): |
|
529 |
new = { |
|
530 |
constants.HT_XEN_PVM: { |
|
531 |
constants.HVST_MEMORY_TOTAL: 4096, |
|
532 |
}, |
|
533 |
} |
|
534 |
self.assertEqual(cmdlib._MergeAndVerifyHvState(new, None), new) |
|
535 |
|
|
536 |
def testWithWrongHv(self): |
|
537 |
new = { |
|
538 |
"i-dont-exist": { |
|
539 |
constants.HVST_MEMORY_TOTAL: 4096, |
|
540 |
}, |
|
541 |
} |
|
542 |
self.assertRaises(errors.OpPrereqError, cmdlib._MergeAndVerifyHvState, new, |
|
543 |
None) |
|
544 |
|
|
545 |
class TestDiskStateHelper(unittest.TestCase): |
|
546 |
def testWithoutOpData(self): |
|
547 |
self.assertEqual(cmdlib._MergeAndVerifyDiskState(None, NotImplemented), |
|
548 |
None) |
|
549 |
|
|
550 |
def testWithoutOldData(self): |
|
551 |
new = { |
|
552 |
constants.LD_LV: { |
|
553 |
"xenvg": { |
|
554 |
constants.DS_DISK_RESERVED: 1024, |
|
555 |
}, |
|
556 |
}, |
|
557 |
} |
|
558 |
self.assertEqual(cmdlib._MergeAndVerifyDiskState(new, None), new) |
|
559 |
|
|
560 |
def testWithWrongStorageType(self): |
|
561 |
new = { |
|
562 |
"i-dont-exist": { |
|
563 |
"xenvg": { |
|
564 |
constants.DS_DISK_RESERVED: 1024, |
|
565 |
}, |
|
566 |
}, |
|
567 |
} |
|
568 |
self.assertRaises(errors.OpPrereqError, cmdlib._MergeAndVerifyDiskState, |
|
569 |
new, None) |
|
570 |
|
|
571 |
|
|
524 | 572 |
if __name__ == "__main__": |
525 | 573 |
testutils.GanetiTestProgram() |
Also available in: Unified diff