refactor: xmodule/video_module -> xmodule/video_block

This commit is contained in:
0x29a
2022-10-26 21:13:38 +02:00
committed by Piotr Surowiec
parent 685f1cd679
commit dd9f6936bc
34 changed files with 149 additions and 149 deletions

View File

@@ -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'})

View File

@@ -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.

View File

@@ -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

View File

@@ -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.

View File

@@ -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

View File

@@ -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})

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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 ################################

View File

@@ -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.
"""

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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.

View File

@@ -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 = '<video display_name="Video" download_video="true" edx_video_id="12345-67890">[]</video>'
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='<video display_name="Video" download_video="true" edx_video_id="12345-67890">[]</video>'
@@ -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):
"""

View File

@@ -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 = """
<video show_captions="true"

View File

@@ -2987,7 +2987,7 @@ INSTALLED_APPS = [
# Site configuration for theming and behavioral modification
'openedx.core.djangoapps.site_configuration',
# 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

View File

@@ -33,8 +33,8 @@ XBLOCKS = [
"static_tab = xmodule.html_block:StaticTabBlock",
"unit = xmodule.unit_block:UnitBlock",
"vertical = xmodule.vertical_block:VerticalBlock",
"video = xmodule.video_module:VideoBlock",
"videoalpha = xmodule.video_module:VideoBlock",
"video = xmodule.video_block:VideoBlock",
"videoalpha = xmodule.video_block:VideoBlock",
"videodev = xmodule.template_block:TranslateCustomTagBlock",
"word_cloud = xmodule.word_cloud_block:WordCloudBlock",
"wrapper = xmodule.wrapper_block:WrapperBlock",

View File

@@ -144,7 +144,7 @@ class Timedelta(JSONField): # lint-amnesty, pylint: disable=missing-class-docst
class RelativeTime(JSONField):
"""
Field for start_time and end_time video module properties.
Field for start_time and end_time video block properties.
It was decided, that python representation of start_time and end_time
should be python datetime.timedelta object, to be consistent with
@@ -152,7 +152,7 @@ class RelativeTime(JSONField):
At the same time, serialized representation should be "HH:MM:SS"
This format is convenient to use in XML (and it is used now),
and also it is used in frond-end studio editor of video module as format
and also it is used in frond-end studio editor of video block as format
for start and end time fields.
In database we previously had float type for start_time and end_time fields,

View File

