Fix: HEIC/MOV-Konvertierung bei Partner-Uploads

Logo-Pfad akzeptierte .heic, öffnete aber direkt mit Pillow (kein HEIF-Opener)
— iPhone-Fotos schlugen fehl. Jetzt convert_media-Vorstufe wie im Foto-Pfad.
Fehlgeschlagene Konvertierungen (HEIC→JPEG, MOV→MP4) brechen mit klarer
Meldung ab statt rohe Dateien zu speichern (MOV wäre als <img> kaputt gerendert).
Test: echter HEIC-Roundtrip (pillow-heif) für Logo + Foto.
This commit is contained in:
rene 2026-06-07 17:29:59 +02:00
parent 21f54f478b
commit 8a614eef1a
2 changed files with 36 additions and 2 deletions

View file

@ -112,6 +112,30 @@ def test_logo_and_photo_upload(client, user):
assert r.json()["photos"] == []
def test_heic_uploads_convert(client, user):
"""HEIC (iPhone-Format) wird bei Logo UND Foto nach WebP konvertiert."""
import pillow_heif
from PIL import Image
_make_partner(user["email"])
pillow_heif.register_heif_opener()
buf = io.BytesIO()
Image.new("RGB", (64, 64), "green").save(buf, format="HEIF")
heic_bytes = buf.getvalue()
# Logo als HEIC
r = client.post("/api/partner/my-profile/logo", headers=user["headers"],
files={"file": ("IMG_0001.HEIC", io.BytesIO(heic_bytes), "image/heic")})
assert r.status_code == 200, r.text
assert r.json()["logo_url"].endswith(".webp")
# Foto als HEIC
r = client.post("/api/partner/my-profile/photos", headers=user["headers"],
files={"file": ("IMG_0002.heic", io.BytesIO(heic_bytes), "image/heic")})
assert r.status_code == 200, r.text
assert r.json()["photos"][0].endswith(".webp")
def test_partner_has_pro_access(client, user):
"""is_partner=1 -> has_pro_access True (Pro gratis fuer Partner)."""
from auth import has_pro_access