Beispiel #1
0
 def factory(name, exchange, routing_key):
     channel = rabbitmq.channel()
     exchange = Exchange(channel, exchange, auto_delete=False, durable=True)
     exchange.declare()
     assert exchange.name in rabbitmq_proc.list_exchanges()
     queue = Queue(channel, name, auto_delete=False, durable=True)
     queue.declare()
     queue.bind(exchange, routing_key=routing_key)
     assert name in rabbitmq_proc.list_queues()
     return exchange, queue
Beispiel #2
0
def test_publish(rabbitmq, coney):
    channel = rabbitmq.channel()
    exchange = Exchange(channel, "my-exchange", "direct")
    exchange.declare()
    queue = Queue(channel, "my-queue")
    queue.declare()
    queue.bind(exchange, "my-routing-key")

    coney.publish("Hi",
                  exchange_name="my-exchange",
                  routing_key="my-routing-key")

    for message in queue.consume():
        assert message.body == b"Hi"
        queue.stop_consuming()
def test_rabbitmq_clear_exchanges(rabbitmq, rabbitmq_proc):
    """Declare exchange, and clear it by clear_rabbitmq."""
    channel = rabbitmq.channel()
    assert channel.state == channel.OPEN

    # list exchanges
    no_exchanges = rabbitmq_proc.list_exchanges()

    # declare exchange and list exchanges afterwards
    exchange = Exchange(channel, 'cache-in')
    exchange.declare()
    exchanges = rabbitmq_proc.list_exchanges()

    # make sure it differs
    assert exchanges != no_exchanges
    clear_rabbitmq(rabbitmq_proc, rabbitmq)

    # list_exchanges again and make sure it's empty
    cleared_exchanges = rabbitmq_proc.list_exchanges()
    assert no_exchanges == cleared_exchanges
def test_rabbitmq_clear_exchanges(rabbitmq, rabbitmq_proc):
    """
    Declare exchange, and clear it by clear_rabbitmq.
    """
    from rabbitpy import Exchange
    channel = rabbitmq.channel()
    assert channel.state == channel.OPEN

    # list exchanges
    no_exchanges = rabbitmq_proc.list_exchanges()

    # declare exchange and list exchanges afterwards
    exchange = Exchange(channel, 'cache-in')
    exchange.declare()
    exchanges = rabbitmq_proc.list_exchanges()

    # make sure it differs
    assert exchanges != no_exchanges
    clear_rabbitmq(rabbitmq_proc, rabbitmq)

    # list_exchanges again and make sure it's empty
    cleared_exchanges = rabbitmq_proc.list_exchanges()
    assert no_exchanges == cleared_exchanges