def test_promote_success(self): ''' Tests zfs promote success ''' res = OrderedDict([('promoted', True)]) ret = {'pid': 69075, 'retcode': 0, 'stderr': '', 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ patch.dict(zfs.__utils__, utils_patch): self.assertEqual(res, zfs.promote('myzpool/yesterday'))
def test_promote_failure(self): ''' Tests zfs promote failure ''' res = OrderedDict([ ('promoted', False), ('error', "cannot promote 'myzpool/yesterday': not a cloned filesystem"), ]) ret = { 'pid': 69209, 'retcode': 1, 'stderr': "cannot promote 'myzpool/yesterday': not a cloned filesystem", 'stdout': '' } mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}), \ patch.dict(zfs.__utils__, utils_patch): self.assertEqual(res, zfs.promote('myzpool/yesterday'))