示例#1
0
    def test_thumb_utils_methods(self, image):
        """
        Bunch of tests on thumb_utils helpers.
        """
        filename = 'test-thumb'
        upload_path = thumb_utils.thumb_path(filename)
        self.assertEqual(upload_path, os.path.join(settings.THUMBNAIL_LOCATION, filename))
        thumb_utils.remove_thumbs(filename)
        self.assertFalse(thumb_utils.thumb_exists(filename))
        f = BytesIO(test_image.tobytes())
        f.name = filename
        storage_manager.save(upload_path, File(f))
        self.assertTrue(thumb_utils.thumb_exists(filename))
        self.assertEqual(thumb_utils.thumb_size(upload_path), 10000)

        # cleanup: remove saved thumbnail
        thumb_utils.remove_thumbs(filename)
        self.assertFalse(thumb_utils.thumb_exists(filename))
示例#2
0
 def test_get_unique_upload_path(self):
     dataset = Dataset.objects.first()
     thumbnail_name = thumbnails._generate_thumbnail_name(dataset)
     upload_path = utils.thumb_path(thumbnail_name)
     new_upload_path = utils.get_unique_upload_path(thumbnail_name)
     self.assertNotEqual(upload_path, new_upload_path)