示例#1
0
 def test_set_success(self):
     '''
     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):
         self.assertEqual(res,
                          zfs.set('myzpool/mydataset', compression='lz4'))
示例#2
0
 def test_set_failure(self):
     '''
     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):
         self.assertEqual(res, zfs.set('myzpool/mydataset', canmount='lz4'))