Ejemplo n.º 1
0
def test_describe_task(session):
    create(name="foo", description="old")
    update(1, description="bar")

    task = session.query(Task).get(1)
    assert task.name == "foo"
    assert task.description == "bar"
Ejemplo n.º 2
0
def test_describe_task_blank_erases(session):
    create(name="foo", description="foobar")
    update(1, description="")

    task = session.query(Task).get(1)
    assert task.name == "foo"
    assert task.description is None
Ejemplo n.º 3
0
def test_rename_task(session):
    create(name="foo")

    update(1, name="bar")

    task = session.query(Task).get(1)
    assert task.name == "bar"
Ejemplo n.º 4
0
def test_create_with_description(session):
    create(name="foo", description="Foobar")

    results = session.query(Task).filter(Task.name == "foo").all()
    assert len(results) == 1
    assert results[0].name == "foo"
    assert results[0].description == "Foobar"
Ejemplo n.º 5
0
def test_create(session):
    create(name="foo")

    results = session.query(Task).filter(Task.name == "foo").all()
    assert len(results) == 1
    assert results[0].name == "foo"
    assert results[0].description is None
Ejemplo n.º 6
0
def test_create_duplicate_name_raises(session):
    create(name="foo")

    result = session.query(Task).filter(Task.name == "foo").one()
    assert result.name == "foo"
    assert result.id == 1

    with pytest.raises(ValidationError):
        create(name="foo")
Ejemplo n.º 7
0
def test_rename_duplicate_name_raises(session):
    create(name="foo")
    create(name="bar")

    with pytest.raises(ValidationError):
        update(2, name="foo")
Ejemplo n.º 8
0
def test_get_task(session):
    create(name="foo")
    task = get(name="foo")
    assert task.id == 1
    assert task.name == "foo"
Ejemplo n.º 9
0
def test_create_invalid_name_raises(session, name):
    with pytest.raises(ValidationError):
        create(name=name)