test(vision): la suite non lascia piu' immagini nel repository
Il file di test dei limiti di upload scriveva un jpeg vero in uploads/vision/reference/ a ogni esecuzione: gli mancava la fixture di dirottamento che test_vision_reference.py ha gia'. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014BBnuACZSCJqXrMYC3LUMU
This commit is contained in:
@@ -21,6 +21,22 @@ from src.backend.models.orm.vision import VisionReferenceImage, VisionResult
|
||||
from src.backend.tests.conftest import auth_headers, create_test_recipe
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def redirect_uploads(monkeypatch, tmp_path):
|
||||
"""Keep the reference image this file stores out of the real repo tree.
|
||||
|
||||
The same guard `test_vision_reference.py` carries: without it, the test that
|
||||
proves a jpeg is stored with its own extension leaves a real file under
|
||||
`uploads/vision/reference/`, so every suite run dirties the working tree.
|
||||
|
||||
`settings.upload_path` is `parents[2] / self.upload_dir`, and pathlib
|
||||
replaces the left operand of `/` when the right one is absolute - so
|
||||
redirecting the bare `upload_dir` setting is enough to redirect the
|
||||
resolved path too.
|
||||
"""
|
||||
monkeypatch.setattr(settings, "upload_dir", str(tmp_path))
|
||||
|
||||
|
||||
def a_png() -> bytes:
|
||||
buffer = io.BytesIO()
|
||||
Image.new("L", (64, 64), color=0).save(buffer, format="PNG")
|
||||
|
||||
Reference in New Issue
Block a user