Merge pull request #5685 from edx/uncomment-thumbnail-tests
Uncomment thumbnail tests
This commit is contained in:
@@ -13,6 +13,8 @@ from path import path
|
||||
from tempdir import mkdtemp_clean
|
||||
from textwrap import dedent
|
||||
from uuid import uuid4
|
||||
from functools import wraps
|
||||
from unittest import SkipTest
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
@@ -58,6 +60,26 @@ TEST_DATA_CONTENTSTORE['DOC_STORE_CONFIG']['db'] = 'test_xcontent_%s' % uuid4().
|
||||
TEST_DATA_DIR = settings.COMMON_TEST_DATA_ROOT
|
||||
|
||||
|
||||
def requires_pillow_jpeg(func):
|
||||
"""
|
||||
A decorator to indicate that the function requires JPEG support for Pillow,
|
||||
otherwise it cannot be run
|
||||
"""
|
||||
@wraps(func)
|
||||
def decorated_func(*args, **kwargs):
|
||||
"""
|
||||
Execute the function if we have JPEG support in Pillow.
|
||||
"""
|
||||
try:
|
||||
from PIL import Image
|
||||
except ImportError:
|
||||
raise SkipTest("Pillow is not installed (or not found)")
|
||||
if not getattr(Image.core, "jpeg_decoder", False):
|
||||
raise SkipTest("Pillow cannot open JPEG files")
|
||||
return func(*args, **kwargs)
|
||||
return decorated_func
|
||||
|
||||
|
||||
@override_settings(CONTENTSTORE=TEST_DATA_CONTENTSTORE)
|
||||
class ContentStoreTestCase(CourseTestCase):
|
||||
"""
|
||||
@@ -100,6 +122,7 @@ class ImportRequiredTestCases(ContentStoreTestCase):
|
||||
effort = self.store.get_item(course_key.make_usage_key('about', 'end_date'))
|
||||
self.assertEqual(effort.data, 'TBD')
|
||||
|
||||
@requires_pillow_jpeg
|
||||
def test_asset_import(self):
|
||||
'''
|
||||
This test validates that an image asset is imported and a thumbnail was generated for a .gif
|
||||
@@ -117,37 +140,16 @@ class ImportRequiredTestCases(ContentStoreTestCase):
|
||||
self.assertGreater(len(all_assets), 0)
|
||||
|
||||
# make sure we have some thumbnails in our contentstore
|
||||
content_store.get_all_content_thumbnails_for_course(course.id)
|
||||
|
||||
#
|
||||
# cdodge: temporarily comment out assertion on thumbnails because many environments
|
||||
# will not have the jpeg converter installed and this test will fail
|
||||
#
|
||||
#
|
||||
# self.assertGreater(len(all_thumbnails), 0)
|
||||
|
||||
content = None
|
||||
try:
|
||||
location = AssetLocation.from_deprecated_string('/c4x/edX/toy/asset/sample_static.txt')
|
||||
content = content_store.find(location)
|
||||
except NotFoundError:
|
||||
pass
|
||||
all_thumbnails = content_store.get_all_content_thumbnails_for_course(course.id)
|
||||
self.assertGreater(len(all_thumbnails), 0)
|
||||
|
||||
location = AssetLocation.from_deprecated_string('/c4x/edX/toy/asset/just_a_test.jpg')
|
||||
content = content_store.find(location)
|
||||
self.assertIsNotNone(content)
|
||||
|
||||
#
|
||||
# cdodge: temporarily comment out assertion on thumbnails because many environments
|
||||
# will not have the jpeg converter installed and this test will fail
|
||||
#
|
||||
# self.assertIsNotNone(content.thumbnail_location)
|
||||
#
|
||||
# thumbnail = None
|
||||
# try:
|
||||
# thumbnail = content_store.find(content.thumbnail_location)
|
||||
# except:
|
||||
# pass
|
||||
#
|
||||
# self.assertIsNotNone(thumbnail)
|
||||
self.assertIsNotNone(content.thumbnail_location)
|
||||
thumbnail = content_store.find(content.thumbnail_location)
|
||||
self.assertIsNotNone(thumbnail)
|
||||
|
||||
def test_course_info_updates_import_export(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user