Skip to content

Commit

Permalink
Refactor list, update and delete ItemRepo unit tests #345
Browse files Browse the repository at this point in the history
  • Loading branch information
joelvdavies committed Aug 7, 2024
1 parent 8142d98 commit 507328b
Show file tree
Hide file tree
Showing 4 changed files with 233 additions and 393 deletions.
10 changes: 10 additions & 0 deletions test/mock_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,16 @@
"usage_status": "In Use",
}


# TODO: Replace in later PR when have a suitable name for one
ITEM_IN_DATA_A = {
"catalogue_item_id": str(ObjectId()),
"system_id": str(ObjectId()),
"is_defective": False,
"usage_status_id": str(ObjectId()),
"usage_status": "In Use",
}

# --------------------------------- MANUFACTURERS ---------------------------------

# Required values only
Expand Down
2 changes: 1 addition & 1 deletion test/unit/repositories/test_catalogue_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ def check_update_success(self) -> None:
"_id": CustomObjectId(self._updated_catalogue_category_id),
},
{
"$set": self._catalogue_category_in.model_dump(),
"$set": self._catalogue_category_in.model_dump(by_alias=True),
},
session=self.mock_session,
)
Expand Down
5 changes: 2 additions & 3 deletions test/unit/repositories/test_catalogue_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ def set_update_data(self, new_catalogue_item_in_data: dict):
"""
self._catalogue_item_in = CatalogueItemIn(**new_catalogue_item_in_data)

# pylint:disable=too-many-arguments
def mock_update(
self,
catalogue_item_id: str,
Expand All @@ -377,7 +376,7 @@ def mock_update(
def call_update(self, catalogue_item_id: str) -> None:
"""
Calls the `CatalogueItemRepo` `update` method with the appropriate data from a prior call to `mock_update`
(or`set_update_data`).
(or `set_update_data`).
:param catalogue_item_id: ID of the catalogue item to be updated.
"""
Expand Down Expand Up @@ -408,7 +407,7 @@ def check_update_success(self) -> None:
"_id": CustomObjectId(self._updated_catalogue_item_id),
},
{
"$set": self._catalogue_item_in.model_dump(),
"$set": self._catalogue_item_in.model_dump(by_alias=True),
},
session=self.mock_session,
)
Expand Down
Loading

0 comments on commit 507328b

Please sign in to comment.