Пример #1
0
 def _wrap_consumer(self, consumer):
     # TODO(ivc): tune retry interval/timeout
     return h_log.LogExceptions(
         h_retry.Retry(consumer,
                       exceptions=(exceptions.ResourceNotReady,
                                   key_exc.connection.ConnectFailure,
                                   requests_exc.ConnectionError)))
Пример #2
0
    def test_no_exception(self, m_log):
        m_handler = mock.Mock()
        handler = h_log.LogExceptions(m_handler)

        handler(mock.sentinel.event)

        m_handler.assert_called_once_with(mock.sentinel.event)
        m_log.exception.assert_not_called()
Пример #3
0
    def test_raises(self, m_log):
        m_handler = mock.Mock()
        m_handler.side_effect = KeyError()
        handler = h_log.LogExceptions(m_handler, exceptions=ValueError)

        self.assertRaises(KeyError, handler, mock.sentinel.event)

        m_handler.assert_called_once_with(mock.sentinel.event)
        m_log.exception.assert_not_called()
Пример #4
0
    def test_exception_default(self, m_log):
        m_handler = mock.Mock()
        m_handler.side_effect = ValueError()
        handler = h_log.LogExceptions(m_handler)

        handler(mock.sentinel.event)

        m_handler.assert_called_once_with(mock.sentinel.event)
        m_log.exception.assert_called_once()
Пример #5
0
 def _wrap_dispatcher(self, dispatcher):
     return h_log.LogExceptions(h_async.Async(dispatcher, self._tg,
                                              h_k8s.object_uid))
Пример #6
0
 def _wrap_consumer(self, consumer):
     # TODO(ivc): tune retry interval/timeout
     return h_log.LogExceptions(
         h_retry.Retry(consumer, exceptions=exceptions.ResourceNotReady))