mirror of
https://github.com/wizarrrr/wizarr.git
synced 2026-06-11 23:34:47 -04:00
Migration Changes: - Renamed migration file from 20251004 to 20251005 - Updated down_revision from fd5a34530162 to 08a6c8fb44db - Ensures migration runs after upstream notification events migration - Fixes migration chain branching issue - Removed incorrect merge migration (1e83c67d9785) Migration chain is now: fd5a34530162 (disabled attribute) → 08a6c8fb44db (notification events) → 20251005_add_category_to_wizard_step (wizard category) Wizard Refactoring: - Enhanced uniqueness constraint for WizardStep from (server_type, position) to (server_type, category, position) - Ensures steps in different categories (pre_invite vs post_invite) can have the same position indexing without conflict - Updated wizard state management documentation to explicitly list and describe data-* attributes used in steps.html template Code Quality: - Applied djlint formatting to 8 template files to minimize rebase conflicts - Applied ruff format and ruff check --fix (no changes needed) - Removed redundant requirement comments from spec-driven development - Fixed case sensitivity in test assertion (POST vs post) - Updated test references from 20251004 to 20251005 to match corrected migration revision ID
54 lines
1.6 KiB
Python
54 lines
1.6 KiB
Python
import pytest
|
|
from sqlalchemy.exc import IntegrityError
|
|
|
|
from app.extensions import db
|
|
from app.models import WizardStep
|
|
|
|
|
|
@pytest.fixture
|
|
def session(app):
|
|
"""Return a clean database session inside an app context."""
|
|
with app.app_context():
|
|
# Clean up any existing WizardStep data before the test
|
|
db.session.query(WizardStep).delete()
|
|
db.session.commit()
|
|
|
|
yield db.session
|
|
|
|
# Clean up after the test
|
|
db.session.rollback()
|
|
|
|
|
|
def test_create_wizard_step(session):
|
|
"""Basic insertion & to_dict serialization work."""
|
|
step = WizardStep(
|
|
server_type="plex",
|
|
category="post_invite", # Explicitly set category
|
|
position=0,
|
|
title="Welcome",
|
|
markdown="# Welcome\nSome intro text",
|
|
requires=["server_url"],
|
|
)
|
|
session.add(step)
|
|
session.commit()
|
|
|
|
fetched = WizardStep.query.first()
|
|
assert fetched is not None
|
|
assert fetched.title == "Welcome"
|
|
assert fetched.to_dict() is not None
|
|
assert fetched.to_dict()["server_type"] == "plex"
|
|
|
|
|
|
def test_unique_server_position_constraint(session):
|
|
"""(server_type, category, position) must be unique."""
|
|
# Both steps must have same category to test the unique constraint
|
|
a = WizardStep(server_type="plex", category="post_invite", position=1, markdown="a")
|
|
b = WizardStep(server_type="plex", category="post_invite", position=1, markdown="b")
|
|
|
|
session.add(a)
|
|
session.commit()
|
|
|
|
session.add(b)
|
|
with pytest.raises(IntegrityError):
|
|
session.commit() # duplicate (server_type, category, position)
|