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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user