Fix TestIssueLockArtifactWarning profile gate setup (full suite failure) #359

Closed
opened 2026-07-07 04:22:56 -05:00 by jcwalker3 · 0 comments
Owner

Problem

The full test suite has 1 failing test on master:

FAILED tests/test_agent_temp_artifacts.py::TestIssueLockArtifactWarning::test_lock_success_includes_artifact_warning

Latest run: 1151 passed, 6 skipped, 1 failed (observed while validating PR #358 / issue #316).

Root cause

TestIssueLockArtifactWarning calls mcp_server.gitea_lock_issue() without seeding author profile permissions.

gitea_lock_issue is gated via task_capability_mapgitea.issue.comment (see task_capability_map.py). Without GITEA_ALLOWED_OPERATIONS, _profile_permission_block returns:

{
  "success": false,
  "reasons": ["profile has no configured allowed operations (fail closed)"]
}

So the assertion result["success"] fails before artifact-warning logic is exercised.

Working pattern elsewhere

tests/test_mcp_server.py::TestIssueLocking already does this correctly in setUp:

ISSUE_WRITE_ENV = {
    "GITEA_ALLOWED_OPERATIONS": (
        "gitea.issue.create,gitea.issue.close,gitea.issue.comment"
    ),
}

self._env_patcher = patch.dict(os.environ, ISSUE_WRITE_ENV, clear=True)

Suggested fix

In tests/test_agent_temp_artifacts.py:

  1. Reuse ISSUE_WRITE_ENV from test_mcp_server (or duplicate locally).
  2. Add setUp/tearDown with patch.dict(os.environ, ISSUE_WRITE_ENV, clear=True) for TestIssueLockArtifactWarning.
  3. Optionally align auth patching with TestIssueLocking (get_auth_header instead of _auth) for consistency.
  4. Provide complete mocked git state (base_equivalent, inspected_git_root, base_branch) like _clean_master_git_state_for_lock() to avoid future lock-worktree regressions.

Acceptance criteria

  • pytest tests/test_agent_temp_artifacts.py::TestIssueLockArtifactWarning::test_lock_success_includes_artifact_warning passes
  • Full suite passes: pytest -q → 0 failures
  • Test still verifies artifact warning is present when porcelain contains ?? _emit_payload.py

Context

  • Related original feature: #261 (agent temp artifact detection)
  • Discovered during full-suite validation for PR #358 (#316)
## Problem The full test suite has **1 failing test** on `master`: ``` FAILED tests/test_agent_temp_artifacts.py::TestIssueLockArtifactWarning::test_lock_success_includes_artifact_warning ``` Latest run: **1151 passed, 6 skipped, 1 failed** (observed while validating PR #358 / issue #316). ## Root cause `TestIssueLockArtifactWarning` calls `mcp_server.gitea_lock_issue()` without seeding author profile permissions. `gitea_lock_issue` is gated via `task_capability_map` → `gitea.issue.comment` (see `task_capability_map.py`). Without `GITEA_ALLOWED_OPERATIONS`, `_profile_permission_block` returns: ```json { "success": false, "reasons": ["profile has no configured allowed operations (fail closed)"] } ``` So the assertion `result["success"]` fails before artifact-warning logic is exercised. ## Working pattern elsewhere `tests/test_mcp_server.py::TestIssueLocking` already does this correctly in `setUp`: ```python ISSUE_WRITE_ENV = { "GITEA_ALLOWED_OPERATIONS": ( "gitea.issue.create,gitea.issue.close,gitea.issue.comment" ), } self._env_patcher = patch.dict(os.environ, ISSUE_WRITE_ENV, clear=True) ``` ## Suggested fix In `tests/test_agent_temp_artifacts.py`: 1. Reuse `ISSUE_WRITE_ENV` from `test_mcp_server` (or duplicate locally). 2. Add `setUp`/`tearDown` with `patch.dict(os.environ, ISSUE_WRITE_ENV, clear=True)` for `TestIssueLockArtifactWarning`. 3. Optionally align auth patching with `TestIssueLocking` (`get_auth_header` instead of `_auth`) for consistency. 4. Provide complete mocked git state (`base_equivalent`, `inspected_git_root`, `base_branch`) like `_clean_master_git_state_for_lock()` to avoid future lock-worktree regressions. ## Acceptance criteria - `pytest tests/test_agent_temp_artifacts.py::TestIssueLockArtifactWarning::test_lock_success_includes_artifact_warning` passes - Full suite passes: `pytest -q` → 0 failures - Test still verifies artifact warning is present when porcelain contains `?? _emit_payload.py` ## Context - Related original feature: #261 (agent temp artifact detection) - Discovered during full-suite validation for PR #358 (#316)
jcwalker3 added the status:in-progress label 2026-07-07 04:25:55 -05:00
sysadmin removed the status:in-progress label 2026-07-07 08:15:20 -05:00
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#359