From 4a45a68703afb2ab45c0af05ee208e29cb581f04 Mon Sep 17 00:00:00 2001 From: UmmmAGoodName Date: Wed, 11 Mar 2026 18:48:36 +0100 Subject: [PATCH] Changed errors to new type, was causing warnings --- gns3server/api/server.py | 2 +- .../compute/test_ethernet_switch_nodes.py | 2 +- tests/api/routes/controller/test_templates.py | 2 +- tests/api/routes/controller/test_users.py | 18 +++++++++--------- tests/api/routes/controller/test_version.py | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/gns3server/api/server.py b/gns3server/api/server.py index 145394681..888822978 100644 --- a/gns3server/api/server.py +++ b/gns3server/api/server.py @@ -207,7 +207,7 @@ async def sqlalchemy_error_handler(request: Request, exc: SQLAlchemyError): async def validation_exception_handler(request: Request, exc: RequestValidationError): log.error(f"Request validation error in {request.url.path} ({request.method}): {exc}") return JSONResponse( - status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, + status_code=status.HTTP_422_UNPROCESSABLE_CONTENT, content={"message": str(exc)} ) diff --git a/tests/api/routes/compute/test_ethernet_switch_nodes.py b/tests/api/routes/compute/test_ethernet_switch_nodes.py index f0dc400b6..ab395522c 100644 --- a/tests/api/routes/compute/test_ethernet_switch_nodes.py +++ b/tests/api/routes/compute/test_ethernet_switch_nodes.py @@ -297,7 +297,7 @@ class TestEthernetSwitchNodesRoutes: node_id=ethernet_switch["node_id"]), json=port_params ) - assert response.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY + assert response.status_code == status.HTTP_422_UNPROCESSABLE_CONTENT async def test_ethernet_switch_delete( diff --git a/tests/api/routes/controller/test_templates.py b/tests/api/routes/controller/test_templates.py index 38f01fb59..4aa64b40d 100644 --- a/tests/api/routes/controller/test_templates.py +++ b/tests/api/routes/controller/test_templates.py @@ -133,7 +133,7 @@ class TestTemplateRoutes: "template_type": "invalid_template_type"} response = await client.post(app.url_path_for("create_template"), json=params) - assert response.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY + assert response.status_code == status.HTTP_422_UNPROCESSABLE_CONTENT async def test_template_update(self, app: FastAPI, client: AsyncClient) -> None: diff --git a/tests/api/routes/controller/test_users.py b/tests/api/routes/controller/test_users.py index e068e3ca2..4041f63bb 100644 --- a/tests/api/routes/controller/test_users.py +++ b/tests/api/routes/controller/test_users.py @@ -75,10 +75,10 @@ class TestUserRoutes: ( ("email", "user2@email.com", status.HTTP_400_BAD_REQUEST), ("username", "user2", status.HTTP_400_BAD_REQUEST), - ("email", "invalid_email@one@two.io", status.HTTP_422_UNPROCESSABLE_ENTITY), - ("password", "short", status.HTTP_422_UNPROCESSABLE_ENTITY), - ("username", "user2@#$%^<>", status.HTTP_422_UNPROCESSABLE_ENTITY), - ("username", "ab", status.HTTP_422_UNPROCESSABLE_ENTITY), + ("email", "invalid_email@one@two.io", status.HTTP_422_UNPROCESSABLE_CONTENT), + ("password", "short", status.HTTP_422_UNPROCESSABLE_CONTENT), + ("username", "user2@#$%^<>", status.HTTP_422_UNPROCESSABLE_CONTENT), + ("username", "ab", status.HTTP_422_UNPROCESSABLE_CONTENT), ) ) async def test_user_registration_fails_when_credentials_are_taken( @@ -101,10 +101,10 @@ class TestUserRoutes: ("email", "user@email.com", status.HTTP_200_OK), ("email", "user@email.com", status.HTTP_400_BAD_REQUEST), ("username", "user2", status.HTTP_400_BAD_REQUEST), - ("email", "invalid_email@one@two.io", status.HTTP_422_UNPROCESSABLE_ENTITY), - ("password", "short", status.HTTP_422_UNPROCESSABLE_ENTITY), - ("username", "user2@#$%^<>", status.HTTP_422_UNPROCESSABLE_ENTITY), - ("username", "ab", status.HTTP_422_UNPROCESSABLE_ENTITY), + ("email", "invalid_email@one@two.io", status.HTTP_422_UNPROCESSABLE_CONTENT), + ("password", "short", status.HTTP_422_UNPROCESSABLE_CONTENT), + ("username", "user2@#$%^<>", status.HTTP_422_UNPROCESSABLE_CONTENT), + ("username", "ab", status.HTTP_422_UNPROCESSABLE_CONTENT), ("full_name", "John Doe", status.HTTP_200_OK), ("password", "password123", status.HTTP_200_OK), ("is_active", True, status.HTTP_200_OK), @@ -259,7 +259,7 @@ class TestUserLogin: ( ("wrong_username", "user1_password", status.HTTP_401_UNAUTHORIZED), ("user1", "wrong_password", status.HTTP_401_UNAUTHORIZED), - ("user1", None, status.HTTP_422_UNPROCESSABLE_ENTITY), + ("user1", None, status.HTTP_422_UNPROCESSABLE_CONTENT), ), ) async def test_user_with_wrong_creds_doesnt_receive_token( diff --git a/tests/api/routes/controller/test_version.py b/tests/api/routes/controller/test_version.py index 1e229dddf..95824067a 100644 --- a/tests/api/routes/controller/test_version.py +++ b/tests/api/routes/controller/test_version.py @@ -62,4 +62,4 @@ class TestVersionRoutes: params = "BOUM" response = await client.post(app.url_path_for("check_version"), json=params) - assert response.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY + assert response.status_code == status.HTTP_422_UNPROCESSABLE_CONTENT