events/tests
Padreug ecd05b4168
Some checks failed
lint.yml / fix: require a capacity on every ticket wave (pull_request) Failing after 0s
fix: require a capacity on every ticket wave
"Capacity is always required, there is no unlimited" was settled on #34
and enforced in #62 — but as a single number on the event. Since v1.6.8
capacity is per-wave and `event.amount_tickets` is a derived roll-up
(`sync_event_ticket_waves`), so the rule had nothing holding it up at
the level organisers actually set: the wave form's capacity input had no
minimum, and nothing on the backend checked one at all.

A zero-capacity wave can never be active — `get_active_ticket_waves`
requires `amount_tickets > 0` — so it is the wave-level form of exactly
what #62 removed: an event that looks on sale but refuses every
purchase, on the card and at checkout both.

`_validate_wave_capacity` now runs on create and update. Two details
that matter:

- it checks `ensure_ticket_waves(data)` rather than the raw list, so an
  event submitted with no waves is checked through the primary wave it
  is about to be given, not vacuously passed
- on an edit it only checks waves NEW to the event. Selling out is the
  legitimate route to zero, and rejecting it would make a sold-out event
  uneditable — including the legacy zero-capacity rows this rule exists
  to let organisers fix

Frontend: the wave dialog's capacity input gains the `min="1"` and hint
the event-level field already had, and a new wave opens at 1 rather than
0. That default uses `??`, not `||` — a sold-out wave holds 0 and must
keep showing it instead of silently regaining stock when saved.

Also drops the stale `0 = unlimited / not ticketed` contract still
documented on `CreateEvent.amount_tickets`, which has not been true
since #62.

6 new tests; 120 pass. ruff, black, prettier clean; mypy error set
unchanged from baseline.
2026-09-28 23:11:30 +02:00
..
__init__.py feat: code quality (#34) 2024-08-29 12:18:49 +02:00
test_capacity_guard.py fix(tickets): amount_tickets is the remaining count, stop subtracting sold 2026-09-27 22:25:01 +02:00
test_crud_ticket_email.py feat: let a user_id ticket carry an email, accept frontend_url 2026-09-06 19:53:05 +02:00
test_frontend_root.py feat: return buyers to the calling app after Stripe, branded QR endpoint 2026-09-06 19:53:05 +02:00
test_init.py feat: code quality (#34) 2024-08-29 12:18:49 +02:00
test_nostr_publish_pending.py feat(nostr): flag events whose NIP-52 publish didn't land 2026-09-26 23:45:47 +02:00
test_nostr_timestamp.py fix: publish NIP-52 events with monotonic created_at (#26) 2026-06-18 14:13:10 +02:00
test_promo.py Merge upstream v1.6.8 into the aio fork 2026-09-28 22:09:18 +02:00
test_promo_api.py feat(promo): enforce active + max_uses, validate endpoint, codes hidden from public 2026-09-13 18:43:34 +02:00
test_publish_active_wave.py feat(nostr): publish the active ticket wave, not the roll-up 2026-09-28 22:28:09 +02:00
test_publish_availability.py fix(nostr): always publish tickets_available, zero is not unlimited 2026-09-27 23:03:54 +02:00
test_publish_confirmation.py feat(nostr): confirm publishes against the relay's OK 2026-09-27 22:11:21 +02:00
test_ticket_email.py feat: attach a self-describing ticket card to the email (1.6.1-aio.10) 2026-09-08 16:40:25 +02:00
test_ticket_models.py feat: let a user_id ticket carry an email, accept frontend_url 2026-09-06 19:53:05 +02:00
test_ticket_qr.py feat: attach a self-describing ticket card to the email (1.6.1-aio.10) 2026-09-08 16:40:25 +02:00
test_wave_capacity_required.py fix: require a capacity on every ticket wave 2026-09-28 23:11:30 +02:00
test_wave_transition_sweep.py feat(nostr): publish the active ticket wave, not the roll-up 2026-09-28 22:28:09 +02:00