@pytest.mark.asyncio
async def test_patch_todo(session, client, user, token):
todo = TodoFactory(user_id=user.id)
session.add(todo)
await session.commit()
response = client.patch(
f'/todos/{todo.id}',
json={'title': 'teste!'},
headers={'Authorization': f'Bearer {token}'},
)
assert response.status_code == HTTPStatus.OK
assert response.json()['title'] == 'teste!'
def test_patch_todo_error(client, token):
response = client.patch(
'/todos/10',
json={},
headers={'Authorization': f'Bearer {token}'},
)
assert response.status_code == HTTPStatus.NOT_FOUND
assert response.json() == {'detail': 'Task not found.'}