From 3f026c1e90ebd2b5962b5957e8b8b12079a33c50 Mon Sep 17 00:00:00 2001 From: zubair-arbi Date: Tue, 16 Sep 2014 13:06:43 +0500 Subject: [PATCH 1/2] Don't set 'download_video' field on importing video from xml until explicitly set TNL-324 --- .../lib/xmodule/xmodule/tests/test_video.py | 38 ++++++++++++++++++- .../xmodule/video_module/video_module.py | 4 -- .../courseware/tests/test_video_mongo.py | 6 +-- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/common/lib/xmodule/xmodule/tests/test_video.py b/common/lib/xmodule/xmodule/tests/test_video.py index 64c1177f3d..0af8212c7f 100644 --- a/common/lib/xmodule/xmodule/tests/test_video.py +++ b/common/lib/xmodule/xmodule/tests/test_video.py @@ -202,6 +202,40 @@ class VideoDescriptorImportTestCase(unittest.TestCase): 'transcripts': {'ua': 'ukrainian_translation.srt', 'ge': 'german_translation.srt'} }) + def test_constructor_for_download_video(self): + """ + Test that "download_video" field is False (default value) if not explicitly set in xml + """ + sample_xml = ''' + + ''' + descriptor = instantiate_descriptor(data=sample_xml) + self.assert_attributes_equal(descriptor, { + 'youtube_id_1_0': 'p2Q6BrNhdh8', + 'download_video': False, + 'html5_sources': ['http://www.example.com/source.mp4'], + 'data': '' + }) + + # Now construct video from xml with explicitly set download_video and check that + # resulting video descriptor has same value for "download_video" + sample_xml = ''' + + ''' + descriptor = instantiate_descriptor(data=sample_xml) + self.assert_attributes_equal(descriptor, { + 'youtube_id_1_0': 'p2Q6BrNhdh8', + 'download_video': True, + 'html5_sources': ['http://www.example.com/source.mp4'], + 'data': '' + }) + def test_from_xml(self): module_system = DummySystem(load_error_modules=True) xml_data = ''' @@ -262,7 +296,7 @@ class VideoDescriptorImportTestCase(unittest.TestCase): 'track': '', 'handout': None, 'download_track': False, - 'download_video': True, + 'download_video': False, 'html5_sources': ['http://www.example.com/source.mp4'], 'data': '' }) @@ -292,7 +326,7 @@ class VideoDescriptorImportTestCase(unittest.TestCase): 'end_time': datetime.timedelta(seconds=0.0), 'track': 'http://www.example.com/track', 'download_track': True, - 'download_video': True, + 'download_video': False, 'html5_sources': ['http://www.example.com/source.mp4'], 'data': '', 'transcripts': {}, diff --git a/common/lib/xmodule/xmodule/video_module/video_module.py b/common/lib/xmodule/xmodule/video_module/video_module.py index 51d0042101..55528c2a52 100644 --- a/common/lib/xmodule/xmodule/video_module/video_module.py +++ b/common/lib/xmodule/xmodule/video_module/video_module.py @@ -235,12 +235,8 @@ class VideoDescriptor(VideoFields, VideoStudioViewHandlers, TabsEditingDescripto # then delete `source` field value and use value from `html5_sources` field. if self.source in self.html5_sources: self.source = '' # Delete source field value. - self.download_video = True else: # Otherwise, `source` field value will be used. self.source_visible = True - download_video = editable_fields['download_video'] - if not download_video['explicitly_set']: - self.download_video = True # for backward compatibility. # If course was existed and was not re-imported by the moment of adding `download_track` field, diff --git a/lms/djangoapps/courseware/tests/test_video_mongo.py b/lms/djangoapps/courseware/tests/test_video_mongo.py index 8c8f247620..963c861331 100644 --- a/lms/djangoapps/courseware/tests/test_video_mongo.py +++ b/lms/djangoapps/courseware/tests/test_video_mongo.py @@ -148,7 +148,7 @@ class TestGetHtmlMethod(BaseTestXmodule):