mirror of
https://github.com/Hopiu/django-imagekit.git
synced 2026-03-16 21:30:23 +00:00
Add test for ProcessedImageField
This commit is contained in:
parent
234082e63c
commit
c6f2c2e7a7
2 changed files with 21 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
|||
from django.db import models
|
||||
|
||||
from imagekit.models import ProcessedImageField
|
||||
from imagekit.models import ImageSpecField
|
||||
from imagekit.processors import Adjust, ResizeToFill, SmartCrop
|
||||
|
||||
|
|
@ -16,6 +17,11 @@ class Photo(models.Model):
|
|||
format='JPEG', options={'quality': 90})
|
||||
|
||||
|
||||
class ProcessedImageFieldModel(models.Model):
|
||||
processed = ProcessedImageField([SmartCrop(50, 50)], format='JPEG',
|
||||
options={'quality': 90}, upload_to='p')
|
||||
|
||||
|
||||
class AbstractImageModel(models.Model):
|
||||
original_image = models.ImageField(upload_to='photos')
|
||||
abstract_class_spec = ImageSpecField()
|
||||
|
|
|
|||
15
tests/test_fields.py
Normal file
15
tests/test_fields.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
from django.core.files.base import File
|
||||
from nose.tools import eq_
|
||||
from . import imagespecs # noqa
|
||||
from .models import ProcessedImageFieldModel
|
||||
from .utils import get_image_file
|
||||
|
||||
|
||||
def test_model_processedimagefield():
|
||||
instance = ProcessedImageFieldModel()
|
||||
file = File(get_image_file())
|
||||
instance.processed.save('whatever.jpeg', file)
|
||||
instance.save()
|
||||
|
||||
eq_(instance.processed.width, 50)
|
||||
eq_(instance.processed.height, 50)
|
||||
Loading…
Reference in a new issue