Example #1
0
 def test_process_msg_logchutes(self, mock_process):
     """
     Tests the process_msg function for LogChutes.
     """
     self.kwargs['method'].routing_key = 'logchutes'
     with patch('receiver.receiver.create_doc_obj',
                return_value=self.mock_doc_obj) as mock_create:
         process_msg(**self.kwargs)
         mock_create.assert_called_once_with(self.decoded_msg)
         mock_process.assert_called_once_with(self.mock_doc_obj)
Example #2
0
 def test_process_msg_exception(self):
     """
     Tests the process_msg function when an exception is raised.
     """
     logging.disable(logging.NOTSET)
     with patch('receiver.receiver.logging.getLogger', return_value=LOGGER):
         with patch('receiver.receiver.json.loads',
                    side_effect=Exception('foo')):
             with LogCapture() as log_capture:
                 process_msg(**self.kwargs)
                 log_capture.check((
                     'receiver', 'ERROR',
                     'An error occurred while processing the message \'{"@uuid": "12345", '
                     '"collection": "elasticsearch.test_index.test_logs", "message": '
                     '"foobar"}\':\n'
                     '  foo'), )