This commit is contained in:
imperosol
2025-04-21 20:37:01 +02:00
parent e1331c7cb6
commit e5b5568d51
17 changed files with 426 additions and 134 deletions

View File

@@ -1,12 +1,35 @@
from django.core.files.uploadedfile import SimpleUploadedFile
from model_bakery import seq
from model_bakery.recipe import Recipe
from sas.models import Picture
from core.utils import RED_PIXEL_PNG
from sas.models import Album, Picture
picture_recipe = Recipe(Picture, is_moderated=True, name=seq("Picture "))
"""A SAS Picture fixture.
album_recipe = Recipe(
Album,
name=seq("Album "),
thumbnail=SimpleUploadedFile(
name="thumb.webp", content=b"", content_type="image/webp"
),
)
Warnings:
If you don't `bulk_create` this, you need
to explicitly set the parent album, or it won't work
"""
picture_recipe = Recipe(
Picture,
is_moderated=True,
name=seq("Picture "),
original=SimpleUploadedFile(
# compressed and thumbnail are generated on save (except if bulk creating).
# For this step no to fail, original must be a valid image.
name="img.png",
content=RED_PIXEL_PNG,
content_type="image/png",
),
compressed=SimpleUploadedFile(
name="img.webp", content=b"", content_type="image/webp"
),
thumbnail=SimpleUploadedFile(
name="img.webp", content=b"", content_type="image/webp"
),
)
"""A SAS Picture fixture."""