Skip to content

Sprint 4 PR 4.6b — integration tests for resources router - #239

Merged
tomqwu merged 1 commit into
mainfrom
sprint-4-pr-4-6b-resources-integration
Jul 19, 2026
Merged

tomqwu merged 1 commit into
mainfrom
sprint-4-pr-4-6b-resources-integration

Conversation

@tomqwu

@tomqwu tomqwu commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

Continues Sprint 4 PR 4.6b (file-by-file revival of the tests/integration/ tier). Adds a production-endpoint integration file that drives the /resources router over real HTTP against the session-scoped uvicorn api_server fixture. Locks in the admin gate, org tenancy, the duplicate-id 409 guard, and the referential-integrity 409 that fires when an event still references the resource.

Coverage

tests/integration/test_resources.py — 17 tests covering:

  • POST /resources/ — success, admin gate (volunteer 403), duplicate id 409, cross-org 403/404
  • GET /resources/ — envelope shape, org scoping, type=equipment filter, volunteer read allowed, cross-org 403
  • GET /resources/{id} — success + 404
  • PUT /resources/{id} — capacity + location update, admin gate, 404
  • DELETE /resources/{id} — success + 404, admin gate, and the 409 when an Event still references the resource

Validation

  • poetry run pytest tests/integration/test_resources.py -v — 17 passed
  • poetry run black tests/integration/test_resources.py — clean
  • poetry run ruff check tests/integration/test_resources.py — clean

No OpenAPI snapshot refresh (no endpoints added or changed).

Notes

  • test_delete_referenced_by_event_409 creates a real Event with resource_id set, then attempts a delete — locks in the router's referential-integrity guard (not just a schema-level FK check).
  • Uses datetime.now(UTC) + timedelta(days=25) for the event window to avoid clashing with other integration tests that also use future dates.

Follow-ups

Remaining routers still to revive under tests/integration/: recurring_events, assignments, audit, analytics, calendar, password_reset, solutions, solver, people, webhooks.


Generated by Claude Code

Summary: Continues PR 4.6b file-by-file revival of the integration tier.
Adds real-HTTP coverage for /api/v1/resources: create with duplicate/
cross-org guards, list envelope with type filter, get, update, delete
(including the 409-if-referenced-by-Event guard).

Changed files:
- tests/integration/test_resources.py (new) — 17 tests across
  create/list/get/update/delete, covering: admin gate on writes,
  volunteer can read, cross-org 403, duplicate id 409, delete-with-
  referencing-event 409 (the router's referential-integrity guard),
  envelope shape, 404 on missing ids.

Validation:
- poetry run pytest tests/integration/test_resources.py -v — 17 passed
- poetry run black tests/integration/test_resources.py — clean
- poetry run ruff check tests/integration/test_resources.py — clean
- No OpenAPI snapshot refresh (no endpoints added or changed).

Follow-ups:
- Remaining integration files to revive: recurring_events, assignments,
  audit, analytics, calendar, password_reset, solutions, solver, people,
  webhooks.
@tomqwu
tomqwu marked this pull request as ready for review July 19, 2026 13:03
@tomqwu
tomqwu merged commit 176bcaf into main Jul 19, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants