def test_filesystem_absent_fail(self): ''' Test if filesystem is absent (with snapshots) ''' ret = { 'name': 'myzpool/filesystem', 'result': False, 'comment': "\n".join([ "cannot destroy 'myzpool/filesystem': filesystem has children", "use 'recursive=True' to destroy the following datasets:", "myzpool/filesystem@snap", ]), 'changes': {} } mock_exists = MagicMock(return_value=True) mock_destroy = MagicMock(return_value=OrderedDict([ ('destroyed', False), ('error', "\n".join([ "cannot destroy 'myzpool/filesystem': filesystem has children", "use 'recursive=True' to destroy the following datasets:", "myzpool/filesystem@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.filesystem_absent('myzpool/filesystem'))
def test_filesystem_absent_nofs(self): ''' Test if filesystem is absent (non existing filesystem) ''' ret = { 'name': 'myzpool/filesystem', 'result': True, 'comment': 'filesystem myzpool/filesystem 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.filesystem_absent('myzpool/filesystem'))
def test_filesystem_absent_removed(self): ''' Test if filesystem is absent ''' ret = { 'name': 'myzpool/filesystem', 'result': True, 'comment': 'filesystem myzpool/filesystem was destroyed', 'changes': { 'myzpool/filesystem': '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.filesystem_absent('myzpool/filesystem'))