Fix 5 failing tests: auth_config + graduating_class #76
No reviewers
Labels
No labels
domain:backend
domain:devops
domain:frontend
status:approved
status:in-progress
status:needs-fix
status:qa
type:bug
type:devops
type:feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
forgejo_admin/basketball-api!76
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "75-fix-5-failing-tests-auth-config-graduati"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Fixes 5 failing tests in
tests/test_tryouts.pycaused by a missingauth_configon thepublic_clientfixture and missinggraduating_classin twoexpected_fieldssets.Changes
tests/test_tryouts.py: Addedfrom basketball_api.main import _auth_configand setapp.state.auth_config = _auth_configin thepublic_clientfixture, matching the pattern fromconftest.py'sclientfixture. This fixes 3test_requires_authtests that were getting HTTP 500 instead of 401.tests/test_tryouts.py: Added"graduating_class"to theexpected_fieldssets inTestApiCheckIn::test_returns_roster_player_formatandTestApiAssignNumber::test_returns_roster_player_format.Test Plan
python -m pytest tests/test_tryouts.py -v-- all 70 tests pass (0 failures)ruff checkandruff formatcleanReview Checklist
Related
Self-Review: LGTM
Diff: 1 file, +4 / -1. Minimal and scoped to the test file only.
Findings: None. All 3 changes are correct:
_auth_configimport added to existing import line.app.state.auth_config = _auth_configinpublic_clientfixture matches the established pattern fromconftest.py::client."graduating_class"added to bothexpected_fieldssets that were missing it.Verification: 70/70 tests pass. Ruff clean.
PR #76 Review
BLOCKERS
None.
NITS
None.
CODE REVIEW
1.
_auth_configimport andpublic_clientfixture fix (line 12, line 136)The
_auth_configimport is moved from a local import insideconftest.py:client()to a top-level import intest_tryouts.py. This is correct --_auth_configis a module-level singleton inbasketball_api.main(line 39), so importing it at the top of the test file is safe and consistent with importingappfrom the same module.The
public_clientfixture now setsapp.state.auth_config = _auth_configat line 136, exactly matching the pattern inconftest.py:client()(line 83). This ensures that auth-dependent middleware returns proper 401 responses instead of 500 "Auth not configured" errors. The fix is correct and addresses the 3test_requires_authfailures.2.
graduating_classadded toexpected_fields(lines 766, 873)The
graduating_classfield exists in theRosterPlayerPydantic model (src/basketball_api/routes/tryouts.py:444) and is populated in the response builder (tryouts.py:517). The field was already present in theTestPublicRoster::test_all_fields_presentexpected set (line 673) but was missing from the two sets inTestApiCheckInandTestApiAssignNumber. Adding it to both is the correct fix.3. Scope verification
Only
tests/test_tryouts.pyis modified (1 file, +4/-1). No production code touched. The diff is minimal and precisely targeted at the 5 failing tests.4. CI verification
Woodpecker pipeline #96 (pull_request event) shows success. All tests pass.
SOP COMPLIANCE
75-fix-5-failing-tests-auth-config-graduatireferences issue #75)Closes #75)VERDICT: APPROVED