From dd9f6936bc38b10c10ab7d68bb0243e005f45432 Mon Sep 17 00:00:00 2001 From: 0x29a Date: Wed, 26 Oct 2022 21:13:38 +0200 Subject: [PATCH] refactor: xmodule/video_module -> xmodule/video_block --- .../contentstore/tests/test_contentstore.py | 4 +- .../tests/test_transcripts_utils.py | 20 +++---- .../views/tests/test_course_index.py | 4 +- .../views/tests/test_transcripts.py | 40 +++++++------- .../contentstore/views/transcript_settings.py | 2 +- .../contentstore/views/transcripts_ajax.py | 12 ++--- cms/djangoapps/contentstore/views/videos.py | 2 +- cms/envs/bok_choy.py | 2 +- cms/envs/common.py | 2 +- cms/envs/devstack.py | 2 +- lms/djangoapps/branding/models.py | 4 +- .../course_api/blocks/tests/test_api.py | 2 +- .../tests/test_video_stream_priority.py | 6 +-- .../transformers/tests/test_video_urls.py | 6 +-- .../blocks/transformers/video_urls.py | 2 +- .../courseware/tests/test_module_render.py | 2 +- .../courseware/tests/test_video_handlers.py | 36 ++++++------- .../courseware/tests/test_video_mongo.py | 52 +++++++++---------- .../courseware/tests/test_video_xml.py | 2 +- lms/envs/common.py | 2 +- setup.py | 4 +- xmodule/fields.py | 4 +- .../test_cross_modulestore_import_export.py | 2 +- xmodule/modulestore/tests/test_mongo.py | 6 +-- xmodule/tests/test_export.py | 2 +- xmodule/tests/test_transcripts_utils.py | 2 +- xmodule/tests/test_video.py | 44 ++++++++-------- .../{video_module => video_block}/__init__.py | 4 +- .../bumper_utils.py | 0 .../transcripts_utils.py | 6 +-- .../video_block.py} | 6 +-- .../video_handlers.py | 6 +-- .../video_utils.py | 2 +- .../video_xfields.py | 6 +-- 34 files changed, 149 insertions(+), 149 deletions(-) rename xmodule/{video_module => video_block}/__init__.py (67%) rename xmodule/{video_module => video_block}/bumper_utils.py (100%) rename xmodule/{video_module => video_block}/transcripts_utils.py (99%) rename xmodule/{video_module/video_module.py => video_block/video_block.py} (99%) rename xmodule/{video_module => video_block}/video_handlers.py (99%) rename xmodule/{video_module => video_block}/video_utils.py (98%) rename xmodule/{video_module => video_block}/video_xfields.py (98%) diff --git a/cms/djangoapps/contentstore/tests/test_contentstore.py b/cms/djangoapps/contentstore/tests/test_contentstore.py index 847b4eeeec..99ffec3ac6 100644 --- a/cms/djangoapps/contentstore/tests/test_contentstore.py +++ b/cms/djangoapps/contentstore/tests/test_contentstore.py @@ -38,7 +38,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_block import SequenceBlock -from xmodule.video_module import VideoBlock +from xmodule.video_block import VideoBlock from cms.djangoapps.contentstore.config import waffle from cms.djangoapps.contentstore.tests.utils import AjaxEnabledTestClient, CourseTestCase, get_url, parse_json @@ -403,7 +403,7 @@ class ImportRequiredTestCases(ContentStoreTestCase): import_course_from_xml(self.store, self.user.id, TEST_DATA_DIR, ['toy'], create_if_not_present=True) course_id = self.store.make_course_key('edX', 'toy', '2012_Fall') - # create a new video module and add it as a child to a vertical + # create a new video block and add it as a child to a vertical # this re-creates a bug whereby since the video template doesn't have # anything in 'data' field, the export was blowing up verticals = self.store.get_items(course_id, qualifiers={'category': 'vertical'}) diff --git a/cms/djangoapps/contentstore/tests/test_transcripts_utils.py b/cms/djangoapps/contentstore/tests/test_transcripts_utils.py index 3f6af8512e..69e327bf97 100644 --- a/cms/djangoapps/contentstore/tests/test_transcripts_utils.py +++ b/cms/djangoapps/contentstore/tests/test_transcripts_utils.py @@ -22,7 +22,7 @@ from xmodule.contentstore.django import contentstore # lint-amnesty, pylint: di from xmodule.exceptions import NotFoundError # lint-amnesty, pylint: disable=wrong-import-order from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.video_module import transcripts_utils # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.video_block import transcripts_utils # lint-amnesty, pylint: disable=wrong-import-order TEST_DATA_CONTENTSTORE = copy.deepcopy(settings.CONTENTSTORE) TEST_DATA_CONTENTSTORE['DOC_STORE_CONFIG']['db'] = 'test_xcontent_%s' % uuid4().hex @@ -234,7 +234,7 @@ class TestDownloadYoutubeSubs(TestYoutubeSubsBase): self.clear_sub_content(good_youtube_sub) language_code = 'en' - with patch('xmodule.video_module.transcripts_utils.requests.get') as mock_get: + with patch('xmodule.video_block.transcripts_utils.requests.get') as mock_get: setup_caption_responses(mock_get, language_code, caption_response_string) transcripts_utils.download_youtube_subs(good_youtube_sub, self.course, settings) @@ -257,7 +257,7 @@ class TestDownloadYoutubeSubs(TestYoutubeSubsBase): self.assertEqual(html5_ids[2], 'baz.1.4') self.assertEqual(html5_ids[3], 'foo') - @patch('xmodule.video_module.transcripts_utils.requests.get') + @patch('xmodule.video_block.transcripts_utils.requests.get') def test_fail_downloading_subs(self, mock_get): track_status_code = 404 @@ -458,7 +458,7 @@ class TestYoutubeTranscripts(unittest.TestCase): """ Tests for checking right datastructure returning when using youtube api. """ - @patch('xmodule.video_module.transcripts_utils.requests.get') + @patch('xmodule.video_block.transcripts_utils.requests.get') def test_youtube_bad_status_code(self, mock_get): track_status_code = 404 setup_caption_responses(mock_get, 'en', 'test', track_status_code) @@ -466,7 +466,7 @@ class TestYoutubeTranscripts(unittest.TestCase): with self.assertRaises(transcripts_utils.GetTranscriptsFromYouTubeException): transcripts_utils.get_transcripts_from_youtube(youtube_id, settings, translation) - @patch('xmodule.video_module.transcripts_utils.requests.get') + @patch('xmodule.video_block.transcripts_utils.requests.get') def test_youtube_empty_text(self, mock_get): setup_caption_responses(mock_get, 'en', '') youtube_id = 'bad_youtube_id' @@ -489,7 +489,7 @@ class TestYoutubeTranscripts(unittest.TestCase): } youtube_id = 'good_youtube_id' language_code = 'en' - with patch('xmodule.video_module.transcripts_utils.requests.get') as mock_get: + with patch('xmodule.video_block.transcripts_utils.requests.get') as mock_get: setup_caption_responses(mock_get, language_code, caption_response_string) transcripts = transcripts_utils.get_transcripts_from_youtube(youtube_id, settings, translation) @@ -886,7 +886,7 @@ class TestGetTranscript(SharedModuleStoreTestCase): self.assertEqual(filename, 'ur_video_101.sjson') self.assertEqual(mimetype, self.sjson_mime_type) - @patch('xmodule.video_module.transcripts_utils.get_video_transcript_content') + @patch('xmodule.video_block.transcripts_utils.get_video_transcript_content') def test_get_transcript_from_val(self, mock_get_video_transcript_content): """ Verify that `get_transcript` function returns correct data when transcript is in val. @@ -948,7 +948,7 @@ class TestGetTranscript(SharedModuleStoreTestCase): exception_message = str(no_en_transcript_exception.exception) self.assertEqual(exception_message, 'No transcript for `en` language') - @patch('xmodule.video_module.transcripts_utils.edxval_api.get_video_transcript_data') + @patch('xmodule.video_block.transcripts_utils.edxval_api.get_video_transcript_data') def test_get_transcript_incorrect_json_(self, mock_get_video_transcript_data): """ Verify that `get transcript` function returns a working json file if the original throws an error @@ -962,7 +962,7 @@ class TestGetTranscript(SharedModuleStoreTestCase): transcripts_utils.TranscriptsGenerationException, UnicodeDecodeError('aliencodec', b'\x02\x01', 1, 2, 'alien codec found!') ) - @patch('xmodule.video_module.transcripts_utils.Transcript') + @patch('xmodule.video_block.transcripts_utils.Transcript') def test_get_transcript_val_exceptions(self, exception_to_raise, mock_Transcript): """ Verify that `get_transcript_from_val` function raises `NotFoundError` when specified exceptions raised. @@ -982,7 +982,7 @@ class TestGetTranscript(SharedModuleStoreTestCase): transcripts_utils.TranscriptsGenerationException, UnicodeDecodeError('aliencodec', b'\x02\x01', 1, 2, 'alien codec found!') ) - @patch('xmodule.video_module.transcripts_utils.Transcript') + @patch('xmodule.video_block.transcripts_utils.Transcript') def test_get_transcript_content_store_exceptions(self, exception_to_raise, mock_Transcript): """ Verify that `get_transcript_from_contentstore` function raises `NotFoundError` when specified exceptions raised. diff --git a/cms/djangoapps/contentstore/views/tests/test_course_index.py b/cms/djangoapps/contentstore/views/tests/test_course_index.py index a954a34632..36ed1aef0c 100644 --- a/cms/djangoapps/contentstore/views/tests/test_course_index.py +++ b/cms/djangoapps/contentstore/views/tests/test_course_index.py @@ -769,7 +769,7 @@ class TestCourseReIndex(CourseTestCase): course_id=str(self.course.id)) self.assertEqual(response['total'], 1) - @mock.patch('xmodule.video_module.VideoBlock.index_dictionary') + @mock.patch('xmodule.video_block.VideoBlock.index_dictionary') def test_reindex_video_error_json_responses(self, mock_index_dictionary): """ Test json response with mocked error data for video @@ -879,7 +879,7 @@ class TestCourseReIndex(CourseTestCase): course_id=str(self.course.id)) self.assertEqual(response['total'], 1) - @mock.patch('xmodule.video_module.VideoBlock.index_dictionary') + @mock.patch('xmodule.video_block.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 fd130917d2..07b5e52705 100644 --- a/cms/djangoapps/contentstore/views/tests/test_transcripts.py +++ b/cms/djangoapps/contentstore/views/tests/test_transcripts.py @@ -22,8 +22,8 @@ from xmodule.contentstore.content import StaticContent # lint-amnesty, pylint: from xmodule.contentstore.django import contentstore # lint-amnesty, pylint: disable=wrong-import-order from xmodule.exceptions import NotFoundError # lint-amnesty, pylint: disable=wrong-import-order from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.video_module import VideoBlock # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.video_module.transcripts_utils import ( # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.video_block import VideoBlock # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.video_block.transcripts_utils import ( # lint-amnesty, pylint: disable=wrong-import-order GetTranscriptsFromYouTubeException, Transcript, get_video_transcript_content, @@ -83,7 +83,7 @@ class BaseTranscripts(CourseTestCase): """Create initial data.""" super().setUp() - # Add video module + # Add video block data = { 'parent_locator': str(self.course.location), 'category': 'video', @@ -121,9 +121,9 @@ class BaseTranscripts(CourseTestCase): 1.5: item.youtube_id_1_5 } - def create_non_video_module(self): + def create_non_video_block(self): """ - Setup non video module for tests. + Setup non video block for tests. """ data = { 'parent_locator': str(self.course.location), @@ -324,8 +324,8 @@ class TestUploadTranscripts(BaseTranscripts): """ Test that transcript upload validation fails if item's category is other than video. """ - # non_video module setup - i.e. an item whose category is not 'video'. - usage_key = self.create_non_video_module() + # non_video block setup - i.e. an item whose category is not 'video'. + usage_key = self.create_non_video_block() # Request to upload transcript for the item response = self.upload_transcript(locator=usage_key, transcript_file=self.good_srt_file, edx_video_id='') self.assert_response( @@ -489,8 +489,8 @@ class TestChooseTranscripts(BaseTranscripts): """ Test that transcript choose validation fails if item's category is other than video. """ - # non_video module setup - i.e. an item whose category is not 'video'. - usage_key = self.create_non_video_module() + # non_video block setup - i.e. an item whose category is not 'video'. + usage_key = self.create_non_video_block() # Request to choose transcript for the item response = self.choose_transcript(locator=usage_key, chosen_html5_id=self.chosen_html5_id) self.assert_response( @@ -611,8 +611,8 @@ class TestRenameTranscripts(BaseTranscripts): """ Test that validation fails if item's category is other than video. """ - # non_video module setup - i.e. an item whose category is not 'video'. - usage_key = self.create_non_video_module() + # non_video block setup - i.e. an item whose category is not 'video'. + usage_key = self.create_non_video_block() # Make call to use current transcript from contentstore. response = self.rename_transcript(usage_key) self.assert_response( @@ -747,8 +747,8 @@ class TestReplaceTranscripts(BaseTranscripts): """ Test that validation fails if item's category is other than video. """ - # non_video module setup - i.e. an item whose category is not 'video'. - usage_key = self.create_non_video_module() + # non_video block setup - i.e. an item whose category is not 'video'. + usage_key = self.create_non_video_block() response = self.replace_transcript(usage_key, youtube_id=self.youtube_id) self.assert_response( response, @@ -825,11 +825,11 @@ class TestDownloadTranscripts(BaseTranscripts): response = self.download_transcript(locator='invalid-locator') self.assert_download_response(response, expected_status_code=404) - def test_download_transcript_404_for_non_video_module(self): + def test_download_transcript_404_for_non_video_block(self): """ - Verify that download transcript returns 404 for a non video module. + Verify that download transcript returns 404 for a non video block. """ - usage_key = self.create_non_video_module() + usage_key = self.create_non_video_block() response = self.download_transcript(locator=usage_key) self.assert_download_response(response, expected_status_code=404) @@ -940,7 +940,7 @@ class TestCheckTranscripts(BaseTranscripts): } ) - @patch('xmodule.video_module.transcripts_utils.requests.get') + @patch('xmodule.video_block.transcripts_utils.requests.get') def test_check_youtube_with_transcript_name(self, mock_get): """ Test that the transcripts are fetched correctly when the the transcript name is set @@ -1033,8 +1033,8 @@ class TestCheckTranscripts(BaseTranscripts): self.assertEqual(resp.status_code, 400) self.assertEqual(json.loads(resp.content.decode('utf-8')).get('status'), "Can't find item by locator.") - def test_fail_for_non_video_module(self): - # Not video module: setup + def test_fail_for_non_video_block(self): + # Not video block: setup data = { 'parent_locator': str(self.course.location), 'category': 'problem', @@ -1080,7 +1080,7 @@ class TestCheckTranscripts(BaseTranscripts): 'Transcripts are supported only for "video" modules.', ) - @patch('xmodule.video_module.transcripts_utils.get_video_transcript_content') + @patch('xmodule.video_block.transcripts_utils.get_video_transcript_content') def test_command_for_fallback_transcript(self, mock_get_video_transcript_content): """ Verify the command if a transcript is there in edx-val. diff --git a/cms/djangoapps/contentstore/views/transcript_settings.py b/cms/djangoapps/contentstore/views/transcript_settings.py index 6776094042..40846a2ec3 100644 --- a/cms/djangoapps/contentstore/views/transcript_settings.py +++ b/cms/djangoapps/contentstore/views/transcript_settings.py @@ -27,7 +27,7 @@ from common.djangoapps.util.json_request import JsonResponse, expect_json from openedx.core.djangoapps.video_config.models import VideoTranscriptEnabledFlag from openedx.core.djangoapps.video_pipeline.api import update_3rd_party_transcription_service_credentials from openedx.core.lib.api.view_utils import view_auth_classes -from xmodule.video_module.transcripts_utils import Transcript, TranscriptsGenerationException # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.video_block.transcripts_utils import Transcript, TranscriptsGenerationException # lint-amnesty, pylint: disable=wrong-import-order from .videos import TranscriptProvider diff --git a/cms/djangoapps/contentstore/views/transcripts_ajax.py b/cms/djangoapps/contentstore/views/transcripts_ajax.py index cf322ff45b..a27ae4a4bf 100644 --- a/cms/djangoapps/contentstore/views/transcripts_ajax.py +++ b/cms/djangoapps/contentstore/views/transcripts_ajax.py @@ -29,7 +29,7 @@ from xmodule.contentstore.django import contentstore # lint-amnesty, pylint: di from xmodule.exceptions import NotFoundError # lint-amnesty, pylint: disable=wrong-import-order from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order from xmodule.modulestore.exceptions import ItemNotFoundError # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.video_module.transcripts_utils import ( # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.video_block.transcripts_utils import ( # lint-amnesty, pylint: disable=wrong-import-order GetTranscriptsFromYouTubeException, Transcript, TranscriptsGenerationException, @@ -124,9 +124,9 @@ def save_video_transcript(edx_video_id, input_format, transcript_content, langua return result -def validate_video_module(request, locator): +def validate_video_block(request, locator): """ - Validates video module given its locator and request. Also, checks + Validates video block given its locator and request. Also, checks if requesting user has course authoring access. Arguments: @@ -175,7 +175,7 @@ def validate_transcript_upload_data(request): error = _('Video ID is required.') if not error: - error, video = validate_video_module(request, video_locator) + error, video = validate_video_block(request, video_locator) if not error: validated_data.update({ 'video': video, @@ -250,7 +250,7 @@ def download_transcripts(request): Raises Http404 if unsuccessful. """ - error, video = validate_video_module(request, locator=request.GET.get('locator')) + error, video = validate_video_block(request, locator=request.GET.get('locator')) if error: raise Http404 @@ -491,7 +491,7 @@ def validate_transcripts_request(request, include_yt=False, include_html5=False) if not data: error = _('Incoming video data is empty.') else: - error, video = validate_video_module(request, locator=data.get('locator')) + error, video = validate_video_block(request, locator=data.get('locator')) if not error: validated_data.update({'video': video}) diff --git a/cms/djangoapps/contentstore/views/videos.py b/cms/djangoapps/contentstore/views/videos.py index d9de03a854..3631ff20d3 100644 --- a/cms/djangoapps/contentstore/views/videos.py +++ b/cms/djangoapps/contentstore/views/videos.py @@ -52,7 +52,7 @@ from openedx.core.djangoapps.video_pipeline.config.waffle import ( ) from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag from openedx.core.lib.api.view_utils import view_auth_classes -from xmodule.video_module.transcripts_utils import Transcript # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.video_block.transcripts_utils import Transcript # lint-amnesty, pylint: disable=wrong-import-order from ..models import VideoUploadConfig from ..utils import reverse_course_url diff --git a/cms/envs/bok_choy.py b/cms/envs/bok_choy.py index 24236cc183..f96183840c 100644 --- a/cms/envs/bok_choy.py +++ b/cms/envs/bok_choy.py @@ -57,7 +57,7 @@ update_module_store_settings( default_store=os.environ.get('DEFAULT_STORE', 'draft'), ) -# Needed to enable licensing on video modules +# Needed to enable licensing on video blocks XBLOCK_SETTINGS.update({'VideoBlock': {'licensing_enabled': True}}) # Capture the console log via template includes, until webdriver supports log capture again diff --git a/cms/envs/common.py b/cms/envs/common.py index bcddb293e0..1d326f34cf 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -1578,7 +1578,7 @@ INSTALLED_APPS = [ # Monitor the status of services 'openedx.core.djangoapps.service_status', - # Video module configs (This will be moved to Video once it becomes an XBlock) + # Video block configs (This will be moved to Video once it becomes an XBlock) 'openedx.core.djangoapps.video_config', # edX Video Pipeline integration diff --git a/cms/envs/devstack.py b/cms/envs/devstack.py index 6bffbe3006..c03347ce99 100644 --- a/cms/envs/devstack.py +++ b/cms/envs/devstack.py @@ -137,7 +137,7 @@ FEATURES['ENTRANCE_EXAMS'] = True ################################ COURSE LICENSES ################################ FEATURES['LICENSING'] = True -# Needed to enable licensing on video modules +# Needed to enable licensing on video blocks XBLOCK_SETTINGS.update({'VideoBlock': {'licensing_enabled': True}}) ################################ SEARCH INDEX ################################ diff --git a/lms/djangoapps/branding/models.py b/lms/djangoapps/branding/models.py index ee710847b9..d2df8174b0 100644 --- a/lms/djangoapps/branding/models.py +++ b/lms/djangoapps/branding/models.py @@ -1,8 +1,8 @@ """ -Model used by Video module for Branding configuration. +Model used by Video block for Branding configuration. Includes: - BrandingInfoConfig: A ConfigurationModel for managing how Video Module will + BrandingInfoConfig: A ConfigurationModel for managing how Video Block will use Branding. """ diff --git a/lms/djangoapps/course_api/blocks/tests/test_api.py b/lms/djangoapps/course_api/blocks/tests/test_api.py index f4cfe82f9c..e6fd74463a 100644 --- a/lms/djangoapps/course_api/blocks/tests/test_api.py +++ b/lms/djangoapps/course_api/blocks/tests/test_api.py @@ -144,7 +144,7 @@ class TestGetBlocksVideoUrls(SharedModuleStoreTestCase): self.request = RequestFactory().get("/dummy") self.request.user = self.user - @patch('xmodule.video_module.VideoBlock.student_view_data') + @patch('xmodule.video_block.VideoBlock.student_view_data') def test_video_urls_rewrite(self, video_data_patch): """ Verify the video blocks returned have their URL re-written for diff --git a/lms/djangoapps/course_api/blocks/transformers/tests/test_video_stream_priority.py b/lms/djangoapps/course_api/blocks/transformers/tests/test_video_stream_priority.py index 604f47306c..d0aea73738 100644 --- a/lms/djangoapps/course_api/blocks/transformers/tests/test_video_stream_priority.py +++ b/lms/djangoapps/course_api/blocks/transformers/tests/test_video_stream_priority.py @@ -66,7 +66,7 @@ class TestVideoBlockStreamPriorityTransformer(ModuleStoreTestCase): @mock.patch('lms.djangoapps.course_blocks.usage_info.CourseUsageInfo') @mock.patch('openedx.core.djangoapps.waffle_utils.CourseWaffleFlag.is_enabled') - @mock.patch('xmodule.video_module.VideoBlock.student_view_data') + @mock.patch('xmodule.video_block.VideoBlock.student_view_data') def test_write_for_deprecated_youtube_flag_on(self, mock_video_data, deprecate_youtube_flag, usage_info): """ Test that video stream priority is written correctly with @@ -127,7 +127,7 @@ class TestVideoBlockStreamPriorityTransformer(ModuleStoreTestCase): @mock.patch('lms.djangoapps.course_blocks.usage_info.CourseUsageInfo') @mock.patch('openedx.core.djangoapps.waffle_utils.CourseWaffleFlag.is_enabled') - @mock.patch('xmodule.video_module.VideoBlock.student_view_data') + @mock.patch('xmodule.video_block.VideoBlock.student_view_data') def test_write_for_deprecated_youtube_flag_off(self, mock_video_data, deprecate_youtube_flag, usage_info): """ Test that video stream priority is written correctly with @@ -186,7 +186,7 @@ class TestVideoBlockStreamPriorityTransformer(ModuleStoreTestCase): else: assert post_transform_data[video_format] == fetched_stream_priority - @mock.patch('xmodule.video_module.VideoBlock.student_view_data') + @mock.patch('xmodule.video_block.VideoBlock.student_view_data') def test_no_priority_for_web_only_videos(self, mock_video_data): """ Verify no write attempt is made for the videos diff --git a/lms/djangoapps/course_api/blocks/transformers/tests/test_video_urls.py b/lms/djangoapps/course_api/blocks/transformers/tests/test_video_urls.py index 44c3536e15..8a695ac84a 100644 --- a/lms/djangoapps/course_api/blocks/transformers/tests/test_video_urls.py +++ b/lms/djangoapps/course_api/blocks/transformers/tests/test_video_urls.py @@ -63,7 +63,7 @@ class TestVideoBlockURLTransformer(ModuleStoreTestCase): block_structure=self.block_structure, ) - @mock.patch('xmodule.video_module.VideoBlock.student_view_data') + @mock.patch('xmodule.video_block.VideoBlock.student_view_data') def test_rewrite_for_encoded_videos(self, mock_video_data): """ Test that video URLs for videos with available encodings @@ -93,7 +93,7 @@ class TestVideoBlockURLTransformer(ModuleStoreTestCase): for video_format, video_url in post_transform_data.items(): assert pre_transform_data[video_format] != video_url - @mock.patch('xmodule.video_module.VideoBlock.student_view_data') + @mock.patch('xmodule.video_block.VideoBlock.student_view_data') def test_no_rewrite_for_third_party_vendor(self, mock_video_data): """ Test that video URLs aren't re-written for the videos @@ -123,7 +123,7 @@ class TestVideoBlockURLTransformer(ModuleStoreTestCase): for video_format, video_url in post_transform_data.items(): assert pre_transform_data[video_format] == video_url - @mock.patch('xmodule.video_module.VideoBlock.student_view_data') + @mock.patch('xmodule.video_block.VideoBlock.student_view_data') def test_no_rewrite_for_web_only_videos(self, mock_video_data): """ Verify no rewrite attempt is made for the videos diff --git a/lms/djangoapps/course_api/blocks/transformers/video_urls.py b/lms/djangoapps/course_api/blocks/transformers/video_urls.py index 60e0f3ed82..974c7faf71 100644 --- a/lms/djangoapps/course_api/blocks/transformers/video_urls.py +++ b/lms/djangoapps/course_api/blocks/transformers/video_urls.py @@ -6,7 +6,7 @@ Video block URL Transformer from django.conf import settings from openedx.core.djangoapps.content.block_structure.transformer import BlockStructureTransformer -from xmodule.video_module.video_utils import rewrite_video_url # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.video_block.video_utils import rewrite_video_url # lint-amnesty, pylint: disable=wrong-import-order from .student_view import StudentViewTransformer diff --git a/lms/djangoapps/courseware/tests/test_module_render.py b/lms/djangoapps/courseware/tests/test_module_render.py index 363de536d7..4983a642c1 100644 --- a/lms/djangoapps/courseware/tests/test_module_render.py +++ b/lms/djangoapps/courseware/tests/test_module_render.py @@ -57,7 +57,7 @@ from xmodule.modulestore.tests.django_utils import ( from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, ToyCourseFactory, check_mongo_calls # lint-amnesty, pylint: disable=wrong-import-order from xmodule.modulestore.tests.test_asides import AsideTestType # lint-amnesty, pylint: disable=wrong-import-order from xmodule.services import RebindUserServiceError -from xmodule.video_module import VideoBlock # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.video_block import VideoBlock # lint-amnesty, pylint: disable=wrong-import-order from xmodule.x_module import STUDENT_VIEW, CombinedSystem # lint-amnesty, pylint: disable=wrong-import-order from common.djangoapps import static_replace from common.djangoapps.course_modes.models import CourseMode # lint-amnesty, pylint: disable=reimported diff --git a/lms/djangoapps/courseware/tests/test_video_handlers.py b/lms/djangoapps/courseware/tests/test_video_handlers.py index 91ad34d0b5..d2a260bf86 100644 --- a/lms/djangoapps/courseware/tests/test_video_handlers.py +++ b/lms/djangoapps/courseware/tests/test_video_handlers.py @@ -22,8 +22,8 @@ from xmodule.contentstore.django import contentstore # lint-amnesty, pylint: di from xmodule.exceptions import NotFoundError # lint-amnesty, pylint: disable=wrong-import-order from xmodule.modulestore import ModuleStoreEnum # lint-amnesty, pylint: disable=wrong-import-order from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.video_module import VideoBlock # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.video_module.transcripts_utils import ( # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.video_block import VideoBlock # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.video_block.transcripts_utils import ( # lint-amnesty, pylint: disable=wrong-import-order Transcript, edxval_api, get_transcript, @@ -285,7 +285,7 @@ class TestTranscriptAvailableTranslationsDispatch(TestVideo): # lint-amnesty, p response = self.item.transcript(request=request, dispatch='available_translations') assert json.loads(response.body.decode('utf-8')) == ['uk'] - @patch('xmodule.video_module.transcripts_utils.get_video_transcript_content') + @patch('xmodule.video_block.transcripts_utils.get_video_transcript_content') def test_multiple_available_translations(self, mock_get_video_transcript_content): mock_get_video_transcript_content.return_value = { 'content': json.dumps({ @@ -311,8 +311,8 @@ class TestTranscriptAvailableTranslationsDispatch(TestVideo): # lint-amnesty, p response = self.item.transcript(request=request, dispatch='available_translations') assert sorted(json.loads(response.body.decode('utf-8'))) == sorted(['en', 'uk']) - @patch('xmodule.video_module.transcripts_utils.get_video_transcript_content') - @patch('xmodule.video_module.transcripts_utils.get_available_transcript_languages') + @patch('xmodule.video_block.transcripts_utils.get_video_transcript_content') + @patch('xmodule.video_block.transcripts_utils.get_available_transcript_languages') @ddt.data( ( ['en', 'uk', 'ro'], @@ -388,7 +388,7 @@ class TestTranscriptAvailableTranslationsDispatch(TestVideo): # lint-amnesty, p response = self.item.transcript(request=request, dispatch='available_translations') self.assertCountEqual(json.loads(response.body.decode('utf-8')), result) - @patch('xmodule.video_module.transcripts_utils.edxval_api.get_available_transcript_languages') + @patch('xmodule.video_block.transcripts_utils.edxval_api.get_available_transcript_languages') def test_val_available_translations_feature_disabled(self, mock_get_available_transcript_languages): """ Tests available translations with val transcript languages when feature is disabled. @@ -438,7 +438,7 @@ class TestTranscriptAvailableTranslationsBumperDispatch(TestVideo): # lint-amne response = self.item.transcript(request=request, dispatch=self.dispatch) assert json.loads(response.body.decode('utf-8')) == [lang] - @patch('xmodule.video_module.transcripts_utils.get_available_transcript_languages') + @patch('xmodule.video_block.transcripts_utils.get_available_transcript_languages') def test_multiple_available_translations(self, mock_get_transcript_languages): """ Verify that available translations dispatch works as expected for multiple @@ -498,7 +498,7 @@ class TestTranscriptDownloadDispatch(TestVideo): # lint-amnesty, pylint: disabl assert response.status == '404 Not Found' @patch( - 'xmodule.video_module.video_handlers.get_transcript', + 'xmodule.video_block.video_handlers.get_transcript', return_value=('Subs!', 'test_filename.srt', 'application/x-subrip; charset=utf-8') ) def test_download_srt_exist(self, __): @@ -509,7 +509,7 @@ class TestTranscriptDownloadDispatch(TestVideo): # lint-amnesty, pylint: disabl assert response.headers['Content-Language'] == 'en' @patch( - 'xmodule.video_module.video_handlers.get_transcript', + 'xmodule.video_block.video_handlers.get_transcript', return_value=('Subs!', 'txt', 'text/plain; charset=utf-8') ) def test_download_txt_exist(self, __): @@ -528,7 +528,7 @@ class TestTranscriptDownloadDispatch(TestVideo): # lint-amnesty, pylint: disabl get_transcript(self.item) @patch( - 'xmodule.video_module.transcripts_utils.get_transcript_for_video', + 'xmodule.video_block.transcripts_utils.get_transcript_for_video', return_value=(Transcript.SRT, "塞", 'Subs!') ) def test_download_non_en_non_ascii_filename(self, __): @@ -538,8 +538,8 @@ class TestTranscriptDownloadDispatch(TestVideo): # lint-amnesty, pylint: disabl assert response.headers['Content-Type'] == 'application/x-subrip; charset=utf-8' assert response.headers['Content-Disposition'] == 'attachment; filename="en_塞.srt"' - @patch('xmodule.video_module.transcripts_utils.edxval_api.get_video_transcript_data') - @patch('xmodule.video_module.get_transcript', Mock(side_effect=NotFoundError)) + @patch('xmodule.video_block.transcripts_utils.edxval_api.get_video_transcript_data') + @patch('xmodule.video_block.get_transcript', Mock(side_effect=NotFoundError)) def test_download_fallback_transcript(self, mock_get_video_transcript_data): """ Verify val transcript is returned as a fallback if it is not found in the content store. @@ -778,7 +778,7 @@ class TestTranscriptTranslationGetDispatch(TestVideo): # lint-amnesty, pylint: if sub: assert ('Location', f'/static/dummy/static/subs_{sub}.srt.sjson') in response.headerlist - @patch('xmodule.video_module.VideoBlock.course_id', return_value='not_a_course_locator') + @patch('xmodule.video_block.VideoBlock.course_id', return_value='not_a_course_locator') def test_translation_static_non_course(self, __): """ Test that get_static_transcript short-circuits in the case of a non-CourseLocator. @@ -799,9 +799,9 @@ class TestTranscriptTranslationGetDispatch(TestVideo): # lint-amnesty, pylint: with store.branch_setting(ModuleStoreEnum.Branch.draft_preferred, self.course.id): store.update_item(self.course, self.user.id) - @patch('xmodule.video_module.transcripts_utils.edxval_api.get_video_transcript_data') - @patch('xmodule.video_module.VideoBlock.translation', Mock(side_effect=NotFoundError)) - @patch('xmodule.video_module.VideoBlock.get_static_transcript', Mock(return_value=Response(status=404))) + @patch('xmodule.video_block.transcripts_utils.edxval_api.get_video_transcript_data') + @patch('xmodule.video_block.VideoBlock.translation', Mock(side_effect=NotFoundError)) + @patch('xmodule.video_block.VideoBlock.get_static_transcript', Mock(return_value=Response(status=404))) def test_translation_fallback_transcript(self, mock_get_video_transcript_data): """ Verify that the val transcript is returned as a fallback, @@ -832,8 +832,8 @@ class TestTranscriptTranslationGetDispatch(TestVideo): # lint-amnesty, pylint: for attribute, value in expected_headers.items(): assert response.headers[attribute] == value - @patch('xmodule.video_module.VideoBlock.translation', Mock(side_effect=NotFoundError)) - @patch('xmodule.video_module.VideoBlock.get_static_transcript', Mock(return_value=Response(status=404))) + @patch('xmodule.video_block.VideoBlock.translation', Mock(side_effect=NotFoundError)) + @patch('xmodule.video_block.VideoBlock.get_static_transcript', Mock(return_value=Response(status=404))) def test_translation_fallback_transcript_feature_disabled(self): """ Verify that val transcript is not returned when its feature is disabled. diff --git a/lms/djangoapps/courseware/tests/test_video_mongo.py b/lms/djangoapps/courseware/tests/test_video_mongo.py index ede041dc5e..7fc2f21ee2 100644 --- a/lms/djangoapps/courseware/tests/test_video_mongo.py +++ b/lms/djangoapps/courseware/tests/test_video_mongo.py @@ -41,9 +41,9 @@ from xmodule.modulestore.inheritance import own_metadata from xmodule.modulestore.tests.django_utils import TEST_DATA_MONGO_MODULESTORE, TEST_DATA_SPLIT_MODULESTORE from xmodule.tests.test_import import DummySystem from xmodule.tests.test_video import VideoBlockTestBase -from xmodule.video_module import VideoBlock, bumper_utils, video_utils -from xmodule.video_module.transcripts_utils import Transcript, save_to_store, subs_filename -from xmodule.video_module.video_module import EXPORT_IMPORT_COURSE_DIR, EXPORT_IMPORT_STATIC_DIR +from xmodule.video_block import VideoBlock, bumper_utils, video_utils +from xmodule.video_block.transcripts_utils import Transcript, save_to_store, subs_filename +from xmodule.video_block.video_block import EXPORT_IMPORT_COURSE_DIR, EXPORT_IMPORT_STATIC_DIR from xmodule.x_module import PUBLIC_VIEW, STUDENT_VIEW from common.djangoapps.xblock_django.constants import ATTR_KEY_REQUEST_COUNTRY_CODE @@ -794,8 +794,8 @@ class TestGetHtmlMethod(BaseTestVideoXBlock): return context, expected_context # pylint: disable=invalid-name - @patch('xmodule.video_module.video_module.BrandingInfoConfig') - @patch('xmodule.video_module.video_module.rewrite_video_url') + @patch('xmodule.video_block.video_block.BrandingInfoConfig') + @patch('xmodule.video_block.video_block.rewrite_video_url') def test_get_html_cdn_source(self, mocked_get_video, mock_BrandingInfoConfig): """ Test if sources got from CDN @@ -1021,14 +1021,14 @@ class TestGetHtmlMethod(BaseTestVideoXBlock): """ Verify val profiles on toggling HLS Playback feature. """ - with patch('xmodule.video_module.video_module.edxval_api.get_urls_for_profiles') as get_urls_for_profiles: + with patch('xmodule.video_block.video_block.edxval_api.get_urls_for_profiles') as get_urls_for_profiles: get_urls_for_profiles.return_value = { 'desktop_webm': 'https://webm.com/dw.webm', 'hls': 'https://hls.com/hls.m3u8', 'youtube': 'https://yt.com/?v=v0TFmdO4ZP0', 'desktop_mp4': 'https://mp4.com/dm.mp4' } - with patch('xmodule.video_module.video_module.HLSPlaybackEnabledFlag.feature_enabled') as feature_enabled: + with patch('xmodule.video_block.video_block.HLSPlaybackEnabledFlag.feature_enabled') as feature_enabled: feature_enabled.return_value = hls_feature_enabled video_xml = '' self.initialize_block(data=video_xml) @@ -1038,8 +1038,8 @@ class TestGetHtmlMethod(BaseTestVideoXBlock): expected_val_profiles, ) - @patch('xmodule.video_module.video_module.HLSPlaybackEnabledFlag.feature_enabled', Mock(return_value=True)) - @patch('xmodule.video_module.video_module.edxval_api.get_urls_for_profiles') + @patch('xmodule.video_block.video_block.HLSPlaybackEnabledFlag.feature_enabled', Mock(return_value=True)) + @patch('xmodule.video_block.video_block.edxval_api.get_urls_for_profiles') def test_get_html_hls(self, get_urls_for_profiles): """ Verify that hls profile functionality works as expected. @@ -1094,7 +1094,7 @@ class TestGetHtmlMethod(BaseTestVideoXBlock): context = self.item_descriptor.render(PUBLIC_VIEW).content assert '"saveStateEnabled": false' in context - @patch('xmodule.video_module.video_module.edxval_api.get_course_video_image_url') + @patch('xmodule.video_block.video_block.edxval_api.get_course_video_image_url') def test_poster_image(self, get_course_video_image_url): """ Verify that poster image functionality works as expected. @@ -1107,7 +1107,7 @@ class TestGetHtmlMethod(BaseTestVideoXBlock): assert '"poster": "/media/video-images/poster.png"' in context - @patch('xmodule.video_module.video_module.edxval_api.get_course_video_image_url') + @patch('xmodule.video_block.video_block.edxval_api.get_course_video_image_url') def test_poster_image_without_edx_video_id(self, get_course_video_image_url): """ Verify that poster image is set to None and there is no crash when no edx_video_id. @@ -1120,7 +1120,7 @@ class TestGetHtmlMethod(BaseTestVideoXBlock): assert "'poster': 'null'" in context - @patch('xmodule.video_module.video_module.HLSPlaybackEnabledFlag.feature_enabled', Mock(return_value=False)) + @patch('xmodule.video_block.video_block.HLSPlaybackEnabledFlag.feature_enabled', Mock(return_value=False)) def test_hls_primary_playback_on_toggling_hls_feature(self): """ Verify that `prioritize_hls` is set to `False` if `HLSPlaybackEnabledFlag` is disabled. @@ -1167,7 +1167,7 @@ class TestGetHtmlMethod(BaseTestVideoXBlock): 'result': 'false' }, ) - @patch('xmodule.video_module.video_module.HLSPlaybackEnabledFlag.feature_enabled', Mock(return_value=True)) + @patch('xmodule.video_block.video_block.HLSPlaybackEnabledFlag.feature_enabled', Mock(return_value=True)) def test_deprecate_youtube_course_waffle_flag(self, data): """ Tests various combinations of a `prioritize_hls` flag being set in waffle and overridden for a course. @@ -1228,7 +1228,7 @@ class TestVideoBlockInitialization(BaseTestVideoXBlock): ), ) @ddt.unpack - @patch('xmodule.video_module.video_module.HLSPlaybackEnabledFlag.feature_enabled', Mock(return_value=True)) + @patch('xmodule.video_block.video_block.HLSPlaybackEnabledFlag.feature_enabled', Mock(return_value=True)) def test_val_encoding_in_context(self, val_video_encodings, video_url): """ Tests that the val encodings correctly override the video url when the edx video id is set and @@ -1240,7 +1240,7 @@ class TestVideoBlockInitialization(BaseTestVideoXBlock): a video component is initialized. Current implementation considers this youtube source as a valid external youtube source. """ - with patch('xmodule.video_module.video_module.edxval_api.get_urls_for_profiles') as get_urls_for_profiles: + with patch('xmodule.video_block.video_block.edxval_api.get_urls_for_profiles') as get_urls_for_profiles: get_urls_for_profiles.return_value = val_video_encodings self.initialize_block( data='' @@ -1269,7 +1269,7 @@ class TestVideoBlockInitialization(BaseTestVideoXBlock): ), ) @ddt.unpack - @patch('xmodule.video_module.video_module.HLSPlaybackEnabledFlag.feature_enabled', Mock(return_value=True)) + @patch('xmodule.video_block.video_block.HLSPlaybackEnabledFlag.feature_enabled', Mock(return_value=True)) def test_val_encoding_in_context_without_external_youtube_source(self, val_video_encodings, video_url): """ Tests that the val encodings correctly override the video url when the edx video id is set and @@ -1277,7 +1277,7 @@ class TestVideoBlockInitialization(BaseTestVideoXBlock): Accepted order of source priority is: VAL's youtube source > external youtube source > hls > mp4 > webm. """ - with patch('xmodule.video_module.video_module.edxval_api.get_urls_for_profiles') as get_urls_for_profiles: + with patch('xmodule.video_block.video_block.edxval_api.get_urls_for_profiles') as get_urls_for_profiles: get_urls_for_profiles.return_value = val_video_encodings # pylint: disable=line-too-long self.initialize_block( @@ -1346,7 +1346,7 @@ class TestEditorSavedMethod(BaseTestVideoXBlock): assert isinstance(Transcript.get_asset(item.location, self.file_name), StaticContent) assert isinstance(Transcript.get_asset(item.location, 'subs_video.srt.sjson'), StaticContent) old_metadata = own_metadata(item) - with patch('xmodule.video_module.video_module.manage_video_subtitles_save') as manage_video_subtitles_save: + with patch('xmodule.video_block.video_block.manage_video_subtitles_save') as manage_video_subtitles_save: item.editor_saved(self.user, old_metadata, None) assert not manage_video_subtitles_save.called @@ -1365,14 +1365,14 @@ class TestEditorSavedMethod(BaseTestVideoXBlock): item = self.store.get_item(self.item_descriptor.location) assert item.edx_video_id == unstripped_video_id - # Now, modifying and saving the video module should strip the video id. + # Now, modifying and saving the video block should strip the video id. old_metadata = own_metadata(item) item.display_name = 'New display name' item.editor_saved(self.user, old_metadata, None) assert item.edx_video_id == stripped_video_id @ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split) - @patch('xmodule.video_module.video_module.edxval_api.get_url_for_profile', Mock(return_value='test_yt_id')) + @patch('xmodule.video_block.video_block.edxval_api.get_url_for_profile', Mock(return_value='test_yt_id')) def test_editor_saved_with_yt_val_profile(self, default_store): """ Verify editor saved overrides `youtube_id_1_0` when a youtube val profile is there @@ -1572,7 +1572,7 @@ class TestVideoBlockStudentViewJson(BaseTestVideoXBlock, CacheIsolationTestCase) ({'uk': 1, 'de': 1}, 'en-subs', ['de', 'en'], ['en', 'uk', 'de']), ) @ddt.unpack - @patch('xmodule.video_module.transcripts_utils.edxval_api.get_available_transcript_languages') + @patch('xmodule.video_block.transcripts_utils.edxval_api.get_available_transcript_languages') def test_student_view_with_val_transcripts_enabled(self, transcripts, english_sub, val_transcripts, expected_transcripts, mock_get_transcript_languages): """ @@ -1730,7 +1730,7 @@ class VideoBlockTest(TestCase, VideoBlockTestBase): content=ContentFile(TRANSCRIPT_FILE_SRT_DATA) ) - # Export the video module into xml + # Export the video block into xml video_xml = self.descriptor.definition_to_xml(resource_fs=self.file_system) # Assert `sub` and `transcripts` attribute in the xml @@ -1767,7 +1767,7 @@ class VideoBlockTest(TestCase, VideoBlockTestBase): expected = etree.XML(expected_str, parser=parser) self.assertXmlEqual(expected, actual) - @patch('xmodule.video_module.transcripts_utils.get_video_ids_info') + @patch('xmodule.video_block.transcripts_utils.get_video_ids_info') def test_export_no_video_ids(self, mock_get_video_ids_info): """ Tests export when there is no video id. `export_to_xml` only works in case of video id. @@ -2127,7 +2127,7 @@ class TestVideoWithBumper(TestVideo): # pylint: disable=test-inherits-tests # Use temporary FEATURES in this test without affecting the original FEATURES = dict(settings.FEATURES) - @patch('xmodule.video_module.bumper_utils.get_bumper_settings') + @patch('xmodule.video_block.bumper_utils.get_bumper_settings') def test_is_bumper_enabled(self, get_bumper_settings): """ Check that bumper is (not)shown if ENABLE_VIDEO_BUMPER is (False)True @@ -2151,8 +2151,8 @@ class TestVideoWithBumper(TestVideo): # pylint: disable=test-inherits-tests with override_settings(FEATURES=self.FEATURES): assert not bumper_utils.is_bumper_enabled(self.item_descriptor) - @patch('xmodule.video_module.bumper_utils.is_bumper_enabled') - @patch('xmodule.video_module.bumper_utils.get_bumper_settings') + @patch('xmodule.video_block.bumper_utils.is_bumper_enabled') + @patch('xmodule.video_block.bumper_utils.get_bumper_settings') @patch('edxval.api.get_urls_for_profiles') def test_bumper_metadata(self, get_url_for_profiles, get_bumper_settings, is_bumper_enabled): """ diff --git a/lms/djangoapps/courseware/tests/test_video_xml.py b/lms/djangoapps/courseware/tests/test_video_xml.py index 046c564b41..4e84168bda 100644 --- a/lms/djangoapps/courseware/tests/test_video_xml.py +++ b/lms/djangoapps/courseware/tests/test_video_xml.py @@ -16,7 +16,7 @@ course, section, subsection, unit, etc. from django.test import TestCase -from xmodule.video_module import VideoBlock +from xmodule.video_block import VideoBlock SOURCE_XML = """