示例#1
0
 def test_hold_success(self):
     '''
     Tests zfs hold success
     '''
     res = OrderedDict([('held', True)])
     ret = {'pid': 50876, '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.hold('important', 'myzpool/mydataset@baseline',
                      'myzpool/[email protected]'))
示例#2
0
 def test_hold_failure(self):
     '''
     Tests zfs hold failure
     '''
     res = OrderedDict([
         ('held', False),
         ('error',
          "cannot hold snapshot 'myzpool/mydataset@baseline': tag already exists on this dataset"
          ),
     ])
     ret = {
         'pid': 51006,
         'retcode': 1,
         'stderr':
         "cannot hold snapshot 'myzpool/mydataset@baseline': tag already exists on this dataset",
         '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.hold('important', 'myzpool/mydataset@baseline'))