def test_set_failure(utils_patch): """ Tests zfs set failure """ res = OrderedDict([ ("set", False), ( "error", "cannot set property for 'myzpool/mydataset': 'canmount' must be" " one of 'on | off | noauto'", ), ]) ret = { "pid": 79887, "retcode": 1, "stderr": ("cannot set property for 'myzpool/mydataset': 'canmount' must be one of" " 'on | off | noauto'"), "stdout": "", } mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {"cmd.run_all": mock_cmd}), patch.dict( zfs.__utils__, utils_patch): assert res == zfs.set("myzpool/mydataset", canmount="lz4")
def test_set_failure(self): ''' Tests zfs set failure ''' res = {'myzpool/mydataset': {'canmount': "'canmount' must be one of 'on | off | noauto'"}} ret = {'pid': 79887, 'retcode': 1, 'stderr': "cannot set property for 'myzpool/mydataset': 'canmount' must be one of 'on | off | noauto'", 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}): self.assertEqual(zfs.set('myzpool/mydataset', canmount='lz4'), res)
def test_set_success(self): ''' Tests zfs set success ''' res = {'myzpool/mydataset': {'compression': 'set'}} ret = {'pid': 79736, 'retcode': 0, 'stderr': '', 'stdout': ''} mock_cmd = MagicMock(return_value=ret) with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}): self.assertEqual(zfs.set('myzpool/mydataset', compression='lz4'), res)
def test_set_success(utils_patch): """ Tests zfs set success """ res = OrderedDict([("set", True)]) ret = {"pid": 79736, "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): assert res == zfs.set("myzpool/mydataset", compression="lz4")