def test_split_not_mirror(utils_patch): """ Tests split on source pool is not a mirror """ ret = {} ret["stdout"] = "" ret[ "stderr" ] = "Unable to split datapool: Source pool must be composed only of mirrors" ret["retcode"] = 1 mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {"cmd.run_all": mock_cmd}), patch.dict( zpool.__utils__, utils_patch ): ret = zpool.split("datapool", "backuppool") res = OrderedDict( [ ("split", False), ( "error", "Unable to split datapool: Source pool must be composed only of" " mirrors", ), ] ) assert ret == res
def test_split_success(self): """ Tests split on success """ ret = {} ret["stdout"] = "" ret["stderr"] = "" ret["retcode"] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {"cmd.run_all": mock_cmd}), patch.dict( zpool.__utils__, self.utils_patch): ret = zpool.split("datapool", "backuppool") res = OrderedDict([("split", True)]) self.assertEqual(ret, res)
def test_split_success(self): ''' Tests split on success ''' ret = {} ret['stdout'] = "" ret['stderr'] = "" ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ patch.dict(zpool.__utils__, self.utils_patch): ret = zpool.split('datapool', 'backuppool') res = OrderedDict([('split', True)]) self.assertEqual(ret, res)
def test_split_not_mirror(self): ''' Tests split on source pool is not a mirror ''' ret = {} ret['stdout'] = "" ret['stderr'] = "Unable to split datapool: Source pool must be composed only of mirrors" ret['retcode'] = 1 mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ patch.dict(zpool.__utils__, utils_patch): ret = zpool.split('datapool', 'backuppool') res = OrderedDict([('split', False), ('error', 'Unable to split datapool: Source pool must be composed only of mirrors')]) self.assertEqual(ret, res)
def test_split_missing_pool(self): ''' Tests split on missing source pool ''' ret = {} ret['stdout'] = "" ret['stderr'] = "cannot open 'datapool': no such pool" ret['retcode'] = 1 mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ patch.dict(zpool.__utils__, utils_patch): ret = zpool.split('datapool', 'backuppool') res = OrderedDict([('split', False), ('error', "cannot open 'datapool': no such pool")]) self.assertEqual(ret, res)
def test_split_exist_new(self): ''' Tests split on exising new pool ''' ret = {} ret['stdout'] = "" ret['stderr'] = "Unable to split datapool: pool already exists" ret['retcode'] = 1 mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}), \ patch.dict(zpool.__utils__, utils_patch): ret = zpool.split('datapool', 'backuppool') res = OrderedDict([('split', False), ('error', 'Unable to split datapool: pool already exists')]) self.assertEqual(ret, res)
def test_split_missing_pool(self): """ Tests split on missing source pool """ ret = {} ret["stdout"] = "" ret["stderr"] = "cannot open 'datapool': no such pool" ret["retcode"] = 1 mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {"cmd.run_all": mock_cmd}), patch.dict( zpool.__utils__, self.utils_patch): ret = zpool.split("datapool", "backuppool") res = OrderedDict([("split", False), ("error", "cannot open 'datapool': no such pool")]) self.assertEqual(ret, res)
def test_split_success(self): ''' Tests split on success ''' ret = {} ret['stdout'] = "" ret['stderr'] = "" ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) mock_exists = Mock() mock_exists.side_effect = [False, True] with patch.dict(zpool.__salt__, {'zpool.exists': mock_exists}): with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}): ret = zpool.split('datapool', 'backuppool') res = OrderedDict([('backuppool', 'split off from datapool')]) self.assertEqual(res, ret)
def test_split_exist_new(self): """ Tests split on exising new pool """ ret = {} ret["stdout"] = "" ret["stderr"] = "Unable to split datapool: pool already exists" ret["retcode"] = 1 mock_cmd = MagicMock(return_value=ret) with patch.dict(zpool.__salt__, {"cmd.run_all": mock_cmd}), patch.dict( zpool.__utils__, self.utils_patch): ret = zpool.split("datapool", "backuppool") res = OrderedDict([ ("split", False), ("error", "Unable to split datapool: pool already exists"), ]) self.assertEqual(ret, res)
def test_split_missing_pool(self): ''' Tests split on missing source pool ''' ret = {} ret['stdout'] = "" ret['stderr'] = "" ret['retcode'] = 0 mock_cmd = MagicMock(return_value=ret) mock_exists = Mock() mock_exists.side_effect = [False, False] with patch.dict(zpool.__salt__, {'zpool.exists': mock_exists}): with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}): ret = zpool.split('datapool', 'backuppool') res = OrderedDict([('datapool', 'storage pool does not exists') ]) self.assertEqual(res, ret)
def test_split_not_mirror(self): ''' Tests split on source pool is not a mirror ''' ret = {} ret['stdout'] = "" ret['stderr'] = "Unable to split datapool: Source pool must be composed only of mirrors" ret['retcode'] = 1 mock_cmd = MagicMock(return_value=ret) mock_exists = Mock() mock_exists.side_effect = [False, True] with patch.dict(zpool.__salt__, {'zpool.exists': mock_exists}): with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}): ret = zpool.split('datapool', 'backuppool') res = OrderedDict([( 'backuppool', 'Unable to split datapool: Source pool must be composed only of mirrors' )]) self.assertEqual(res, ret)