Beispiel #1
0
def test_delete_many(connection, assert_atomic):
    tasks = [Task() for i in range(5)]
    for t in tasks:
        t._save()

    with assert_atomic():
        Task.delete_many([tasks[0].id, tasks[1].id])

    for t in tasks[0:2]:
        assert not connection.exists(t.key)
    for t in tasks[2:5]:
        assert connection.exists(t.key)
Beispiel #2
0
def test_init_save_fetch_delete(connection, assert_atomic, stub):
    t = Task(stub, ["foo"])
    assert not connection.exists(t.key)
    with assert_atomic():
        t._save()
    assert connection.exists(t.key)

    fetched = Task.fetch(t.id)
    assert fetched.id == t.id
    assert fetched.args == ["foo"]

    Task.delete_many([t.id])
    assert not connection.exists(t.key)
    with pytest.raises(TaskDoesNotExist):
        Task.fetch(t.id)