Le seed créait déjà des disponibilités, mais aucun Artist ni vœu (VolunteerPositionWish, VolunteerArtist) — la démo ne montrait donc rien du solveur ni des vœux : postes/artistes jamais choisis, programmation vide. - 3 artistes par jour de festival (pas montage/démontage), horaires échelonnés en soirée (18h-19h / 19h30-21h / 21h30-23h). - ~40 % des bénévoles ont un vœu de poste ; ~15 % de chance par artiste d'être un vœu (~1 par bénévole en moyenne sur 6 artistes). - Summary affiche désormais artists / position_wishes / artist_wishes ; tests étendus (présence + déterminisme). Vérifié en conditions réelles (`python -m app.seed` + appels API) : 6 artistes, 47 vœux de poste, 95 vœux d'artiste sur 120 bénévoles ; le solveur tourne toujours en ~0,3 s dessus. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017uUsRg7XzopkCPWimwg9ZM
53 lines
1.8 KiB
Python
53 lines
1.8 KiB
Python
from sqlmodel import select
|
|
|
|
from app.models import Edition, Volunteer
|
|
from app.seed import DEMO_EDITION_NAME, build
|
|
|
|
|
|
def test_build_creates_a_realistic_dataset(session):
|
|
summary = build(session)
|
|
|
|
assert summary.volunteers == 120
|
|
assert summary.positions == 15
|
|
assert summary.shifts > 40
|
|
assert summary.assignments > 100
|
|
assert summary.understaffed_shifts >= 3 # « quelques trous d'effectif »
|
|
assert summary.blocking == 0 # aucune violation bloquante
|
|
# Au moins deux règles d'avertissement représentées, quelques alertes.
|
|
assert len(summary.warnings) >= 2
|
|
assert sum(summary.warnings.values()) >= 3
|
|
# Programmation et vœux des bénévoles : le mode démo doit les illustrer.
|
|
assert summary.artists > 0
|
|
assert summary.position_wishes > 0
|
|
assert summary.artist_wishes > 0
|
|
|
|
edition = session.exec(
|
|
select(Edition).where(Edition.name == DEMO_EDITION_NAME)
|
|
).one()
|
|
volunteers = session.exec(
|
|
select(Volunteer).where(Volunteer.edition_id == edition.id)
|
|
).all()
|
|
assert len(volunteers) == 120
|
|
|
|
|
|
def test_build_is_deterministic_and_idempotent(session):
|
|
first = build(session)
|
|
second = build(session)
|
|
|
|
assert (second.volunteers, second.positions, second.shifts) == (
|
|
first.volunteers,
|
|
first.positions,
|
|
first.shifts,
|
|
)
|
|
assert second.assignments == first.assignments
|
|
assert second.understaffed_shifts == first.understaffed_shifts
|
|
assert dict(second.warnings) == dict(first.warnings)
|
|
assert second.artists == first.artists
|
|
assert second.position_wishes == first.position_wishes
|
|
assert second.artist_wishes == first.artist_wishes
|
|
|
|
editions = session.exec(
|
|
select(Edition).where(Edition.name == DEMO_EDITION_NAME)
|
|
).all()
|
|
assert len(editions) == 1
|