Badges : corrections de lint (E501) et couverture du smoke test
Lignes trop longues détectées par ruff (badges.py, tests) ; ajout de /badges au smoke test frontend (rendu SSR de chaque écran protégé). Vérifié dans ce commit : pytest (248 passés), ruff check, alembic check, tsc --noEmit, eslint, vite build, smoke — tous verts. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
579ea5d9db
commit
bc165757ca
@@ -226,14 +226,18 @@ AssignmentRow = tuple[Position, Shift, Volunteer | None] # (poste, créneau, r
|
||||
|
||||
|
||||
def _role_label(volunteer_id: uuid.UUID, lead_volunteer_ids: set[uuid.UUID]) -> str:
|
||||
return t("badge.role.referent") if volunteer_id in lead_volunteer_ids else t("badge.role.volunteer")
|
||||
if volunteer_id in lead_volunteer_ids:
|
||||
return t("badge.role.referent")
|
||||
return t("badge.role.volunteer")
|
||||
|
||||
|
||||
def _category_label(category) -> str:
|
||||
return t(f"position.category.{category.value.lower()}")
|
||||
|
||||
|
||||
def _position_line(position: Position, shift: Shift, referent: Volunteer | None, volunteer_id: uuid.UUID) -> str:
|
||||
def _position_line(
|
||||
position: Position, shift: Shift, referent: Volunteer | None, volunteer_id: uuid.UUID
|
||||
) -> str:
|
||||
"""Une ligne par créneau affecté : poste + horaire, et le référent du
|
||||
poste s'il y en a un — sauf si le bénévole badgé est lui-même ce
|
||||
référent (pas besoin de se l'indiquer à soi-même)."""
|
||||
@@ -258,7 +262,9 @@ def _field_text(
|
||||
for position, shift, referent in assignments
|
||||
)
|
||||
if field.field_type == BadgeFieldType.CATEGORY:
|
||||
categories = sorted({_category_label(position.category) for position, _shift, _r in assignments})
|
||||
categories = sorted(
|
||||
{_category_label(position.category) for position, _shift, _r in assignments}
|
||||
)
|
||||
return ", ".join(categories)
|
||||
if field.field_type == BadgeFieldType.ROLE:
|
||||
return _role_label(volunteer.id, lead_volunteer_ids)
|
||||
@@ -315,7 +321,9 @@ def generate_badges(
|
||||
BadgeSpec(
|
||||
fields=tuple(
|
||||
BadgeFieldSpec(
|
||||
text=_field_text(field, volunteer, assignments_by_volunteer, lead_volunteer_ids),
|
||||
text=_field_text(
|
||||
field, volunteer, assignments_by_volunteer, lead_volunteer_ids
|
||||
),
|
||||
x_mm=field.x_mm,
|
||||
y_mm=field.y_mm,
|
||||
width_mm=field.width_mm,
|
||||
|
||||
@@ -23,7 +23,10 @@ def _position(**kw) -> Position:
|
||||
|
||||
|
||||
def _shift(start: dt.datetime, end: dt.datetime) -> Shift:
|
||||
return Shift(id=uuid.uuid4(), edition_id=uuid.uuid4(), position_id=uuid.uuid4(), starts_at=start, ends_at=end)
|
||||
return Shift(
|
||||
id=uuid.uuid4(), edition_id=uuid.uuid4(), position_id=uuid.uuid4(),
|
||||
starts_at=start, ends_at=end,
|
||||
)
|
||||
|
||||
|
||||
def test_position_line_shows_the_schedule():
|
||||
|
||||
@@ -76,7 +76,9 @@ def test_day_part_before_the_day_boundary_rolls_to_the_next_calendar_day(client,
|
||||
shifts = client.get(
|
||||
f"/editions/{edition.id}/shifts", params={"position_id": position["id"]}
|
||||
).json()
|
||||
nuit_shifts = [s for s in shifts if dt.time.fromisoformat(s["starts_at"][11:19]) == dt.time(2, 0)]
|
||||
nuit_shifts = [
|
||||
s for s in shifts if dt.time.fromisoformat(s["starts_at"][11:19]) == dt.time(2, 0)
|
||||
]
|
||||
assert len(nuit_shifts) == 4
|
||||
|
||||
nuit_dates = sorted(dt.date.fromisoformat(s["starts_at"][:10]) for s in nuit_shifts)
|
||||
|
||||
Reference in New Issue
Block a user