Disponibilités déclarées supprimées (table `availability`, migration 0022, API, éditeur de la fiche bénévole, badge de couverture du panneau d'affectation, colonnes des statistiques) ainsi que les règles OUTSIDE_AVAILABILITY, DAILY_HOURS_EXCEEDED et INSUFFICIENT_REST, les malus de disponibilité et de repos du solveur et le filtre « Surchargés » de la vue bénévoles. Seul le chevauchement reste contrôlé. La case « je suis disponible » du formulaire public est conservée. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
59 lines
1.9 KiB
Python
59 lines
1.9 KiB
Python
from app.models import Assignment
|
|
from app.validation.loader import build_validation_input
|
|
from tests.factories import (
|
|
dt_at,
|
|
make_position,
|
|
make_shift,
|
|
make_volunteer,
|
|
)
|
|
|
|
|
|
def test_build_input_gathers_everything_from_db(client, edition, session, day_parts):
|
|
position = make_position(session, edition)
|
|
candidate = make_shift(
|
|
session, edition, position, start=dt_at(10, 14), end=dt_at(10, 18)
|
|
)
|
|
other_shift = make_shift(
|
|
session, edition, position, start=dt_at(11, 9), end=dt_at(11, 12)
|
|
)
|
|
volunteer = make_volunteer(session, edition, email="v@ex.fr")
|
|
session.add(
|
|
Assignment(
|
|
edition_id=edition.id, volunteer_id=volunteer.id,
|
|
shift_id=other_shift.id,
|
|
)
|
|
)
|
|
session.commit()
|
|
|
|
data = build_validation_input(
|
|
session=session, edition=edition, volunteer=volunteer, shift=candidate
|
|
)
|
|
|
|
assert data.candidate_shift.id == str(candidate.id)
|
|
# Toute affectation existante compte, sauf le créneau candidat lui-même.
|
|
assert [s.id for s in data.existing_shifts] == [str(other_shift.id)]
|
|
|
|
|
|
def test_exclude_assignment_id_is_honoured(client, edition, session, day_parts):
|
|
position = make_position(session, edition)
|
|
candidate = make_shift(
|
|
session, edition, position, start=dt_at(10, 14), end=dt_at(10, 18)
|
|
)
|
|
other_shift = make_shift(
|
|
session, edition, position, start=dt_at(11, 9), end=dt_at(11, 12)
|
|
)
|
|
volunteer = make_volunteer(session, edition, email="v@ex.fr")
|
|
own = Assignment(
|
|
edition_id=edition.id, volunteer_id=volunteer.id,
|
|
shift_id=other_shift.id,
|
|
)
|
|
session.add(own)
|
|
session.commit()
|
|
session.refresh(own)
|
|
|
|
data = build_validation_input(
|
|
session=session, edition=edition, volunteer=volunteer,
|
|
shift=candidate, exclude_assignment_id=own.id,
|
|
)
|
|
assert data.existing_shifts == ()
|