From 0b27c62ca62e86cd18b4bed33ceb848dd88a80d6 Mon Sep 17 00:00:00 2001 From: Usman Khalid <2200617@gmail.com> Date: Thu, 2 May 2019 21:43:31 +0500 Subject: [PATCH] Convert VideoModule to VideoBlock. Some deprecated functionality has been removed: - Reading data field and transforms being applied in the init() method. - The source field. - The source_visible attribute. --- .../tests/test_migrate_transcripts.py | 13 +- .../contentstore/tests/test_contentstore.py | 8 +- .../views/tests/test_course_index.py | 4 +- .../views/tests/test_transcripts.py | 28 ++- cms/envs/bok_choy.py | 2 +- cms/envs/common.py | 6 +- cms/envs/devstack.py | 2 +- cms/envs/production.py | 4 +- cms/static/sass/_shame.scss | 2 +- cms/static/sass/elements/_modal-window.scss | 2 +- cms/static/sass/elements/_xmodules.scss | 2 +- common/lib/xmodule/setup.py | 4 +- common/lib/xmodule/xmodule/editing_module.py | 28 ++- common/lib/xmodule/xmodule/raw_module.py | 13 +- common/lib/xmodule/xmodule/static_content.py | 39 +++- common/lib/xmodule/xmodule/tests/__init__.py | 4 +- .../lib/xmodule/xmodule/tests/test_video.py | 129 ++++------- .../xmodule/tests/test_xblock_wrappers.py | 3 - .../xmodule/video_module/bumper_utils.py | 2 +- .../xmodule/video_module/transcripts_utils.py | 4 +- .../xmodule/video_module/video_handlers.py | 2 +- .../xmodule/video_module/video_module.py | 194 +++++++---------- .../xmodule/video_module/video_utils.py | 2 +- .../xmodule/video_module/video_xfields.py | 10 +- .../test/acceptance/pages/lms/video/video.py | 2 +- .../acceptance/pages/studio/video/video.py | 2 +- .../tests/video/test_video_license.py | 6 +- .../tests/video/test_video_module.py | 4 +- .../commands/tests/test_dump_course.py | 8 +- .../courseware/tests/test_module_render.py | 30 ++- .../courseware/tests/test_video_handlers.py | 44 ++-- .../courseware/tests/test_video_mongo.py | 204 +++++++----------- .../courseware/tests/test_video_xml.py | 22 +- lms/envs/production.py | 4 +- 34 files changed, 379 insertions(+), 454 deletions(-) diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_migrate_transcripts.py b/cms/djangoapps/contentstore/management/commands/tests/test_migrate_transcripts.py index 58e81d86e7..113fc1fa81 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_migrate_transcripts.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_migrate_transcripts.py @@ -18,6 +18,7 @@ from openedx.core.djangoapps.video_config.models import ( from xmodule.modulestore.django import modulestore from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.video_module import VideoBlock from xmodule.video_module.transcripts_utils import save_to_store from edxval import api as api from testfixtures import LogCapture @@ -105,9 +106,9 @@ class TestMigrateTranscripts(ModuleStoreTestCase): youtube="1.0:p2Q6BrNhdh8,0.75:izygArpw-Qo,1.25:1EeWXzPdhSA,1.5:rABDYkeK0x8" show_captions="false" download_track="false" - start_time="00:00:01" + start_time="1.0" download_video="false" - end_time="00:01:00"> + end_time="60.0"> @@ -122,9 +123,9 @@ class TestMigrateTranscripts(ModuleStoreTestCase): youtube="1.0:p2Q6BrNhdh8,0.75:izygArpw-Qo,1.25:1EeWXzPdhSA,1.5:rABDYkeK0x8" show_captions="false" download_track="false" - start_time="00:00:01" + start_time="1.0" download_video="false" - end_time="00:01:00"> + end_time="60.0"> @@ -133,11 +134,11 @@ class TestMigrateTranscripts(ModuleStoreTestCase): ''' self.video_descriptor = ItemFactory.create( parent_location=self.course.location, category='video', - data={'data': video_sample_xml} + **VideoBlock.parse_video_xml(video_sample_xml) ) self.video_descriptor_2 = ItemFactory.create( parent_location=self.course_2.location, category='video', - data={'data': video_sample_xml_2} + **VideoBlock.parse_video_xml(video_sample_xml_2) ) save_to_store(SRT_FILEDATA, 'subs_grmtran1.srt', 'text/srt', self.video_descriptor.location) diff --git a/cms/djangoapps/contentstore/tests/test_contentstore.py b/cms/djangoapps/contentstore/tests/test_contentstore.py index 5b48c6fd9e..e0df1a65ac 100644 --- a/cms/djangoapps/contentstore/tests/test_contentstore.py +++ b/cms/djangoapps/contentstore/tests/test_contentstore.py @@ -54,6 +54,7 @@ from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, chec from xmodule.modulestore.xml_exporter import export_course_to_xml from xmodule.modulestore.xml_importer import import_course_from_xml, perform_xlint from xmodule.seq_module import SequenceDescriptor +from xmodule.video_module import VideoBlock TEST_DATA_CONTENTSTORE = copy.deepcopy(settings.CONTENTSTORE) TEST_DATA_CONTENTSTORE['DOC_STORE_CONFIG']['db'] = 'test_xcontent_%s' % uuid4().hex @@ -1815,15 +1816,15 @@ class MetadataSaveTestCase(ContentStoreTestCase): """ self.video_descriptor = ItemFactory.create( parent_location=course.location, category='video', - data={'data': video_sample_xml} + **VideoBlock.parse_video_xml(video_sample_xml) ) def test_metadata_not_persistence(self): @@ -1840,7 +1841,6 @@ class MetadataSaveTestCase(ContentStoreTestCase): 'youtube_id_1_5', 'start_time', 'end_time', - 'source', 'html5_sources', 'track' } diff --git a/cms/djangoapps/contentstore/views/tests/test_course_index.py b/cms/djangoapps/contentstore/views/tests/test_course_index.py index 42879eed70..d1f0154538 100644 --- a/cms/djangoapps/contentstore/views/tests/test_course_index.py +++ b/cms/djangoapps/contentstore/views/tests/test_course_index.py @@ -718,7 +718,7 @@ class TestCourseReIndex(CourseTestCase): course_id=unicode(self.course.id)) self.assertEqual(response['total'], 1) - @mock.patch('xmodule.video_module.VideoDescriptor.index_dictionary') + @mock.patch('xmodule.video_module.VideoBlock.index_dictionary') def test_reindex_video_error_json_responses(self, mock_index_dictionary): """ Test json response with mocked error data for video @@ -828,7 +828,7 @@ class TestCourseReIndex(CourseTestCase): course_id=unicode(self.course.id)) self.assertEqual(response['total'], 1) - @mock.patch('xmodule.video_module.VideoDescriptor.index_dictionary') + @mock.patch('xmodule.video_module.VideoBlock.index_dictionary') def test_indexing_video_error_responses(self, mock_index_dictionary): """ Test do_course_reindex response with mocked error data for video diff --git a/cms/djangoapps/contentstore/views/tests/test_transcripts.py b/cms/djangoapps/contentstore/views/tests/test_transcripts.py index 05e03aebd6..8dc31a1284 100644 --- a/cms/djangoapps/contentstore/views/tests/test_transcripts.py +++ b/cms/djangoapps/contentstore/views/tests/test_transcripts.py @@ -21,6 +21,7 @@ from xmodule.contentstore.content import StaticContent from xmodule.contentstore.django import contentstore from xmodule.exceptions import NotFoundError from xmodule.modulestore.django import modulestore +from xmodule.video_module import VideoBlock from xmodule.video_module.transcripts_utils import ( GetTranscriptsFromYouTubeException, Transcript, @@ -94,7 +95,9 @@ class BaseTranscripts(CourseTestCase): self.item = modulestore().get_item(self.video_usage_key) # hI10vDNYz4M - valid Youtube ID with transcripts. # JMD_ifUUfsU, AKqURZnYqpk, DYpADpL7jAY - valid Youtube IDs without transcripts. - self.item.data = ' """ with self.assertRaises(mock_val_api.ValCannotCreateError): - VideoDescriptor.from_xml(xml_data, module_system, id_generator=Mock()) + VideoBlock.from_xml(xml_data, module_system, id_generator=Mock()) -class VideoExportTestCase(VideoDescriptorTestBase): +class VideoExportTestCase(VideoBlockTestBase): """ - Make sure that VideoDescriptor can export itself to XML correctly. + Make sure that VideoBlock can export itself to XML correctly. """ def setUp(self): @@ -773,7 +773,7 @@ class VideoExportTestCase(VideoDescriptorTestBase): xml = self.descriptor.definition_to_xml(self.file_system) parser = etree.XMLParser(remove_blank_text=True) - xml_string = '