예제 #1
0
 def test_rename_success(self):
     '''
     Tests successful return of rename function
     '''
     res = OrderedDict([('renamed', True)])
     ret = {}
     ret['stdout'] = ""
     ret['stderr'] = ""
     ret['retcode'] = 0
     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.rename('myzpool/mydataset', 'myzpool/newdataset'))
예제 #2
0
 def test_rename_error_not_exists(self):
     '''
     Tests failure return of rename function
     '''
     res = OrderedDict([
         ('renamed', False),
         ('error',
          "cannot open 'myzpool/mydataset': dataset does not exist"),
     ])
     ret = {}
     ret['stdout'] = ""
     ret['stderr'] = "cannot open 'myzpool/mydataset': dataset does not exist"
     ret['retcode'] = 1
     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.rename('myzpool/mydataset', 'myzpool/newdataset'))