From 71d90aa1e3544bb1755fb71693bcbc8aa60e1683 Mon Sep 17 00:00:00 2001 From: grillazz Date: Sun, 24 Aug 2025 09:41:55 +0200 Subject: [PATCH] add simple exception handlers tests --- app/exception handlers/__init__.py | 0 tests/api/test_stuff.py | 6 ++++++ 2 files changed, 6 insertions(+) create mode 100644 app/exception handlers/__init__.py diff --git a/app/exception handlers/__init__.py b/app/exception handlers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/api/test_stuff.py b/tests/api/test_stuff.py index e1352c2..9445c7e 100644 --- a/tests/api/test_stuff.py +++ b/tests/api/test_stuff.py @@ -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"]