Add and extend test coverage for models and their methods
Enhanced test coverage includes `repr` methods, model functionality, and validation logic for key models like `GiftItem`, `GiftCategory`, `EventMedia`, `RSVP`, and `GiftPurchase`. Refactored and added fixtures to support comprehensive testing scenarios. Addresses validation for gift reordering and updates `EventMedia` representation format for consistency.
This commit is contained in:
@@ -103,4 +103,22 @@ def test_dietary_requirements(rsvp_fixture):
|
||||
|
||||
# Update and re-check
|
||||
rsvp_fixture.dietary_requirements = "No preference"
|
||||
assert rsvp_fixture.dietary_requirements == "No preference"
|
||||
assert rsvp_fixture.dietary_requirements == "No preference"
|
||||
|
||||
def test_rsvp_repr(db_session):
|
||||
# Arrange
|
||||
rsvp = RSVP(
|
||||
id=uuid.uuid4(),
|
||||
event_id=uuid.uuid4(),
|
||||
guest_id=uuid.uuid4(),
|
||||
status=RSVPStatus.ATTENDING,
|
||||
number_of_guests=3,
|
||||
)
|
||||
db_session.add(rsvp)
|
||||
db_session.commit()
|
||||
|
||||
# Act
|
||||
result = repr(rsvp)
|
||||
|
||||
# Assert
|
||||
assert result == f"<RSVP guest_id={rsvp.guest_id} status=attending>"
|
||||
|
||||
Reference in New Issue
Block a user