Spaces:
Sleeping
Sleeping
File size: 930 Bytes
7fa723a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | """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"
|