Enhanced theme creation and update logic to include proper file organization by relocating and managing URLs for images and assets. Introduced roles validation to restrict access to superusers for these operations. Updated tests to align with the refactored logic and dependencies.
37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
# tests/api/routes/test_event_themes.py
|
|
import uuid
|
|
from fastapi import status
|
|
|
|
import pytest
|
|
|
|
from app.api.routes.event_themes import router as themes_router
|
|
|
|
|
|
class TestCreateEventTheme:
|
|
"""Test scenarios for the create_theme endpoint."""
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def setup_method(self, create_test_client, db_session, mock_superuser):
|
|
self.client = create_test_client(
|
|
router=themes_router,
|
|
prefix="/themes",
|
|
db_session=db_session,
|
|
user=mock_superuser
|
|
)
|
|
self.db_session = db_session
|
|
self.mock_superuser = mock_superuser
|
|
|
|
def test_create_theme_success(self, theme_data):
|
|
"""Test successful theme creation."""
|
|
# Make the request
|
|
response = self.client.post("/themes/", json=theme_data)
|
|
|
|
# Assert response
|
|
assert response.status_code == 200
|
|
data = response.json()
|
|
assert data["name"] == theme_data["name"]
|
|
assert data["description"] == theme_data["description"]
|
|
assert data["preview_image_url"] == theme_data["preview_image_url"]
|
|
assert data["color_palette"] == theme_data["color_palette"]
|
|
assert data["fonts"] == theme_data["fonts"]
|
|
assert "id" in data |