Exemple #1
0
    def test_send(self, build):
        ttl = 10
        address = 'jeff'
        content = 'hello'

        # test
        sender = Sender('')
        sender.durable = 18
        sender.channel = Mock()
        sender.send(address, content, ttl=ttl)

        # validation
        build.assert_called_once_with(content, ttl, sender.durable)
        sender.channel.basic_publish.assert_called_once_with(
            build.return_value,
            mandatory=True,
            exchange='',
            routing_key='jeff')
Exemple #2
0
    def test_send(self, build):
        ttl = 10
        address = 'jeff'
        content = 'hello'

        # test
        sender = Sender('')
        sender.durable = 18
        sender.channel = Mock()
        sender.send(address, content, ttl=ttl)

        # validation
        build.assert_called_once_with(content, ttl, sender.durable)
        sender.channel.basic_publish.assert_called_once_with(
            build.return_value,
            mandatory=True,
            exchange='',
            routing_key='jeff')
Exemple #3
0
    def test_send_exchange(self, build):
        ttl = 10
        exchange = 'amq.direct'
        key = 'bar'
        address = '/'.join((exchange, key))
        content = 'hello'

        # test
        sender = Sender('')
        sender.durable = False
        sender.channel = Mock()
        sender.send(address, content, ttl=ttl)

        # validation
        build.assert_called_once_with(content, ttl, sender.durable)
        sender.channel.basic_publish.assert_called_once_with(
            build.return_value,
            mandatory=True,
            exchange=exchange,
            routing_key=key)
Exemple #4
0
    def test_send_exchange(self, build):
        ttl = 10
        exchange = 'amq.direct'
        key = 'bar'
        address = '/'.join((exchange, key))
        content = 'hello'

        # test
        sender = Sender('')
        sender.durable = False
        sender.channel = Mock()
        sender.send(address, content, ttl=ttl)

        # validation
        build.assert_called_once_with(content, ttl, sender.durable)
        sender.channel.basic_publish.assert_called_once_with(
            build.return_value,
            mandatory=True,
            exchange=exchange,
            routing_key=key)