def test_publish_user(self, producer_pool): payload = {'action': 'create', 'user': {'id': 'foobar'}} producer = producer_pool['foobar'].acquire().__enter__() exchange = realtime.get_exchange() request = DummyRequest() publisher = realtime.Publisher(request) publisher.publish_user(payload) producer.publish.assert_called_once_with( payload, exchange=exchange, declare=[exchange], routing_key='user')
def test_get_consumers_creates_a_queue(self, Queue, consumer, generate_queue_name): consumer_factory = mock.Mock(spec_set=[]) exchange = realtime.get_exchange() consumer.get_consumers(consumer_factory, mock.Mock()) Queue.assert_called_once_with(generate_queue_name.return_value, exchange=exchange, durable=False, routing_key='annotation', auto_delete=True)
def test_publish_user(self, matchers, producer_pool, pyramid_request): payload = {'action': 'create', 'user': {'id': 'foobar'}} producer = producer_pool['foobar'].acquire().__enter__() exchange = realtime.get_exchange() publisher = realtime.Publisher(pyramid_request) publisher.publish_user(payload) expected_headers = matchers.mapping_containing('timestamp') producer.publish.assert_called_once_with(payload, exchange=exchange, declare=[exchange], routing_key='user', headers=expected_headers)
def test_publish_user(self, matchers, producer_pool, pyramid_request, retry_policy): payload = {"action": "create", "user": {"id": "foobar"}} producer = producer_pool["foobar"].acquire().__enter__() exchange = realtime.get_exchange() publisher = realtime.Publisher(pyramid_request) publisher.publish_user(payload) expected_headers = matchers.MappingContaining("timestamp") producer.publish.assert_called_once_with( payload, exchange=exchange, declare=[exchange], routing_key="user", headers=expected_headers, retry=True, retry_policy=retry_policy, )
def test_delivery_mode(self): """Test that delivery mode is 1 (transient)""" exchange = realtime.get_exchange() assert exchange.delivery_mode == 1
def test_durable(self): exchange = realtime.get_exchange() assert exchange.durable is False
def test_type(self): exchange = realtime.get_exchange() assert exchange.type == 'direct'
def test_returns_the_exchange(self): import kombu exchange = realtime.get_exchange() assert isinstance(exchange, kombu.Exchange)
def exchange(self): return realtime.get_exchange()