<s> from django . contrib . contenttypes . models import ContentType <EOL> from django . core . files import File <EOL> from nose . tools import eq_ <EOL> from kitsune . questions . tests import QuestionFactory <EOL> from kitsune . sumo . tests import TestCase <EOL> from kitsune . upload . models import ImageAttachment <EOL> from kitsune . upload . tasks import generate_thumbnail <EOL> from kitsune . users . tests import UserFactory <EOL> class ImageAttachmentTestCase ( TestCase ) : <EOL> def setUp ( self ) : <EOL> super ( ImageAttachmentTestCase , self ) . setUp ( ) <EOL> self . user = UserFactory ( ) <EOL> self . obj = QuestionFactory ( ) <EOL> self . ct = ContentType . objects . get_for_model ( self . obj ) <EOL> def tearDown ( self ) : <EOL> ImageAttachment . objects . all ( ) . delete ( ) <EOL> super ( ImageAttachmentTestCase , self ) . tearDown ( ) <EOL> def test_thumbnail_if_set ( self ) : <EOL> """<STR_LIT>""" <EOL> image = ImageAttachment ( content_object = self . obj , creator = self . user ) <EOL> with open ( '<STR_LIT>' ) as f : <EOL> up_file = File ( f ) <EOL> image . file . save ( up_file . name , up_file , save = True ) <EOL> eq_ ( image . file , image . thumbnail_if_set ( ) ) <EOL> generate_thumbnail ( image , '<STR_LIT:file>' , '<STR_LIT>' ) <EOL> eq_ ( image . thumbnail , image . thumbnail_if_set ( ) ) </s>
