Phase 2a fix: CI test failures blocking deploy #25

Closed
opened 2026-03-10 03:53:43 +00:00 by forgejo_admin · 0 comments

Lineage

plan-2026-03-08-tryout-prep → Phase 2 → Phase 2a → CI fix

Repo

forgejo_admin/basketball-api

User Story

As the team deploying for March 13 tryouts,
I need CI to pass on main so the image builds and we can deploy to prod,
So that branding, tokens, email-first gate, AND coach invite endpoint are all live.

Context

PR #24 (coach invite endpoint) merged to main but pipeline #28 fails at the test step. build-and-push is skipped, so no image exists for the latest main. Three invite-coach tests fail against real Postgres in CI. The dev agent couldn't run tests locally (no Postgres) so these slipped through.

Currently deployed image is b0fc60f (PR #17). PR #22 image exists (1dbfb8f, pipeline #26 succeeded) and is being deployed now. But we need the full main (including PR #24) to pass CI.

67 tests pass. 3 fail. All 3 are in the invite-coach test class.

File Targets

Files to modify:

  • tests/test_admin.py — fix 3 failing tests in TestInviteCoachHappyPath and TestInviteCoachAuth
  • src/basketball_api/routes/admin.py — may need error handling fix if the 500s come from the endpoint, not the test

Files NOT to touch:

  • Everything else — this is a surgical fix

Acceptance Criteria

  • TestInviteCoachHappyPath::test_creates_coach_and_returns_invite passes — fix timezone-aware vs naive datetime comparison
  • TestInviteCoachAuth::test_returns_403_for_non_admin returns 403 not 500 — fix auth dependency error handling
  • TestInviteCoachAuth::test_returns_401_without_token returns 401 not 500 — same root cause as above
  • All 70 tests pass (pytest tests/ -v)
  • ruff format . and ruff check . clean
  • Pipeline succeeds on main (test + build-and-push)

Test Expectations

  • Run pytest tests/ -v — all 70 tests pass
  • Specifically: pytest tests/test_admin.py -v — all 9 tests pass
  • Run command: pytest tests/ -v

Constraints

  • The 500 errors on auth tests likely mean the require_role("admin") dependency raises an unhandled exception when no user/wrong role is provided without the mock override. Check how generate-tokens tests handle auth (they pass) vs invite-coach tests (they fail). The pattern should be identical.
  • The datetime issue: generate_invite_expiry() returns datetime.now(timezone.utc) (tz-aware). The test probably compares to datetime.utcnow() (naive). Fix the test to use tz-aware comparison.
  • Do NOT change existing passing tests
  • Do NOT change endpoint behavior — only fix tests and error handling

Checklist

  • PR opened
  • Tests pass
  • No unrelated changes
  • project-westside-basketball
  • Issue #23 / PR #24 — the code that introduced these tests
  • Pipeline #28 — the failing pipeline
### Lineage `plan-2026-03-08-tryout-prep` → Phase 2 → Phase 2a → CI fix ### Repo `forgejo_admin/basketball-api` ### User Story As the team deploying for March 13 tryouts, I need CI to pass on main so the image builds and we can deploy to prod, So that branding, tokens, email-first gate, AND coach invite endpoint are all live. ### Context PR #24 (coach invite endpoint) merged to main but pipeline #28 fails at the test step. `build-and-push` is skipped, so no image exists for the latest main. Three invite-coach tests fail against real Postgres in CI. The dev agent couldn't run tests locally (no Postgres) so these slipped through. Currently deployed image is `b0fc60f` (PR #17). PR #22 image exists (`1dbfb8f`, pipeline #26 succeeded) and is being deployed now. But we need the full main (including PR #24) to pass CI. **67 tests pass. 3 fail. All 3 are in the invite-coach test class.** ### File Targets Files to modify: - `tests/test_admin.py` — fix 3 failing tests in `TestInviteCoachHappyPath` and `TestInviteCoachAuth` - `src/basketball_api/routes/admin.py` — may need error handling fix if the 500s come from the endpoint, not the test Files NOT to touch: - Everything else — this is a surgical fix ### Acceptance Criteria - [ ] `TestInviteCoachHappyPath::test_creates_coach_and_returns_invite` passes — fix timezone-aware vs naive datetime comparison - [ ] `TestInviteCoachAuth::test_returns_403_for_non_admin` returns 403 not 500 — fix auth dependency error handling - [ ] `TestInviteCoachAuth::test_returns_401_without_token` returns 401 not 500 — same root cause as above - [ ] All 70 tests pass (`pytest tests/ -v`) - [ ] `ruff format .` and `ruff check .` clean - [ ] Pipeline succeeds on main (test + build-and-push) ### Test Expectations - [ ] Run `pytest tests/ -v` — all 70 tests pass - [ ] Specifically: `pytest tests/test_admin.py -v` — all 9 tests pass - Run command: `pytest tests/ -v` ### Constraints - The 500 errors on auth tests likely mean the `require_role("admin")` dependency raises an unhandled exception when no user/wrong role is provided without the mock override. Check how generate-tokens tests handle auth (they pass) vs invite-coach tests (they fail). The pattern should be identical. - The datetime issue: `generate_invite_expiry()` returns `datetime.now(timezone.utc)` (tz-aware). The test probably compares to `datetime.utcnow()` (naive). Fix the test to use tz-aware comparison. - Do NOT change existing passing tests - Do NOT change endpoint behavior — only fix tests and error handling ### Checklist - [ ] PR opened - [ ] Tests pass - [ ] No unrelated changes ### Related - `project-westside-basketball` - Issue #23 / PR #24 — the code that introduced these tests - Pipeline #28 — the failing pipeline
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
forgejo_admin/basketball-api#25
No description provided.