refactor: use video block utils from xblocks-contrib package (#38088)
* refactor: use bumper_utils from xblocks-contrib package * refactor: use video_handlers from xblocks-contrib package * fix: fix test_video_handlers test cases
This commit is contained in:
committed by
GitHub
parent
68a53b8506
commit
9b6445cb7b
@@ -46,6 +46,7 @@ from openedx.core.djangoapps.video_config.services import VideoConfigService
|
||||
from openedx.core.djangoapps.discussions.services import DiscussionConfigService
|
||||
from openedx.core.lib.xblock_services.call_to_action import CallToActionService
|
||||
from xmodule.contentstore.django import contentstore
|
||||
from xblocks_contrib.video.exceptions import TranscriptNotFoundError
|
||||
from xmodule.exceptions import NotFoundError as XModuleNotFoundError
|
||||
from xmodule.library_tools import LegacyLibraryToolsService
|
||||
from xmodule.modulestore.django import XBlockI18nService, modulestore
|
||||
@@ -975,7 +976,7 @@ def _invoke_xblock_handler(request, course_id, usage_id, handler, suffix, course
|
||||
raise Http404 # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
# If we can't find the block, respond with a 404
|
||||
except (XModuleNotFoundError, NotFoundError):
|
||||
except (XModuleNotFoundError, NotFoundError, TranscriptNotFoundError):
|
||||
log.exception("Module indicating to user that request doesn't exist")
|
||||
raise Http404 # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
|
||||
@@ -320,7 +320,7 @@ class TestTranscriptAvailableTranslationsDispatch(TestVideo): # lint-amnesty, p
|
||||
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('edxval.api.get_available_transcript_languages')
|
||||
@ddt.data(
|
||||
(
|
||||
['en', 'uk', 'ro'],
|
||||
@@ -504,7 +504,7 @@ class TestTranscriptDownloadDispatch(TestVideo): # lint-amnesty, pylint: disabl
|
||||
assert response.status == '404 Not Found'
|
||||
|
||||
@patch(
|
||||
'xmodule.video_block.video_handlers.get_transcript',
|
||||
'xblocks_contrib.video.video_handlers.get_transcript',
|
||||
return_value=('Subs!', 'test_filename.srt', 'application/x-subrip; charset=utf-8')
|
||||
)
|
||||
def test_download_srt_exist(self, __):
|
||||
@@ -515,7 +515,7 @@ class TestTranscriptDownloadDispatch(TestVideo): # lint-amnesty, pylint: disabl
|
||||
assert response.headers['Content-Language'] == 'en'
|
||||
|
||||
@patch(
|
||||
'xmodule.video_block.video_handlers.get_transcript',
|
||||
'xblocks_contrib.video.video_handlers.get_transcript',
|
||||
return_value=('Subs!', 'txt', 'text/plain; charset=utf-8')
|
||||
)
|
||||
def test_download_txt_exist(self, __):
|
||||
@@ -545,7 +545,6 @@ class TestTranscriptDownloadDispatch(TestVideo): # lint-amnesty, pylint: disabl
|
||||
assert response.headers['Content-Disposition'] == 'attachment; filename="en_塞.srt"'
|
||||
|
||||
@patch('openedx.core.djangoapps.video_config.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.
|
||||
|
||||
@@ -49,7 +49,8 @@ from xmodule.modulestore.tests.django_utils import TEST_DATA_SPLIT_MODULESTORE
|
||||
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 xblocks_contrib.video import bumper_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
|
||||
@@ -2323,7 +2324,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('xblocks_contrib.video.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
|
||||
@@ -2348,8 +2349,8 @@ class TestVideoWithBumper(TestVideo): # pylint: disable=test-inherits-tests
|
||||
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('xblocks_contrib.video.bumper_utils.is_bumper_enabled')
|
||||
@patch('xblocks_contrib.video.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, mock_render_django_template
|
||||
|
||||
Reference in New Issue
Block a user