예제 #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"
예제 #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
예제 #3
0
def test_rename_task(session):
    create(name="foo")

    update(1, name="bar")

    task = session.query(Task).get(1)
    assert task.name == "bar"
예제 #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"
예제 #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
예제 #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")
예제 #7
0
def test_rename_duplicate_name_raises(session):
    create(name="foo")
    create(name="bar")

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