<s> from django import forms <EOL> from django . core . files . base import File <EOL> from django . core . files . uploadedfile import SimpleUploadedFile <EOL> from imagekit import forms as ikforms <EOL> from imagekit . processors import SmartCrop <EOL> from nose . tools import eq_ <EOL> from . import imagegenerators <EOL> from . models import ProcessedImageFieldModel , ImageModel <EOL> from . utils import get_image_file <EOL> def test_model_processedimagefield ( ) : <EOL> instance = ProcessedImageFieldModel ( ) <EOL> file = File ( get_image_file ( ) ) <EOL> instance . processed . save ( '<STR_LIT>' , file ) <EOL> instance . save ( ) <EOL> eq_ ( instance . processed . width , <NUM_LIT:50> ) <EOL> eq_ ( instance . processed . height , <NUM_LIT:50> ) <EOL> def test_form_processedimagefield ( ) : <EOL> class TestForm ( forms . ModelForm ) : <EOL> image = ikforms . ProcessedImageField ( spec_id = '<STR_LIT>' , <EOL> processors = [ SmartCrop ( <NUM_LIT:50> , <NUM_LIT:50> ) ] , format = '<STR_LIT>' ) <EOL> class Meta : <EOL> model = ImageModel <EOL> fields = '<STR_LIT:image>' , <EOL> upload_file = get_image_file ( ) <EOL> file_dict = { '<STR_LIT:image>' : SimpleUploadedFile ( '<STR_LIT>' , upload_file . read ( ) ) } <EOL> form = TestForm ( { } , file_dict ) <EOL> instance = form . save ( ) <EOL> eq_ ( instance . image . width , <NUM_LIT:50> ) <EOL> eq_ ( instance . image . height , <NUM_LIT:50> ) </s>
