class WhenPublishingJSONMessage(_BaseTestCase): __contexts__ = (('super', patch(mod + '.super', create=True)), ) def configure(self): self.ctx.super.return_value = self.superclass = MagicMock() self.publisher = BlockingJSONPublisher(sentinel.broker) self.publisher._serialize = MagicMock(return_value=sentinel.body) self.publisher._channel = MagicMock(is_open=True) self.properties = MagicMock(content_type=None) def execute(self): self.publisher.publish(sentinel.exchange, sentinel.routing_key, sentinel.payload, self.properties) def should_serialize_payload(self): self.publisher._serialize.assert_called_once_with(sentinel.payload) def should_call_super(self): self.ctx.super.assert_called_once_with(JSONPublisherMixin, self.publisher) def should_call_publish_on_superclass(self): self.superclass.publish.assert_called_once_with( sentinel.exchange, sentinel.routing_key, sentinel.body, self.properties) def should_set_content_type(self): self.assertEqual(self.properties.content_type, 'application/json')
class WhenPublishingJSONMessage(_BaseTestCase): __contexts__ = ( ('super', patch(mod + '.super', create=True)), ) def configure(self): self.ctx.super.return_value = self.superclass = MagicMock() self.publisher = BlockingJSONPublisher(sentinel.broker) self.publisher._serialize = MagicMock(return_value=sentinel.body) self.publisher._channel = MagicMock(is_open=True) self.properties = MagicMock(content_type=None) def execute(self): self.publisher.publish(sentinel.exchange, sentinel.routing_key, sentinel.payload, self.properties) def should_serialize_payload(self): self.publisher._serialize.assert_called_once_with(sentinel.payload) def should_call_super(self): self.ctx.super.assert_called_once_with(JSONPublisherMixin, self.publisher) def should_call_publish_on_superclass(self): self.superclass.publish.assert_called_once_with(sentinel.exchange, sentinel.routing_key, sentinel.body, self.properties) def should_set_content_type(self): self.assertEqual(self.properties.content_type, 'application/json')
def execute(self): BlockingJSONPublisher(self.broker).publish(self.exchange, self.routing_key, self.payload)
def configure(self): self.ctx.super.return_value = self.superclass = MagicMock() self.publisher = BlockingJSONPublisher(sentinel.broker) self.publisher._serialize = MagicMock(return_value=sentinel.body) self.publisher._channel = MagicMock(is_open=True) self.properties = MagicMock(content_type=None)
def should_extend_BlockingPublisher(self): isinstance(BlockingJSONPublisher(sentinel.broker), BlockingPublisher)