fix(ci): mock AI provider in record_decision test + cache pip/npm + drop term-missing
Three changes that get PR #150 to a green CI gate: 1. **test_record_decision_persists_and_bumps_state_version** — the `decision: draft_template` path calls `_extract_template_parameters` (TemplateExtractionService → AI provider). CI doesn't set ANTHROPIC_API_KEY/GOOGLE_AI_API_KEY, so the endpoint raised `RuntimeError: No AI provider configured` and returned 500. The test isn't exercising the AI integration — patched the extractor with an AsyncMock returning a minimal valid `{templated_body, parameters}` dict. Verified locally: the test now passes. 2. **pip + npm caches** in backend, frontend, and e2e jobs. Keyed on the hash of requirements*.txt / package-lock.json with a runner-os restore-key fallback. Saves ~30-60s per run on cache hit. 3. **Pytest invocation tightened**: - Dropped `--cov-report=term-missing` — the custom "Display coverage summary" step below parses coverage.json and prints the same module list more concisely. Term-missing dumps every uncovered line which adds ~5-10s of stdout. - Added `--maxfail=10` so a structural breakage (fixture explosion, DB unreachable) bails after 10 errors instead of running the full 25-min suite. Tunable. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -218,11 +218,23 @@ async def test_record_decision_persists_and_bumps_state_version(
|
||||
test_db.add(fix)
|
||||
await test_db.commit()
|
||||
|
||||
r = await client.post(
|
||||
f"/api/v1/ai-sessions/{session.id}/suggested-fixes/{fix.id}/decision",
|
||||
headers=auth_headers,
|
||||
json={"decision": "draft_template"},
|
||||
)
|
||||
# The draft_template path calls TemplateExtractionService, which needs an
|
||||
# AI provider configured. CI doesn't set ANTHROPIC_API_KEY/GOOGLE_AI_API_KEY,
|
||||
# and this test isn't exercising the AI integration — patch the extractor
|
||||
# with a minimal valid response so the rest of the decision flow runs.
|
||||
extractor_stub = AsyncMock(return_value={
|
||||
"templated_body": "Write-Output 'ok'",
|
||||
"parameters": [],
|
||||
})
|
||||
with patch(
|
||||
"app.api.endpoints.session_suggested_fixes._extract_template_parameters",
|
||||
extractor_stub,
|
||||
):
|
||||
r = await client.post(
|
||||
f"/api/v1/ai-sessions/{session.id}/suggested-fixes/{fix.id}/decision",
|
||||
headers=auth_headers,
|
||||
json={"decision": "draft_template"},
|
||||
)
|
||||
assert r.status_code == 200
|
||||
assert r.json()["user_decision"] == "draft_template"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user