From 100bd0535b65904d36e5154278975e2279fdea0c Mon Sep 17 00:00:00 2001 From: Mickael Farina Date: Wed, 22 Jul 2026 18:44:20 +0200 Subject: [PATCH] fix(tests): stop staging fake skills into the operator's real review queue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test_skill_routes hit /api/skill/review through a TestClient, and the handler writes to ~/.codec/skill_reviews — the REAL one. Every run of the suite left a live `test_review.py` sitting in the Skills tab waiting for human approval. Six had accumulated before anyone looked; three landed in a single afternoon of test runs while preparing the demo. routes/skills.py already anticipated exactly this — `_reviews_dir()` is a function rather than a constant, documented "so tests can monkeypatch it to a tmp dir for isolation". Nothing ever did. An autouse fixture now points it at tmp_path. Verified: real review count is 6 before the suite and 6 after (was +1 per run). Co-Authored-By: Claude Opus 4.8 --- tests/test_skill_routes.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_skill_routes.py b/tests/test_skill_routes.py index 9b70be6..95aa8cd 100644 --- a/tests/test_skill_routes.py +++ b/tests/test_skill_routes.py @@ -10,6 +10,7 @@ import sys from pathlib import Path +import pytest from fastapi import FastAPI from fastapi.testclient import TestClient @@ -56,6 +57,22 @@ def test_replacement_handlers_present(): # ── Live TestClient checks (verify the FastAPI app behavior) ────────────────── +@pytest.fixture(autouse=True) +def _isolate_reviews(tmp_path, monkeypatch): + """Stage reviews into a tmp dir, never the user's real ~/.codec. + + routes/skills.py deliberately exposes _reviews_dir() as a FUNCTION "so tests + can monkeypatch it to a tmp dir for isolation" — but nothing did, so every + run of this file wrote a live `test_review.py` into the operator's Skills + review queue. Six had piled up before anyone noticed; three of them landed + in a single afternoon of test runs. + """ + d = tmp_path / "skill_reviews" + d.mkdir() + monkeypatch.setattr(skills_routes, "_reviews_dir", lambda: str(d)) + return d + + def _make_client() -> TestClient: app = FastAPI() app.include_router(skills_routes.router)