Beispiel #1
0
    def test_is_zfs_configuration_compatible_invalid_read_value(self):
        """Check error raised if any content of zfs config file invalid"""

        with tempfile.NamedTemporaryFile("a", prefix="testfile_",
                                         delete=True, dir=".", suffix=".txt") as fobj:
            mockobj = mock.patch.object(BmapHelpers, "ZFS_COMPAT_PARAM_PATH", fobj.name)
            with self.assertRaises(BmapHelpers.Error):
                with mockobj:
                    BmapHelpers.is_zfs_configuration_compatible()
Beispiel #2
0
    def test_is_zfs_configuration_compatible_unreadable_file(self, mock_open):
        """Check error raised if any IO errors when checking zfs config file"""

        mock_open.side_effect = IOError
        with self.assertRaises(BmapHelpers.Error):
            if not BmapHelpers.is_zfs_configuration_compatible():
                raise BmapHelpers.Error
Beispiel #3
0
    def test_is_zfs_configuration_compatible_notinstalled(self):
        """Check compatiblilty check passes when zfs not installed"""

        directory = os.path.dirname(__file__)
        filepath = os.path.join(directory, "BmapHelpers/file/does/not/exist")
        mockobj = mock.patch.object(BmapHelpers, "ZFS_COMPAT_PARAM_PATH", filepath)
        with mockobj:
            self.assertFalse(BmapHelpers.is_zfs_configuration_compatible())
Beispiel #4
0
    def test_is_zfs_configuration_compatible_disabled(self):
        """Check compatiblilty check is false when zfs param is set incorrectly"""

        with tempfile.NamedTemporaryFile("w+", prefix="testfile_",
                                         delete=True, dir=".", suffix=".txt") as fobj:
            fobj.write("0")
            fobj.flush()
            mockobj = mock.patch.object(BmapHelpers, "ZFS_COMPAT_PARAM_PATH", fobj.name)
            with mockobj:
                self.assertFalse(BmapHelpers.is_zfs_configuration_compatible())