Example #1
0
    def setUp(self):
        self.backend = get_module_class(settings.THUMBNAIL_BACKEND)()
        self.engine = get_module_class(settings.THUMBNAIL_ENGINE)()
        self.kvstore = get_module_class(settings.THUMBNAIL_KVSTORE)()

        if not os.path.exists(settings.MEDIA_ROOT):
            os.makedirs(settings.MEDIA_ROOT)

        # portrait
        name = 'portrait.jpg'
        fn = pjoin(settings.MEDIA_ROOT, name)
        im = Image.new('L', (100, 200))
        im.paste(255, (0, 0, 100, 100))
        im.save(fn)
        self.portrait = ImageFile(Item.objects.get_or_create(image=name)[0].image)
        self.kvstore.delete(self.portrait)

        # landscape
        name = 'landscape.jpg'
        fn = pjoin(settings.MEDIA_ROOT, name)
        im = Image.new('L', (200, 100))
        im.paste(255, (0, 0, 100, 100))
        im.save(fn)
        self.landscape = ImageFile(Item.objects.get_or_create(image=name)[0].image)
        self.kvstore.delete(self.landscape)
Example #2
0
    def setUp(self):
        self.BACKEND = get_module_class(settings.THUMBNAIL_BACKEND)()
        self.ENGINE = get_module_class(settings.THUMBNAIL_ENGINE)()
        self.KVSTORE = get_module_class(settings.THUMBNAIL_KVSTORE)()

        if not os.path.exists(settings.MEDIA_ROOT):
            os.makedirs(settings.MEDIA_ROOT)
            shutil.copytree(settings.DATA_ROOT, DATA_DIR)

        for dimension in self.IMAGE_DIMENSIONS:
            name = '%sx%s.jpg' % dimension
            self.create_image(name, dimension)
Example #3
0
 def setUp(self):
     self.backend = get_module_class(settings.THUMBNAIL_BACKEND)()
     self.engine = get_module_class(settings.THUMBNAIL_ENGINE)()
     self.kvstore = get_module_class(settings.THUMBNAIL_KVSTORE)()
     if not os.path.exists(settings.MEDIA_ROOT):
         os.makedirs(settings.MEDIA_ROOT)
     dims = [(500, 500), (100, 100)]
     for dim in dims:
         name = "%sx%s.jpg" % dim
         fn = pjoin(settings.MEDIA_ROOT, name)
         im = Image.new("L", dim)
         im.save(fn)
         Item.objects.get_or_create(image=name)
Example #4
0
    def setUp(self):
        self.backend = get_module_class(settings.THUMBNAIL_BACKEND)()
        self.engine = get_module_class(settings.THUMBNAIL_ENGINE)()
        self.kvstore = get_module_class(settings.THUMBNAIL_KVSTORE)()

        if not os.path.exists(settings.MEDIA_ROOT):
            os.makedirs(settings.MEDIA_ROOT)
            shutil.copytree(settings.DATA_ROOT, DATA_DIR)

        dims = [(500, 500), (100, 100), (200, 100), ]

        for dim in dims:
            name = '%sx%s.jpg' % dim
            self.create_image(name, dim)
Example #5
0
 def test_dummy_response(self):
     client = Client()
     response = client.get('/thumbnail-dummy/111x666/')
     engine = get_module_class(settings.THUMBNAIL_ENGINE)()
     image = engine.dummy_image(111, 666)
     raw_data = engine._get_raw_data(image, format_='PNG', quality=95)
     self.assertEqual(response.content, raw_data)
Example #6
0
 def setUp(self):
     self.backend = get_module_class(settings.THUMBNAIL_BACKEND)()
     self.org_settings = {}
     params = {"THUMBNAIL_DUMMY": True}
     for k, v in params.iteritems():
         self.org_settings[k] = getattr(settings, k)
         setattr(settings, k, v)
Example #7
0
 def _setup(self):
     self._wrapped = get_module_class(settings.THUMBNAIL_BACKEND)()
Example #8
0
 def _setup(self):
     self._wrapped = get_module_class(settings.THUMBNAIL_STORAGE)()
Example #9
0
 def _setup(self):
     self._wrapped = get_module_class(data['storage'])()
 def setUp(self):
     self.ENGINE = get_module_class(settings.THUMBNAIL_ENGINE)()
Example #11
0
 def setUp(self):
     self.backend = get_module_class(settings.THUMBNAIL_BACKEND)()
Example #12
0
 def test_encode_utf8_filenames(self):
     storage = get_module_class('sorl.thumbnail.images.UrlStorage')()
     self.assertEqual(
         storage.normalize_url('El jovencito emponzoƱado de whisky, quƩ figura exhibe'),
         'El%20jovencito%20emponzoado%20de%20whisky%2C%20qu%20figura%20exhibe'
     )
Example #13
0
 def setUp(self):
     self.backend = get_module_class(settings.THUMBNAIL_BACKEND)()
     setattr(settings, "THUMBNAIL_DUMMY", True)
Example #14
0
# coding: utf-8

from django.conf import settings
from sorl.thumbnail.helpers import get_module_class

engines = [get_module_class(engine_path)
    for engine_path in settings.SORL_ENGINES]

EngineMixin = type('EngineMixin', tuple(engines), {})