Fixe (partially) gift tests and api
This commit is contained in:
@@ -25,7 +25,7 @@ pytest_plugins = ["pytest_asyncio"]
|
||||
def db_session():
|
||||
"""
|
||||
Creates a fresh SQLite in-memory database for each test function.
|
||||
|
||||
|
||||
Yields a SQLAlchemy session that can be used for testing.
|
||||
"""
|
||||
# Set up the database
|
||||
@@ -340,17 +340,27 @@ def gift_category_fixture(db_session, mock_user, mock_event):
|
||||
"""
|
||||
Fixture to create and return a GiftCategory instance.
|
||||
"""
|
||||
# Create the category without event_id and display_order
|
||||
gift_category = GiftCategory(
|
||||
id=uuid.uuid4(),
|
||||
name="Electronics",
|
||||
description="Category for electronic gifts",
|
||||
event_id=mock_event.id,
|
||||
created_by=mock_user.id,
|
||||
display_order=0,
|
||||
is_visible=True
|
||||
created_by=mock_user.id
|
||||
)
|
||||
db_session.add(gift_category)
|
||||
db_session.commit()
|
||||
|
||||
# Create the association between the category and the event
|
||||
from app.models.gift import EventGiftCategory
|
||||
event_gift_category = EventGiftCategory(
|
||||
event_id=mock_event.id,
|
||||
category_id=gift_category.id,
|
||||
display_order=0,
|
||||
is_visible=True
|
||||
)
|
||||
db_session.add(event_gift_category)
|
||||
db_session.commit()
|
||||
|
||||
return gift_category
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user