'Mock the "send to XQueue" method to return either success or an error.'

@contextmanager
def _mock_queue(self, is_successful=True):

    symbol = 'capa.xqueue_interface.XQueueInterface.send_to_queue'
    with patch(symbol) as mock_send_to_queue:
        if is_successful:
            mock_send_to_queue.return_value = (0, 'Successfully    queued')
        else:
            mock_send_to_queue.side_effect = XQueueAddToQueueError(1, self.ERROR_REASON)
        (yield mock_send_to_queue)
