Revision f79be8ec test/py/ganeti.backend_unittest.py
b/test/py/ganeti.backend_unittest.py | ||
---|---|---|
625 | 625 |
|
626 | 626 |
def testApplyValidStorageType(self): |
627 | 627 |
storage_type = constants.ST_LVM_VG |
628 |
info_fn_orig = backend._STORAGE_TYPE_INFO_FN |
|
628 | 629 |
backend._STORAGE_TYPE_INFO_FN = { |
629 | 630 |
storage_type: self.mock_storage_fn |
630 | 631 |
} |
... | ... | |
633 | 634 |
storage_type, self._STORAGE_KEY, self._SOME_ARGS) |
634 | 635 |
|
635 | 636 |
self.mock_storage_fn.assert_called_with(self._STORAGE_KEY, self._SOME_ARGS) |
637 |
backend._STORAGE_TYPE_INFO_FN = info_fn_orig |
|
636 | 638 |
|
637 | 639 |
def testApplyInValidStorageType(self): |
638 | 640 |
storage_type = "invalid_storage_type" |
641 |
info_fn_orig = backend._STORAGE_TYPE_INFO_FN |
|
639 | 642 |
backend._STORAGE_TYPE_INFO_FN = {} |
640 | 643 |
|
641 | 644 |
self.assertRaises(KeyError, backend._ApplyStorageInfoFunction, |
642 | 645 |
storage_type, self._STORAGE_KEY, self._SOME_ARGS) |
646 |
backend._STORAGE_TYPE_INFO_FN = info_fn_orig |
|
643 | 647 |
|
644 | 648 |
def testApplyNotImplementedStorageType(self): |
645 | 649 |
storage_type = "not_implemented_storage_type" |
650 |
info_fn_orig = backend._STORAGE_TYPE_INFO_FN |
|
646 | 651 |
backend._STORAGE_TYPE_INFO_FN = {storage_type: None} |
647 | 652 |
|
648 | 653 |
self.assertRaises(NotImplementedError, |
649 | 654 |
backend._ApplyStorageInfoFunction, |
650 | 655 |
storage_type, self._STORAGE_KEY, self._SOME_ARGS) |
656 |
backend._STORAGE_TYPE_INFO_FN = info_fn_orig |
|
651 | 657 |
|
652 | 658 |
|
653 | 659 |
class TestGetLvmVgSpaceInfo(unittest.TestCase): |
... | ... | |
784 | 790 |
backend._ApplyStorageInfoFunction = orig_fn |
785 | 791 |
|
786 | 792 |
|
793 |
class TestSpaceReportingConstants(unittest.TestCase): |
|
794 |
"""Ensures consistency between STS_REPORT and backend. |
|
795 |
|
|
796 |
These tests ensure, that the constant 'STS_REPORT' is consitent |
|
797 |
with the implementation of invoking space reporting functions |
|
798 |
in backend.py. Once space reporting is available for all types, |
|
799 |
the constant can be removed and these tests as well. |
|
800 |
|
|
801 |
""" |
|
802 |
def testAllReportingTypesHaveAReportingFunction(self): |
|
803 |
for storage_type in constants.STS_REPORT: |
|
804 |
self.assertTrue(backend._STORAGE_TYPE_INFO_FN[storage_type] is not None) |
|
805 |
|
|
806 |
def testAllNotReportingTypesDoneHaveFunction(self): |
|
807 |
non_reporting_types = set(constants.VALID_STORAGE_TYPES)\ |
|
808 |
- set(constants.STS_REPORT) |
|
809 |
for storage_type in non_reporting_types: |
|
810 |
self.assertEqual(None, backend._STORAGE_TYPE_INFO_FN[storage_type]) |
|
811 |
|
|
812 |
|
|
787 | 813 |
if __name__ == "__main__": |
788 | 814 |
testutils.GanetiTestProgram() |
Also available in: Unified diff