예제 #1
0
    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')
예제 #2
0
파일: realtime_test.py 프로젝트: gnott/h
    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)
예제 #3
0
파일: realtime_test.py 프로젝트: gnott/h
    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)
예제 #4
0
    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,
        )
예제 #5
0
파일: realtime_test.py 프로젝트: gnott/h
 def test_delivery_mode(self):
     """Test that delivery mode is 1 (transient)"""
     exchange = realtime.get_exchange()
     assert exchange.delivery_mode == 1
예제 #6
0
파일: realtime_test.py 프로젝트: gnott/h
 def test_durable(self):
     exchange = realtime.get_exchange()
     assert exchange.durable is False
예제 #7
0
파일: realtime_test.py 프로젝트: gnott/h
 def test_type(self):
     exchange = realtime.get_exchange()
     assert exchange.type == 'direct'
예제 #8
0
파일: realtime_test.py 프로젝트: gnott/h
 def test_returns_the_exchange(self):
     import kombu
     exchange = realtime.get_exchange()
     assert isinstance(exchange, kombu.Exchange)
예제 #9
0
 def exchange(self):
     return realtime.get_exchange()
예제 #10
0
 def test_delivery_mode(self):
     """Test that delivery mode is 1 (transient)"""
     exchange = realtime.get_exchange()
     assert exchange.delivery_mode == 1
예제 #11
0
 def test_durable(self):
     exchange = realtime.get_exchange()
     assert exchange.durable is False
예제 #12
0
 def test_type(self):
     exchange = realtime.get_exchange()
     assert exchange.type == 'direct'
예제 #13
0
 def test_returns_the_exchange(self):
     import kombu
     exchange = realtime.get_exchange()
     assert isinstance(exchange, kombu.Exchange)