Fix test env isolation for credentials and create_pr gate tests #227

Closed
opened 2026-07-06 00:26:20 -05:00 by jcwalker3 · 0 comments
Owner

Problem

Full test suite on master fails 8 tests when GITEA_MCP_CONFIG / GITEA_MCP_PROFILE are set in the operator environment (common during MCP sessions):

  • tests/test_credentials.py::TestGetAuthHeader (2) — profile keychain token leaks before Basic-auth / None fallbacks
  • tests/test_mcp_server.py::TestCreatePR (2) — gitea_create_pr permission/namespace gates block before API path
  • tests/test_mcp_server.py::TestIssueLocking (4) — same gate ordering; tests expect lock-validation exceptions

Fix

  • Isolate TestGetAuthHeader from MCP config env and dynamic token configs
  • Add CREATE_PR_ENV author profile fixture; patch reviewer-stop gate; use patch.dict(..., clear=True) in create_pr tests

Acceptance

  • pytest tests/ --ignore=branches passes with and without GITEA_MCP_PROFILE / GITEA_MCP_CONFIG set
## Problem Full test suite on `master` fails 8 tests when `GITEA_MCP_CONFIG` / `GITEA_MCP_PROFILE` are set in the operator environment (common during MCP sessions): - `tests/test_credentials.py::TestGetAuthHeader` (2) — profile keychain token leaks before Basic-auth / None fallbacks - `tests/test_mcp_server.py::TestCreatePR` (2) — `gitea_create_pr` permission/namespace gates block before API path - `tests/test_mcp_server.py::TestIssueLocking` (4) — same gate ordering; tests expect lock-validation exceptions ## Fix - Isolate `TestGetAuthHeader` from MCP config env and dynamic token configs - Add `CREATE_PR_ENV` author profile fixture; patch reviewer-stop gate; use `patch.dict(..., clear=True)` in create_pr tests ## Acceptance - `pytest tests/ --ignore=branches` passes with and without `GITEA_MCP_PROFILE` / `GITEA_MCP_CONFIG` set
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Scaled-Tech-Consulting/Gitea-Tools#227