Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ def make_lms_template_path(settings):
'statici18n',

# Tagging
'cms.lib.xblock.tagging',
'cms.lib.xblock.tagging.apps.TaggingConfig',

# Enables default site and redirects
'django_sites_extensions',
Expand Down
12 changes: 12 additions & 0 deletions cms/lib/xblock/tagging/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""Expand commentComment on line R1Code has comments. Press enter to view.
Django app configuration for the XBlock tagging app
"""
from django.apps import AppConfig


class TaggingConfig(AppConfig):
"""
Django app configuration for the XBlock tagging app
"""
name = 'cms.lib.xblock.tagging'
verbose_name = 'XBlock Tagging'
29 changes: 22 additions & 7 deletions lms/djangoapps/courseware/tests/test_video_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import pytest
import ddt
import freezegun
from django.conf import settings
from django.core.files.base import ContentFile
from django.utils.timezone import now
from django.test import RequestFactory
Expand Down Expand Up @@ -48,6 +49,13 @@
Привіт, edX вітає вас.
""")

if settings.USE_EXTRACTED_VIDEO_BLOCK:
path_video_handlers = 'xblocks_contrib.video.video_handlers'
path_transcripts_utils = 'xblocks_contrib.video.video_transcripts_utils'
else:
path_video_handlers = 'xmodule.video_block.video_handlers'
path_transcripts_utils = 'openedx.core.djangoapps.video_config.transcripts_utils'


def _create_srt_file(content=None):
"""
Expand Down Expand Up @@ -206,10 +214,17 @@ def test_handle_ajax(self):
{'demoo�': 'sample'}
]
for sample in data:
response = self.clients[self.users[0].username].post(
self.get_url('save_user_state'),
sample,
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
if settings.USE_EXTRACTED_VIDEO_BLOCK:
handler_url = self.get_url('save_user_state', handler_name='ajax_handler')
response = self.clients[self.users[0].username].post(
handler_url,
sample,
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
else:
response = self.clients[self.users[0].username].post(
self.get_url('save_user_state'),
sample,
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
assert response.status_code == 200

assert self.block.speed is None
Expand Down Expand Up @@ -320,7 +335,7 @@ def test_multiple_available_translations(self, mock_get_video_transcript_content
assert sorted(json.loads(response.body.decode('utf-8'))) == sorted(['en', 'uk'])

@patch('openedx.core.djangoapps.video_config.transcripts_utils.get_video_transcript_content')
@patch('openedx.core.djangoapps.video_config.transcripts_utils.get_available_transcript_languages')
@patch(f'{path_transcripts_utils}.get_available_transcript_languages')
@ddt.data(
(
['en', 'uk', 'ro'],
Expand Down Expand Up @@ -504,7 +519,7 @@ def test_download_transcript_not_exist(self):
assert response.status == '404 Not Found'

@patch(
'xmodule.video_block.video_handlers.get_transcript',
f'{path_video_handlers}.get_transcript',
return_value=('Subs!', 'test_filename.srt', 'application/x-subrip; charset=utf-8')
)
def test_download_srt_exist(self, __):
Expand All @@ -515,7 +530,7 @@ def test_download_srt_exist(self, __):
assert response.headers['Content-Language'] == 'en'

@patch(
'xmodule.video_block.video_handlers.get_transcript',
f'{path_video_handlers}.get_transcript',
return_value=('Subs!', 'txt', 'text/plain; charset=utf-8')
)
def test_download_txt_exist(self, __):
Expand Down
17 changes: 12 additions & 5 deletions lms/djangoapps/courseware/tests/test_video_mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
from xmodule.tests.helpers import mock_render_template, override_descriptor_system # pylint: disable=unused-import
from xmodule.tests.test_import import DummyModuleStoreRuntime
from xmodule.tests.test_video import VideoBlockTestBase
from xmodule.video_block import VideoBlock, bumper_utils, video_utils
from xmodule.video_block import VideoBlock, video_utils
from openedx.core.djangoapps.video_config.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
Expand All @@ -66,6 +66,13 @@
from .test_video_xml import SOURCE_XML, PUBLIC_SOURCE_XML
from common.test.utils import assert_dict_contains_subset

if settings.USE_EXTRACTED_VIDEO_BLOCK:
from xblocks_contrib.video import bumper_utils
bumper_utils_path = 'xblocks_contrib.video.bumper_utils'
else:
from xmodule.video_block import bumper_utils
bumper_utils_path = 'xmodule.video_block.bumper_utils'

TRANSCRIPT_FILE_SRT_DATA = """
1
00:00:14,370 --> 00:00:16,530
Expand Down Expand Up @@ -930,7 +937,7 @@ def helper_get_html_with_edx_video_id(self, data):

