Skip to content

Commit

Permalink
add image to command
Browse files Browse the repository at this point in the history
  • Loading branch information
viggo-devries committed Dec 8, 2023
1 parent 33450c5 commit dec2bc1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions oscar_odin/management/commands/test_illshit.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import io
import PIL

from decimal import Decimal as D

from django.core.management.base import BaseCommand
from django.core.files import File
from django.test import TestCase
from oscar.core.loading import get_model

Expand Down Expand Up @@ -30,6 +34,10 @@
class Command(BaseCommand):

def handle(self, *args, **options):
img = PIL.Image.new(mode="RGB", size=(200, 200))
output = io.BytesIO()
img.save(output, "jpeg")

product_class, _ = ProductClass.objects.get_or_create(
slug="klaas", defaults={"requires_shipping": True, "track_stock": True, "name": "Klaas"}
)
Expand Down Expand Up @@ -84,8 +92,7 @@ def handle(self, *args, **options):
partner=partner,
product_class=product_class,
images=[
ImageResource(caption="gekke caption", display_order=0),
ImageResource(caption="gekke caption 2", display_order=1),
ImageResource(caption="gekke caption", display_order=0, original=File(output, name="image%s.jpg")),
],
categories=[
CategoryResource(name="henk", slug="klaas"),
Expand Down

0 comments on commit dec2bc1

Please sign in to comment.