def test_process_queue_error_cb(self):
     """ Verify error callback executed on Future exception"""
     mock_future = Future()
     mock_future.is_done = True
     mock_future.exception = FailureException()
     cb_spy = Mock(wraps=self.error_cb)
     with self.assertRaises(FailureException) as context:
         self.kafka_producer.send = MagicMock(return_value=mock_future)
         process_queue(self.event_queue, "test", self.kafka_producer,
                       self.success_cb, cb_spy)
     # Also verify propagation of queue and message to error callback.
     # Message is specified by mocking of self.event_queue.get in setUp.
     cb_spy.assert_called_with(1, self.event_queue)
 def test_process_queue_error_cb(self):
     """ Verify error callback executed on Future exception"""
     mock_future = Future()
     mock_future.is_done = True
     mock_future.exception = FailureException()
     cb_spy = Mock(wraps=self.error_cb)
     with self.assertRaises(FailureException) as context:
         self.kafka_producer.send = MagicMock(return_value=mock_future)
         process_queue(self.event_queue,
                       "test",
                       self.kafka_producer,
                       self.success_cb,
                       cb_spy)
     # Also verify propagation of queue and message to error callback.
     # Message is specified by mocking of self.event_queue.get in setUp.
     cb_spy.assert_called_with(1, self.event_queue)