RandomZ / app /tests /test_photo_vision_paths.py
StormShadow308's picture
Prioritize production AI: photo vision fix, HF profile, and inspector on generate.
7fa723a
Raw
History Blame Contribute Delete
930 Bytes
"""Section photo vision resolves paths under upload_dir."""
from __future__ import annotations
from pathlib import Path
from types import SimpleNamespace
import pytest
from app.services import photo_vision
def test_photo_paths_from_rows_resolves_under_upload_dir(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
upload = tmp_path / "uploads"
monkeypatch.setattr("app.storage.photo_paths.settings.upload_dir", upload)
rel = "tenant_x/report_photos/rep-1/E1/photo-1.jpg"
img = upload / rel
img.parent.mkdir(parents=True)
img.write_bytes(b"\xff\xd8\xff")
row = SimpleNamespace(id="photo-1", file_path=rel, content_type="image/jpeg")
paths = photo_vision._photo_paths_from_rows(
[row],
tenant_id="tenant_x",
report_id="rep-1",
section_code="E1",
)
assert len(paths) == 1
assert paths[0][0] == img
assert paths[0][1] == "image/jpeg"