Beispiel #1
0
def test_remove_and_delete(assert_atomic, connection):
    q = Queue()
    q.enqueue_call()
    task = q.enqueue_call()
    assert q.count() == 2
    assert connection.exists(task.key)
    with assert_atomic():
        q.remove_and_delete(task)
    assert not connection.exists(task.key)
    assert q.count() == 1
    with pytest.raises(TaskDoesNotExist):
        q.remove_and_delete(task)
    assert q.count() == 1
Beispiel #2
0
def test_queue_basics(assert_atomic):
    worker = WorkerFactory()
    q = Queue()
    assert q.name == 'default'
    assert str(q) == '<Queue default>'
    assert repr(q) == "Queue('default')"

    assert q.count() == 0
    with assert_atomic():
        task = q.enqueue_call()
    q.enqueue_call()
    assert q.count() == 2

    assert q.dequeue(worker).id == task.id
    assert q.count() == 1