Esempio n. 1
0
def test_queue_is_empty(redis):
    """Detecting empty queues."""

    q = Queue('example')
    assert (yield from q.is_empty())
    yield from redis.rpush('rq:queue:example', 'sentinel message')
    assert not (yield from q.is_empty())
Esempio n. 2
0
def test_empty_queue(redis):
    """Emptying queues."""

    q = Queue('example', connection=redis)
    yield from redis.rpush('rq:queue:example', 'foo')
    yield from redis.rpush('rq:queue:example', 'bar')
    assert not (yield from q.is_empty())
    yield from q.empty()
    assert (yield from q.is_empty())
    assert (yield from redis.lpop('rq:queue:example')) is None
Esempio n. 3
0
def test_enqueue(redis):
    """Enqueueing job onto queues."""

    q = Queue()
    assert (yield from q.is_empty())

    # say_hello spec holds which queue this is sent to
    job = yield from q.enqueue(say_hello, 'Nick', foo='bar')
    job_id = job.id
    assert job.origin == q.name

    # Inspect data inside Redis
    q_key = 'rq:queue:default'
    assert 1 == (yield from redis.llen(q_key))
    assert job_id == (yield from redis.lrange(q_key, 0, -1))[0].decode('ascii')