# pylint: disable=invalid-name
@patch('xblock.utils.resources.ResourceLoader.render_django_template', side_effect=mock_render_template)
@patch('xmodule.video_block.video_block.rewrite_video_url')
@patch(f'{VideoBlock.__module__}.rewrite_video_url')
def test_get_html_cdn_source(self, mocked_get_video, mock_render_django_template):
"""
Test if sources got from CDN
Expand Down Expand Up @@ -2323,7 +2330,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_block.bumper_utils.get_bumper_settings')
@patch(f'{bumper_utils_path}.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
Expand All @@ -2348,8 +2355,8 @@ def test_is_bumper_enabled(self, get_bumper_settings):
assert not bumper_utils.is_bumper_enabled(self.block)

@patch('xblock.utils.resources.ResourceLoader.render_django_template', side_effect=mock_render_template)
@patch('xmodule.video_block.bumper_utils.is_bumper_enabled')
@patch('xmodule.video_block.bumper_utils.get_bumper_settings')
@patch(f'{bumper_utils_path}.is_bumper_enabled')
@patch(f'{bumper_utils_path}.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, mock_render_django_template
Expand Down
3 changes: 2 additions & 1 deletion openedx/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2114,7 +2114,8 @@ def add_optional_apps(optional_apps, installed_apps):
# .. toggle_warning: Not production-ready until relevant subtask https://github.com/openedx/edx-platform/issues/34827 is done.
# .. toggle_creation_date: 2024-11-10
# .. toggle_target_removal_date: 2025-06-01
USE_EXTRACTED_VIDEO_BLOCK = False
USE_EXTRACTED_VIDEO_BLOCK = True


############################## Marketing Site ##############################

Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ xblock-utils==4.0.0
# via
# edx-sga
# xblock-poll
xblocks-contrib==0.10.2
git+https://github.com/openedx/xblocks-contrib.git@farhan/update-shifted-video-block-code#egg=xblocks-contrib
# via -r requirements/edx/bundled.in
xmlsec==1.3.14
# via
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2299,7 +2299,7 @@ xblock-utils==4.0.0
# -r requirements/edx/testing.txt
# edx-sga
# xblock-poll
xblocks-contrib==0.10.2
git+https://github.com/openedx/xblocks-contrib.git@farhan/update-shifted-video-block-code#egg=xblocks-contrib
# via
# -r requirements/edx/doc.txt
# -r requirements/edx/testing.txt
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1609,7 +1609,7 @@ xblock-utils==4.0.0
# -r requirements/edx/base.txt
# edx-sga
# xblock-poll
xblocks-contrib==0.10.2
git+https://github.com/openedx/xblocks-contrib.git@farhan/update-shifted-video-block-code#egg=xblocks-contrib
# via -r requirements/edx/base.txt
xmlsec==1.3.14
# via
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/testing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1699,7 +1699,7 @@ xblock-utils==4.0.0
# -r requirements/edx/base.txt
# edx-sga
# xblock-poll
xblocks-contrib==0.10.2
git+https://github.com/openedx/xblocks-contrib.git@farhan/update-shifted-video-block-code#egg=xblocks-contrib
# via -r requirements/edx/base.txt
xmlsec==1.3.14
# via
Expand Down
5 changes: 4 additions & 1 deletion xmodule/modulestore/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ def test_get_root_module_name():
Ensure the module name function works with different xblocks.
"""
assert get_root_module_name(LtiConsumerXBlock) == 'lti_consumer'
assert get_root_module_name(VideoBlock) == 'xmodule'
if settings.USE_EXTRACTED_VIDEO_BLOCK:
assert get_root_module_name(VideoBlock) == 'xblocks_contrib'
else:
assert get_root_module_name(VideoBlock) == 'xmodule'
assert get_root_module_name(DoneXBlock) == 'done'


