def test_publishing_failure_raised(self):
     with self.mock_publish(side_effect=exceptions.AMQPChannelError()):
         response = self.fetch('/', headers=self.headers)
         result = json.loads(response.body.decode('utf-8'))
         error_expectation = amqp.PublishingFailure.fmt.format(
             result['parameters']['properties']['message_id'],
             result['parameters']['exchange'],
             result['parameters']['routing_key'],
             exceptions.AMQPChannelError.__name__)
         self.assertEqual(result['error'], error_expectation)
         self.assertEqual(result['type'], 'PublishingFailure')
Example #2
0
 def test_publish_generic_channel_error(self):
     # The publisher must try to re-establish a connection on publish.
     self.publisher_channel_publish.side_effect = pika_errs.AMQPChannelError(
         200, "I wanted to"
     )
     connection_class_mock = mock.Mock()
     connection_mock = mock.Mock()
     channel_mock = mock.Mock()
     connection_class_mock.return_value = connection_mock
     connection_mock.channel.return_value = channel_mock
     with mock.patch(
         "fedora_messaging._session.pika.BlockingConnection", connection_class_mock
     ):
         self.publisher.publish(self.message)
     # Check that the connection was reestablished
     publish_mock_method = channel_mock.basic_publish
     publish_mock_method.assert_called_once()
Example #3
0
 def on_remote_close(self, method_frame):
     super(BlockingChannel, self).on_remote_close(method_frame)
     if self.transport.connection.is_open:
         raise exceptions.AMQPChannelError(method_frame.method.reply_code,
                                           method_frame.method.reply_text)