Commit 6b824897 by David Baumgold

Merge pull request #5685 from edx/uncomment-thumbnail-tests

Uncomment thumbnail tests
parents cb1058ac 9440235a
...@@ -13,6 +13,8 @@ from path import path ...@@ -13,6 +13,8 @@ from path import path
from tempdir import mkdtemp_clean from tempdir import mkdtemp_clean
from textwrap import dedent from textwrap import dedent
from uuid import uuid4 from uuid import uuid4
from functools import wraps
from unittest import SkipTest
from django.conf import settings from django.conf import settings
from django.contrib.auth.models import User from django.contrib.auth.models import User
...@@ -58,6 +60,26 @@ TEST_DATA_CONTENTSTORE['DOC_STORE_CONFIG']['db'] = 'test_xcontent_%s' % uuid4(). ...@@ -58,6 +60,26 @@ TEST_DATA_CONTENTSTORE['DOC_STORE_CONFIG']['db'] = 'test_xcontent_%s' % uuid4().
TEST_DATA_DIR = settings.COMMON_TEST_DATA_ROOT 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) @override_settings(CONTENTSTORE=TEST_DATA_CONTENTSTORE)
class ContentStoreTestCase(CourseTestCase): class ContentStoreTestCase(CourseTestCase):
""" """
...@@ -100,6 +122,7 @@ class ImportRequiredTestCases(ContentStoreTestCase): ...@@ -100,6 +122,7 @@ class ImportRequiredTestCases(ContentStoreTestCase):
effort = self.store.get_item(course_key.make_usage_key('about', 'end_date')) effort = self.store.get_item(course_key.make_usage_key('about', 'end_date'))
self.assertEqual(effort.data, 'TBD') self.assertEqual(effort.data, 'TBD')
@requires_pillow_jpeg
def test_asset_import(self): def test_asset_import(self):
''' '''
This test validates that an image asset is imported and a thumbnail was generated for a .gif This test validates that an image asset is imported and a thumbnail was generated for a .gif
...@@ -117,37 +140,16 @@ class ImportRequiredTestCases(ContentStoreTestCase): ...@@ -117,37 +140,16 @@ class ImportRequiredTestCases(ContentStoreTestCase):
self.assertGreater(len(all_assets), 0) self.assertGreater(len(all_assets), 0)
# make sure we have some thumbnails in our contentstore # make sure we have some thumbnails in our contentstore
content_store.get_all_content_thumbnails_for_course(course.id) all_thumbnails = content_store.get_all_content_thumbnails_for_course(course.id)
self.assertGreater(len(all_thumbnails), 0)
#
# 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
location = AssetLocation.from_deprecated_string('/c4x/edX/toy/asset/just_a_test.jpg')
content = content_store.find(location)
self.assertIsNotNone(content) self.assertIsNotNone(content)
# self.assertIsNotNone(content.thumbnail_location)
# cdodge: temporarily comment out assertion on thumbnails because many environments thumbnail = content_store.find(content.thumbnail_location)
# will not have the jpeg converter installed and this test will fail self.assertIsNotNone(thumbnail)
#
# self.assertIsNotNone(content.thumbnail_location)
#
# thumbnail = None
# try:
# thumbnail = content_store.find(content.thumbnail_location)
# except:
# pass
#
# self.assertIsNotNone(thumbnail)
def test_course_info_updates_import_export(self): def test_course_info_updates_import_export(self):
""" """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment