Esempio n. 1
0
def test_crud_update_404(session, loop):
    with pytest.raises(HTTPException) as exc_info:
        loop.run_until_complete(
            crud.update_instance(Person, session, uuid.uuid4(),
                                 PersonRequestModel(**PEOPLE_DATA[0])))

    assert exc_info.value.status_code == 404
Esempio n. 2
0
def test_crud_update_partial(session, loop):
    person = Person(**PEOPLE_DATA[0])
    session.add(person)
    session.commit()
    person = session.merge(person)

    assert person.name == "alice"

    data = {"name": "edith"}

    result = loop.run_until_complete(
        crud.update_instance(Person, session, person.id, data))
    assert result["name"] == "edith"

    session.refresh(person)
    assert person.name == "edith"
Esempio n. 3
0
def test_crud_update(session, loop):
    person = Person(**PEOPLE_DATA[0])
    session.add(person)
    session.commit()
    person = session.merge(person)

    assert person.name == "alice"

    data = person.as_dict()
    data["name"] = "edith"

    result = loop.run_until_complete(
        crud.update_instance(Person, session, person.id,
                             PersonRequestModel(**data)))
    assert result["name"] == "edith"

    session.refresh(person)
    assert person.name == "edith"