Add unit tests for GiftItem, GiftCategory, and GiftPurchase models

Introduced comprehensive test coverage for GiftItem, GiftCategory, and GiftPurchase models to validate core functionality such as creation, updates, deletions, and derived properties. Also updated the `total_gifts` method in `GiftCategory` to calculate the total requested quantity rather than the count of gifts.
This commit is contained in:
2025-02-28 14:41:43 +01:00
parent 712f1ddcb2
commit 38d5ac7c63
2 changed files with 201 additions and 2 deletions

View File

@@ -158,8 +158,9 @@ class GiftCategory(Base, UUIDMixin, TimestampMixin):
@property
def total_gifts(self) -> int:
"""Get total number of gifts in category"""
return len(self.gifts)
"""Get the total quantity of gifts requested in the category."""
return sum(gift.quantity_requested for gift in self.gifts)
@property
def available_gifts(self) -> int: