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)
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)
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)
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)
def execute(self): BlockingPublisher(self.broker).publish(self.exchange, self.routing_key, self.payload)
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 = BlockingPublisher(self.broker)