Expand Down
22 changes: 15 additions & 7 deletions xmodule/tests/test_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@
["ur", "Urdu"]
)

if settings.USE_EXTRACTED_VIDEO_BLOCK:
get_available_transcript_languages_path = (
'xblocks_contrib.video.video_transcripts_utils.get_available_transcript_languages'
)
else:
get_available_transcript_languages_path = (
'openedx.core.djangoapps.video_config.transcripts_utils.get_available_transcript_languages'
)


def instantiate_block(**field_data):
"""
Expand Down Expand Up @@ -320,7 +329,7 @@ def test_parse_xml(self):

@XBlockAside.register_temp_plugin(AsideTestType, "test_aside")
@patch('xmodule.video_block.video_block.VideoBlock.load_file')
@patch('xmodule.video_block.video_block.is_pointer_tag')
@patch(f'{VideoBlock.__module__}.is_pointer_tag')
@ddt.data(True, False)
def test_parse_xml_with_asides(self, video_xml_has_aside, mock_is_pointer_tag, mock_load_file):
"""Test that `parse_xml` parses asides from the video xml"""
Expand Down Expand Up @@ -642,7 +651,7 @@ def test_import_with_float_times(self):
'data': ''
})

@patch('xmodule.video_block.video_block.edxval_api')
@patch(f'{VideoBlock.__module__}.edxval_api')
def test_import_val_data(self, mock_val_api):
"""
Test that `parse_xml` works method works as expected.
Expand Down Expand Up @@ -687,7 +696,7 @@ def mock_val_import(xml, edx_video_id, resource_fs, static_dir, external_transcr
course_id='test_course_id'
)

@patch('xmodule.video_block.video_block.edxval_api')
@patch(f'{VideoBlock.__module__}.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)
Expand Down Expand Up @@ -715,7 +724,7 @@ def setUp(self):
self.file_system = OSFS(self.temp_dir)
self.addCleanup(shutil.rmtree, self.temp_dir)

@patch('xmodule.video_block.video_block.edxval_api')
@patch(f'{VideoBlock.__module__}.edxval_api')
def test_export_to_xml(self, mock_val_api):
"""
Test that we write the correct XML on export.
Expand Down Expand Up @@ -815,7 +824,7 @@ def test_export_to_xml_without_video_id(self):
expected = etree.XML(xml_string, parser=parser)
self.assertXmlEqual(expected, xml)

@patch('xmodule.video_block.video_block.edxval_api')
@patch(f'{VideoBlock.__module__}.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
Expand Down Expand Up @@ -948,8 +957,7 @@ def test_student_view_data(self, field_data, expected_student_view_data):
'openedx.core.djangoapps.video_config.services.VideoConfigService.is_hls_playback_enabled',
Mock(return_value=True)
)
@patch('openedx.core.djangoapps.video_config.transcripts_utils.get_available_transcript_languages',
Mock(return_value=['es']))
@patch(get_available_transcript_languages_path, Mock(return_value=['es']))
@patch('edxval.api.get_video_info_for_course_and_profiles', Mock(return_value={}))
@patch('openedx.core.djangoapps.video_config.transcripts_utils.get_video_transcript_content')
@patch('edxval.api.get_video_info')
Expand Down
Loading