From 97d7421432702611768046d5f165da74dfdb58eb Mon Sep 17 00:00:00 2001 From: Valera Rozuvan Date: Fri, 28 Jun 2013 11:32:35 +0300 Subject: [PATCH] Fix for bug Blades/BLD-152. Added test for bugfix. Optimized bug fix. --- .../lib/xmodule/xmodule/videoalpha_module.py | 5 ++- .../courseware/tests/test_videoalpha_mongo.py | 44 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/common/lib/xmodule/xmodule/videoalpha_module.py b/common/lib/xmodule/xmodule/videoalpha_module.py index 6b27bcda2b..3b5b90e674 100644 --- a/common/lib/xmodule/xmodule/videoalpha_module.py +++ b/common/lib/xmodule/xmodule/videoalpha_module.py @@ -70,7 +70,10 @@ class VideoAlphaModule(VideoAlphaFields, XModule): def __init__(self, *args, **kwargs): XModule.__init__(self, *args, **kwargs) xmltree = etree.fromstring(self.data) - self.youtube_streams = xmltree.get('youtube') + + # Front-end expects an empty string, or a properly formatted string with YouTube IDs. + self.youtube_streams = xmltree.get('youtube', '') + self.sub = xmltree.get('sub') self.position = 0 self.show_captions = xmltree.get('show_captions', 'true') diff --git a/lms/djangoapps/courseware/tests/test_videoalpha_mongo.py b/lms/djangoapps/courseware/tests/test_videoalpha_mongo.py index a6bff60acf..182cbab9e7 100644 --- a/lms/djangoapps/courseware/tests/test_videoalpha_mongo.py +++ b/lms/djangoapps/courseware/tests/test_videoalpha_mongo.py @@ -52,3 +52,47 @@ class TestVideo(BaseTestXmodule): 'autoplay': settings.MITX_FEATURES.get('AUTOPLAY_VIDEOS', True) } self.assertDictEqual(context, expected_context) + + +class TestVideoNonYouTube(TestVideo): + """Integration tests: web client + mongo.""" + + DATA = """ + + + + + + """ + MODEL_DATA = { + 'data': DATA + } + + def test_videoalpha_constructor(self): + """Make sure that if the 'youtube' attribute is omitted in XML, then + the template generates an empty string for the YouTube streams. + """ + + # `get_html` return only context, cause we + # overwrite `system.render_template` + context = self.item_module.get_html() + expected_context = { + 'data_dir': getattr(self, 'data_dir', None), + 'caption_asset_path': '/c4x/MITx/999/asset/subs_', + 'show_captions': self.item_module.show_captions, + 'display_name': self.item_module.display_name_with_default, + 'end': self.item_module.end_time, + 'id': self.item_module.location.html_id(), + 'sources': self.item_module.sources, + 'start': self.item_module.start_time, + 'sub': self.item_module.sub, + 'track': self.item_module.track, + 'youtube_streams': '', + 'autoplay': settings.MITX_FEATURES.get('AUTOPLAY_VIDEOS', True) + } + self.assertDictEqual(context, expected_context)