def test_split_brain_exception(self, mock_sp, mock_exit): ctx = mock.Mock(sp_iptables=True) mock_sp_inst = mock.Mock() mock_sp.return_value = mock_sp_inst mock_sp_inst.pre_check.side_effect = task.TaskError("error data") main.split_brain(ctx) mock_sp_inst.error.assert_called_once_with("error data") mock_exit.assert_called_once_with(1)
def test_split_brain(self, mock_sp): ctx = mock.Mock(sp_iptables=True, yes=False) mock_sp_inst = mock.Mock() mock_sp.return_value = mock_sp_inst mock_sp_inst.do_block.return_value.__enter__ = mock.Mock() mock_sp_inst.do_block.return_value.__exit__ = mock.Mock() main.split_brain(ctx) mock_sp.assert_called_once_with(False) mock_sp_inst.pre_check.assert_called_once_with() mock_sp_inst.print_header.assert_called_once_with() mock_sp_inst.do_block.assert_called_once_with() mock_sp_inst.run.assert_called_once_with() mock_sp_inst.wait.assert_called_once_with()
def test_split_brain_return(self): ctx = mock.Mock(sp_iptables=None) main.split_brain(ctx)