Skip to content

Commit 4941dc5

Browse files
committed
Fix inconsistent error message for getting a non-existent item #74
1 parent e62ac02 commit 4941dc5

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

inventory_management_system_api/routers/v1/item.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import logging
66
from typing import Annotated, List, Optional
77

8-
from fastapi import APIRouter, Depends, HTTPException, Path, Request, Query, status
8+
from fastapi import APIRouter, Depends, HTTPException, Path, Query, Request, status
99

1010
from inventory_management_system_api.core.config import config
1111
from inventory_management_system_api.core.exceptions import (
@@ -15,8 +15,8 @@
1515
InvalidPropertyTypeError,
1616
MissingMandatoryProperty,
1717
MissingRecordError,
18-
ObjectStorageAPIServerError,
1918
ObjectStorageAPIAuthError,
19+
ObjectStorageAPIServerError,
2020
)
2121
from inventory_management_system_api.schemas.item import ItemPatchSchema, ItemPostSchema, ItemSchema
2222
from inventory_management_system_api.services.item import ItemService
@@ -126,7 +126,7 @@ def get_item(
126126
) -> ItemSchema:
127127
# pylint: disable=missing-function-docstring
128128
logger.info("Getting item with ID %s", item_id)
129-
message = "An item with such ID was not found"
129+
message = "Item not found"
130130
try:
131131
item = item_service.get(item_id)
132132
if not item:

test/e2e/test_item.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -630,13 +630,13 @@ def test_get_with_non_existent_id(self):
630630
"""Test getting an item with a non-existent ID."""
631631

632632
self.get_item(str(ObjectId()))
633-
self.check_get_item_failed_with_detail(404, "An item with such ID was not found")
633+
self.check_get_item_failed_with_detail(404, "Item not found")
634634

635635
def test_get_with_invalid_id(self):
636636
"""Test getting an item with an invalid ID."""
637637

638638
self.get_item("invalid-id")
639-
self.check_get_item_failed_with_detail(404, "An item with such ID was not found")
639+
self.check_get_item_failed_with_detail(404, "Item not found")
640640

641641

642642
class ListDSL(GetDSL):
@@ -1176,7 +1176,7 @@ def test_delete(self):
11761176
self.check_delete_item_success()
11771177

11781178
self.get_item(item_id)
1179-
self.check_get_item_failed_with_detail(404, "An item with such ID was not found")
1179+
self.check_get_item_failed_with_detail(404, "Item not found")
11801180

11811181
def test_delete_with_non_existent_id(self):
11821182
"""Test deleting a non-existent item."""

0 commit comments

Comments
 (0)