Backend API: auth, projects/images/annotations, R2 presign, tracing, thumbnails, pagination, tests, docs

This commit is contained in:
hailt 2026-11-12 15:12:26 +07:00
parent 5c5deed2f5
commit f8ed08b854
49 changed files with 2626 additions and 0 deletions

30
tests/test_thumbnails.py Normal file
View file

@ -0,0 +1,30 @@
"""Thumbnail resize: pure bytes in/out, no R2, no DB."""
from io import BytesIO
from PIL import Image as PILImage
from shared.thumbnails import resize_to_thumbnail
def _jpeg(width: int, height: int) -> bytes:
buf = BytesIO()
PILImage.new("RGB", (width, height), (200, 30, 30)).save(buf, "JPEG", quality=90)
return buf.getvalue()
def test_resize_bounds_long_side():
out = resize_to_thumbnail(_jpeg(2000, 1000))
with PILImage.open(BytesIO(out)) as im:
assert max(im.size) <= 512
assert im.format == "JPEG"
def test_resize_small_image_not_upscaled():
out = resize_to_thumbnail(_jpeg(100, 60))
with PILImage.open(BytesIO(out)) as im:
assert im.size == (100, 60)
def test_resize_output_is_smaller():
big = _jpeg(1920, 1080)
assert len(resize_to_thumbnail(big)) < len(big)