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"
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
def test_rename_task(session): create(name="foo") update(1, name="bar") task = session.query(Task).get(1) assert task.name == "bar"
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"
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
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")
def test_rename_duplicate_name_raises(session): create(name="foo") create(name="bar") with pytest.raises(ValidationError): update(2, name="foo")
def test_get_task(session): create(name="foo") task = get(name="foo") assert task.id == 1 assert task.name == "foo"
def test_create_invalid_name_raises(session, name): with pytest.raises(ValidationError): create(name=name)