Apply reference design to Astro and add screenshot storage

This commit is contained in:
ik
2026-09-03 07:53:53 +07:00
parent 6d536d0ade
commit c5242720b1
26 changed files with 253 additions and 59 deletions
+28
View File
@@ -0,0 +1,28 @@
from __future__ import annotations
import io
import pytest
from PIL import Image
from app.storage import ScreenshotError, prepare_image
def test_prepare_image_removes_metadata() -> None:
source = Image.new("RGB", (32, 24), "#12383b")
exif = Image.Exif()
exif[0x010E] = "private note"
raw = io.BytesIO()
source.save(raw, format="JPEG", exif=exif)
cleaned, extension, mime = prepare_image(raw.getvalue())
with Image.open(io.BytesIO(cleaned)) as result:
assert result.getexif() == {}
assert result.size == (32, 24)
assert (extension, mime) == ("jpg", "image/jpeg")
def test_prepare_image_rejects_non_image() -> None:
with pytest.raises(ScreenshotError, match="valid image"):
prepare_image(b"not an image")