mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2025-08-26 16:40:40 +03:00
add simple exception handlers tests
This commit is contained in:
parent
7d122f7062
commit
71d90aa1e3
0
app/exception handlers/__init__.py
Normal file
0
app/exception handlers/__init__.py
Normal file
@ -25,9 +25,15 @@ async def test_add_stuff(client: AsyncClient):
|
||||
"description": stuff["description"],
|
||||
}
|
||||
)
|
||||
response = await client.post("/stuff", json=stuff)
|
||||
assert response.status_code == status.HTTP_500_INTERNAL_SERVER_ERROR
|
||||
assert response.json() == snapshot({'message':'A database error occurred. Please try again later.'})
|
||||
|
||||
|
||||
async def test_get_stuff(client: AsyncClient):
|
||||
response = await client.get(f"/stuff/nonexistent")
|
||||
assert response.status_code == status.HTTP_404_NOT_FOUND
|
||||
assert response.json() == snapshot({'no_response':'The requested resource was not found'})
|
||||
stuff = StuffFactory.build(factory_use_constructors=True).model_dump(mode="json")
|
||||
await client.post("/stuff", json=stuff)
|
||||
name = stuff["name"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user