示例#1
0
    def test_volume_absent_fail(self):
        '''
        Test if volume is absent (with snapshots)
        '''
        ret = {
            'name':
            'myzpool/volume',
            'result':
            False,
            'comment':
            "\n".join([
                "cannot destroy 'myzpool/volume': volume has children",
                "use 'recursive=True' to destroy the following datasets:",
                "myzpool/volume@snap",
            ]),
            'changes': {}
        }

        mock_exists = MagicMock(return_value=True)
        mock_destroy = MagicMock(return_value=OrderedDict([
            ('destroyed', False),
            ('error', "\n".join([
                "cannot destroy 'myzpool/volume': volume has children",
                "use 'recursive=True' to destroy the following datasets:",
                "myzpool/volume@snap",
            ])),
        ]))
        with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \
             patch.dict(zfs.__salt__, {'zfs.destroy': mock_destroy}), \
             patch.dict(zfs.__utils__, utils_patch):
            self.assertEqual(ret, zfs.volume_absent('myzpool/volume'))
示例#2
0
    def test_volume_absent_novol(self):
        '''
        Test if volume is absent (non existing volume)
        '''
        ret = {
            'name': 'myzpool/volume',
            'result': True,
            'comment': 'volume myzpool/volume is absent',
            'changes': {}
        }

        mock_exists = MagicMock(return_value=False)
        with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \
             patch.dict(zfs.__utils__, utils_patch):
            self.assertEqual(ret, zfs.volume_absent('myzpool/volume'))
示例#3
0
    def test_volume_absent_removed(self):
        '''
        Test if volume is absent
        '''
        ret = {
            'name': 'myzpool/volume',
            'result': True,
            'comment': 'volume myzpool/volume was destroyed',
            'changes': {
                'myzpool/volume': 'destroyed'
            }
        }

        mock_exists = MagicMock(return_value=True)
        mock_destroy = MagicMock(return_value=OrderedDict([('destroyed',
                                                            True)]))
        with patch.dict(zfs.__salt__, {'zfs.exists': mock_exists}), \
             patch.dict(zfs.__salt__, {'zfs.destroy': mock_destroy}), \
             patch.dict(zfs.__utils__, utils_patch):
            self.assertEqual(ret, zfs.volume_absent('myzpool/volume'))