Пример #1
0
class _BasePublishOnClosedResource(_BaseTestCase):

    def configure(self):
        self.publisher = BlockingPublisher(MagicMock())
        BlockingPublisher.channel = self.channel = PropertyMock(is_open=True)
        self.channel().basic_publish = \
            MagicMock(side_effect=[self.exception_cls(), None])
        self.publisher._build_basic_properties = \
            MagicMock(return_value=sentinel.basic_properties)

    def execute(self):
        self.publisher.publish(sentinel.exchange, sentinel.routing_key,
                               sentinel.body, sentinel.properties)

    def should_build_basic_properties(self):
        self.publisher._build_basic_properties.assert_called_once_with(
            sentinel.properties)

    def should_call_basic_publish_twice(self):
        basic_publish_call = call(
            exchange=sentinel.exchange,
            routing_key=sentinel.routing_key,
            body=sentinel.body,
            properties=sentinel.basic_properties)
        self.assertEqual(self.channel().basic_publish.mock_calls,
                         [basic_publish_call] * 2)
Пример #2
0
 def configure(self):
     self.publisher = BlockingPublisher(MagicMock())
     BlockingPublisher.channel = self.channel = PropertyMock(is_open=True)
     self.channel().basic_publish = \
         MagicMock(side_effect=[self.exception_cls(), None])
     self.publisher._build_basic_properties = \
         MagicMock(return_value=sentinel.basic_properties)
Пример #3
0
 def configure(self):
     self.publisher = BlockingPublisher(MagicMock())
     BlockingPublisher.channel = self.channel = PropertyMock(is_open=True)
     self.channel().basic_publish = \
         MagicMock(side_effect=[self.exception_cls(), None])
     self.publisher._build_basic_properties = \
         MagicMock(return_value=sentinel.basic_properties)
Пример #4
0
class WhenPublishingMessage(_BaseTestCase):

    def configure(self):
        self.publisher = BlockingPublisher(sentinel.broker)
        self.publisher._channel = self.channel = MagicMock(is_open=True)
        self.publisher._build_basic_properties = \
            MagicMock(return_value=sentinel.basic_properties)

    def execute(self):
        self.publisher.publish(sentinel.exchange, sentinel.routing_key,
                               sentinel.body, sentinel.properties)

    def should_build_basic_properties(self):
        self.publisher._build_basic_properties.assert_called_once_with(
            sentinel.properties)

    def should_call_basic_publish(self):
        self.channel.basic_publish.assert_called_once_with(
            exchange=sentinel.exchange, routing_key=sentinel.routing_key,
            body=sentinel.body, properties=sentinel.basic_properties)
Пример #5
0
class WhenPublishingMessage(_BaseTestCase):
    def configure(self):
        self.publisher = BlockingPublisher(sentinel.broker)
        self.publisher._channel = self.channel = MagicMock(is_open=True)
        self.publisher._build_basic_properties = \
            MagicMock(return_value=sentinel.basic_properties)

    def execute(self):
        self.publisher.publish(sentinel.exchange, sentinel.routing_key,
                               sentinel.body, sentinel.properties)

    def should_build_basic_properties(self):
        self.publisher._build_basic_properties.assert_called_once_with(
            sentinel.properties)

    def should_call_basic_publish(self):
        self.channel.basic_publish.assert_called_once_with(
            exchange=sentinel.exchange,
            routing_key=sentinel.routing_key,
            body=sentinel.body,
            properties=sentinel.basic_properties)
Пример #6
0
class _BasePublishOnClosedResource(_BaseTestCase):
    def configure(self):
        self.publisher = BlockingPublisher(MagicMock())
        BlockingPublisher.channel = self.channel = PropertyMock(is_open=True)
        self.channel().basic_publish = \
            MagicMock(side_effect=[self.exception_cls(), None])
        self.publisher._build_basic_properties = \
            MagicMock(return_value=sentinel.basic_properties)

    def execute(self):
        self.publisher.publish(sentinel.exchange, sentinel.routing_key,
                               sentinel.body, sentinel.properties)

    def should_build_basic_properties(self):
        self.publisher._build_basic_properties.assert_called_once_with(
            sentinel.properties)

    def should_call_basic_publish_twice(self):
        basic_publish_call = call(exchange=sentinel.exchange,
                                  routing_key=sentinel.routing_key,
                                  body=sentinel.body,
                                  properties=sentinel.basic_properties)
        self.assertEqual(self.channel().basic_publish.mock_calls,
                         [basic_publish_call] * 2)
Пример #7
0
 def execute(self):
     BlockingPublisher(self.broker).publish(self.exchange, self.routing_key,
                                            self.payload)
Пример #8
0
 def configure(self):
     self.publisher = BlockingPublisher(sentinel.broker)
     self.publisher._channel = self.channel = MagicMock(is_open=True)
     self.publisher._build_basic_properties = \
         MagicMock(return_value=sentinel.basic_properties)
Пример #9
0
 def execute(self):
     self.publisher = BlockingPublisher(self.broker)
Пример #10
0
 def configure(self):
     self.publisher = BlockingPublisher(sentinel.broker)
     self.publisher._channel = self.channel = MagicMock(is_open=True)
     self.publisher._build_basic_properties = \
         MagicMock(return_value=sentinel.basic_properties)