@@ -59,7 +59,7 @@ class CrossStoreXMLRoundtrip(CourseComparisonTest, PartitionTestCase):
self.export_dir = mkdtemp()
self.addCleanup(rmtree, self.export_dir, ignore_errors=True)
@patch('xmodule.video_module.video_module.edxval_api', None)
@patch('xmodule.video_block.video_block.edxval_api', None)
@ddt.data(*itertools.product(
MODULESTORE_SETUPS,
MODULESTORE_SETUPS,

View File

@@ -554,7 +554,7 @@ class TestMongoModuleStore(TestMongoModuleStoreBase):
check_xblock_fields()
check_mongo_fields()
@patch('xmodule.video_module.video_module.edxval_api', None)
@patch('xmodule.video_block.video_block.edxval_api', None)
def test_export_course_image(self):
"""
Test to make sure that we have a course image in the contentstore,
@@ -572,7 +572,7 @@ class TestMongoModuleStore(TestMongoModuleStoreBase):
assert path(root_dir / 'test_export/static/images/course_image.jpg').isfile()
assert path(root_dir / 'test_export/static/images_course_image.jpg').isfile()
@patch('xmodule.video_module.video_module.edxval_api', None)
@patch('xmodule.video_block.video_block.edxval_api', None)
def test_export_course_image_nondefault(self):
"""
Make sure that if a non-default image path is specified that we
@@ -587,7 +587,7 @@ class TestMongoModuleStore(TestMongoModuleStoreBase):
assert path(root_dir / 'test_export/static/just_a_test.jpg').isfile()
assert not path(root_dir / 'test_export/static/images/course_image.jpg').isfile()
@patch('xmodule.video_module.video_module.edxval_api', None)
@patch('xmodule.video_block.video_block.edxval_api', None)
def test_course_without_image(self):
"""
Make sure we elegantly passover our code when there isn't a static

View File

@@ -70,7 +70,7 @@ class RoundTripTestCase(unittest.TestCase):
self.temp_dir = mkdtemp()
self.addCleanup(shutil.rmtree, self.temp_dir)
@mock.patch('xmodule.video_module.video_module.edxval_api', None)
@mock.patch('xmodule.video_block.video_block.edxval_api', None)
@mock.patch('xmodule.course_block.requests.get')
@ddt.data(
"toy",

View File

@@ -7,7 +7,7 @@ These tests follow the following nomenclature:
- among the fields found in a track descriptor is a caption URL (aka caption link)
- use this link to obtain the track's caption data
'''
from ..video_module.transcripts_utils import get_transcript_link_from_youtube
from ..video_block.transcripts_utils import get_transcript_link_from_youtube
from unittest import mock, TestCase

View File

@@ -36,8 +36,8 @@ from xblock.fields import ScopeIds
from xmodule.tests import get_test_descriptor_system
from xmodule.validation import StudioValidationMessage
from xmodule.video_module import EXPORT_IMPORT_STATIC_DIR, VideoBlock, create_youtube_string
from xmodule.video_module.transcripts_utils import save_to_store
from xmodule.video_block import EXPORT_IMPORT_STATIC_DIR, VideoBlock, create_youtube_string
from xmodule.video_block.transcripts_utils import save_to_store
from .test_import import DummySystem
@@ -98,7 +98,7 @@ def instantiate_descriptor(**field_data):
)
# Because of the way xmodule.video_module.video_module imports edxval.api, we
# Because of the way xmodule.video_block.video_block imports edxval.api, we
# must mock the entire module, which requires making mock exception classes.
class _MockValVideoNotFoundError(Exception):
@@ -612,7 +612,7 @@ class VideoBlockImportTestCase(TestCase):
'data': ''
})
@patch('xmodule.video_module.video_module.edxval_api')
@patch('xmodule.video_block.video_block.edxval_api')
def test_import_val_data(self, mock_val_api):
"""
Test that `parse_xml` works method works as expected.
@@ -658,7 +658,7 @@ class VideoBlockImportTestCase(TestCase):
course_id='test_course_id'
)
@patch('xmodule.video_module.video_module.edxval_api')
@patch('xmodule.video_block.video_block.edxval_api')
def test_import_val_data_invalid(self, mock_val_api):
mock_val_api.ValCannotCreateError = _MockValCannotCreateError
mock_val_api.import_from_xml = Mock(side_effect=mock_val_api.ValCannotCreateError)
@@ -686,7 +686,7 @@ class VideoExportTestCase(VideoBlockTestBase):
self.file_system = OSFS(self.temp_dir)
self.addCleanup(shutil.rmtree, self.temp_dir)
@patch('xmodule.video_module.video_module.edxval_api')
@patch('xmodule.video_block.video_block.edxval_api')
def test_export_to_xml(self, mock_val_api):
"""
Test that we write the correct XML on export.
@@ -744,7 +744,7 @@ class VideoExportTestCase(VideoBlockTestBase):
course_id=self.descriptor.scope_ids.usage_id.context_key,
)
@patch('xmodule.video_module.video_module.edxval_api')
@patch('xmodule.video_block.video_block.edxval_api')
def test_export_to_xml_val_error(self, mock_val_api):
# Export should succeed without VAL data if video does not exist
mock_val_api.ValVideoNotFoundError = _MockValVideoNotFoundError
@@ -757,7 +757,7 @@ class VideoExportTestCase(VideoBlockTestBase):
expected = etree.XML(xml_string, parser=parser)
self.assertXmlEqual(expected, xml)
@patch('xmodule.video_module.video_module.edxval_api', None)
@patch('xmodule.video_block.video_block.edxval_api', None)
def test_export_to_xml_empty_end_time(self):
"""
Test that we write the correct XML on export.
@@ -786,7 +786,7 @@ class VideoExportTestCase(VideoBlockTestBase):
expected = etree.XML(xml_string, parser=parser)
self.assertXmlEqual(expected, xml)
@patch('xmodule.video_module.video_module.edxval_api', None)
@patch('xmodule.video_block.video_block.edxval_api', None)
def test_export_to_xml_empty_parameters(self):
"""
Test XML export with defaults.
@@ -796,7 +796,7 @@ class VideoExportTestCase(VideoBlockTestBase):
expected = '<video youtube="1.00:3_yD_cEKoCk" url_name="SampleProblem"/>\n'
assert expected == etree.tostring(xml, pretty_print=True).decode('utf-8')
@patch('xmodule.video_module.video_module.edxval_api', None)
@patch('xmodule.video_block.video_block.edxval_api', None)
def test_export_to_xml_with_transcripts_as_none(self):
"""
Test XML export with transcripts being overridden to None.
@@ -806,7 +806,7 @@ class VideoExportTestCase(VideoBlockTestBase):
expected = b'<video youtube="1.00:3_yD_cEKoCk" url_name="SampleProblem"/>\n'
assert expected == etree.tostring(xml, pretty_print=True)
@patch('xmodule.video_module.video_module.edxval_api', None)
@patch('xmodule.video_block.video_block.edxval_api', None)
def test_export_to_xml_invalid_characters_in_attributes(self):
"""
Test XML export will *not* raise TypeError by lxml library if contains illegal characters.
@@ -816,7 +816,7 @@ class VideoExportTestCase(VideoBlockTestBase):
xml = self.descriptor.definition_to_xml(self.file_system)
assert xml.get('display_name') == 'DisplayName'
@patch('xmodule.video_module.video_module.edxval_api', None)
@patch('xmodule.video_block.video_block.edxval_api', None)
def test_export_to_xml_unicode_characters(self):
"""
Test XML export handles the unicode characters.
@@ -840,7 +840,7 @@ class VideoBlockStudentViewDataTestCase(unittest.TestCase):
VIDEO_URL_3 = 'http://www.example.com/source_high.mp4'
@ddt.data(
# Ensure no extra data is returned if video module configured only for web display.
# Ensure no extra data is returned if video block configured only for web display.
(
{'only_on_web': True},
{'only_on_web': True},
@@ -867,16 +867,16 @@ class VideoBlockStudentViewDataTestCase(unittest.TestCase):
@ddt.unpack
def test_student_view_data(self, field_data, expected_student_view_data):
"""
Ensure that student_view_data returns the expected results for video modules.
Ensure that student_view_data returns the expected results for video blocks.
"""
descriptor = instantiate_descriptor(**field_data)
student_view_data = descriptor.student_view_data()
assert student_view_data == expected_student_view_data
@patch('xmodule.video_module.video_module.HLSPlaybackEnabledFlag.feature_enabled', Mock(return_value=True))
@patch('xmodule.video_module.transcripts_utils.get_available_transcript_languages', Mock(return_value=['es']))
@patch('xmodule.video_block.video_block.HLSPlaybackEnabledFlag.feature_enabled', Mock(return_value=True))
@patch('xmodule.video_block.transcripts_utils.get_available_transcript_languages', Mock(return_value=['es']))
@patch('edxval.api.get_video_info_for_course_and_profiles', Mock(return_value={}))
@patch('xmodule.video_module.transcripts_utils.get_video_transcript_content')
@patch('xmodule.video_block.transcripts_utils.get_video_transcript_content')
@patch('edxval.api.get_video_info')
def test_student_view_data_with_hls_flag(self, mock_get_video_info, mock_get_video_transcript_content):
mock_get_video_info.return_value = {
@@ -958,7 +958,7 @@ class VideoBlockIndexingTestCase(unittest.TestCase):
def test_video_with_no_subs_index_dictionary(self):
"""
Test index dictionary of a video module without subtitles.
Test index dictionary of a video block without subtitles.
"""
xml_data = '''
<video display_name="Test Video"
@@ -978,7 +978,7 @@ class VideoBlockIndexingTestCase(unittest.TestCase):
def test_video_with_multiple_transcripts_index_dictionary(self):
"""
Test index dictionary of a video module with
Test index dictionary of a video block with
two transcripts uploaded by a user.
"""
xml_data_transcripts = '''
@@ -1007,7 +1007,7 @@ class VideoBlockIndexingTestCase(unittest.TestCase):
def test_video_with_multiple_transcripts_translation_retrieval(self):
"""
Test translation retrieval of a video module with
Test translation retrieval of a video block with
multiple transcripts uploaded by a user.
"""
xml_data_transcripts = '''
@@ -1032,7 +1032,7 @@ class VideoBlockIndexingTestCase(unittest.TestCase):
def test_video_with_no_transcripts_translation_retrieval(self):
"""
Test translation retrieval of a video module with
Test translation retrieval of a video block with
no transcripts uploaded by a user- ie, that retrieval
does not throw an exception.
"""
@@ -1049,7 +1049,7 @@ class VideoBlockIndexingTestCase(unittest.TestCase):
@override_settings(ALL_LANGUAGES=ALL_LANGUAGES)
def test_video_with_language_do_not_have_transcripts_translation(self):
"""
Test translation retrieval of a video module with
Test translation retrieval of a video block with
a language having no transcripts uploaded by a user.
"""
xml_data_transcripts = '''

View File

@@ -1,8 +1,8 @@
"""
Container for video module and its utils.
Container for video block and its utils.
"""
from .bumper_utils import *
from .transcripts_utils import * # lint-amnesty, pylint: disable=redefined-builtin
from .video_module import *
from .video_block import *
from .video_utils import *

View File

@@ -121,7 +121,7 @@ def save_subs_to_store(subs, subs_id, item, language='en'):
Args:
`subs_id`: str, subtitles id
`item`: video module instance
`item`: video block instance
`language`: two chars str ('uk'), language of translation of transcripts
Returns: location of saved subtitles.
@@ -410,7 +410,7 @@ def manage_video_subtitles_save(item, user, old_metadata=None, generate_translat
If value of `sub` field of `new_item` is cleared, transcripts should be removed.
`item` is video module instance with updated values of fields,
`item` is video block instance with updated values of fields,
but actually have not been saved to store yet.
`old_metadata` contains old values of XFields.
@@ -846,7 +846,7 @@ class VideoTranscriptsMixin:
def get_default_transcript_language(self, transcripts):
"""
Returns the default transcript language for this video module.
Returns the default transcript language for this video block.
Args:
transcripts (dict): A dict with all transcripts and a sub.

View File

@@ -1,5 +1,5 @@
"""Video is ungraded Xmodule for support video content.
It's new improved video module, which support additional feature:
It's new improved video block, which support additional feature:
- Can play non-YouTube video sources via in-browser HTML5 video player.
- YouTube defaults to HTML5 mode from the start.
- Speed changes in both YouTube and non-YouTube videos happen via
@@ -42,7 +42,7 @@ from xmodule.modulestore.inheritance import InheritanceKeyValueStore, own_metada
from xmodule.raw_block import EmptyDataRawMixin
from xmodule.validation import StudioValidation, StudioValidationMessage
from xmodule.util.xmodule_django import add_webpack_to_fragment
from xmodule.video_module import manage_video_subtitles_save
from xmodule.video_block import manage_video_subtitles_save
from xmodule.x_module import (
PUBLIC_VIEW, STUDENT_VIEW,
HTMLSnippet, ResourceTemplates, shim_xmodule_js,
@@ -1121,7 +1121,7 @@ class VideoBlock(
except edxval_api.ValVideoNotFoundError:
pass
# Fall back to other video URLs in the video module if not found in VAL
# Fall back to other video URLs in the video block if not found in VAL
if not encoded_videos:
if all_sources:
encoded_videos["fallback"] = {

View File

@@ -1,7 +1,7 @@
"""
Handlers for video module.
Handlers for video block.
StudentViewHandlers are handlers for video module instance.
StudentViewHandlers are handlers for video block instance.
StudioViewHandlers are handlers for video descriptor instance.
"""
@@ -56,7 +56,7 @@ def to_boolean(value):
class VideoStudentViewHandlers:
"""
Handlers for video module instance.
Handlers for video block instance.
"""
global_speed = None
transcript_language = None

View File

@@ -1,5 +1,5 @@
"""
Module contains utils specific for video_module but not for transcripts.
Module contains utils specific for video_block but not for transcripts.
"""

View File

@@ -1,5 +1,5 @@
""" # lint-amnesty, pylint: disable=cyclic-import
XFields for video module.
XFields for video block.
"""
@@ -29,7 +29,7 @@ class VideoFields:
default=datetime.timedelta(seconds=0)
)
# TODO: This should be moved to Scope.content, but this will
# require data migration to support the old video module.
# require data migration to support the old video block.
youtube_id_1_0 = String(
help=_("Optional, for older browsers: the YouTube ID for the normal speed video."),
display_name=_("YouTube ID"),
@@ -112,7 +112,7 @@ class VideoFields:
default=False
)
# `sub` is deprecated field and should not be used in future. Now, transcripts are primarily handled in VAL and
# backward compatibility for the video modules already using this field has been ensured.
# backward compatibility for the video blocks already using this field has been ensured.
sub = String(
help=_("The default transcript for the video, from the Default Timed Transcript field on the Basic tab. "
"This transcript should be in English. You don't have to change this setting."),