Skip to content

Commit 4121681

Browse files
authored
test: fix/update test cases for the extracted video block (#38123)
1 parent bbc7e9b commit 4121681

4 files changed

Lines changed: 19 additions & 10 deletions

File tree

lms/djangoapps/courseware/tests/test_video_handlers.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import pytest
1111
import ddt
1212
import freezegun
13+
from django.conf import settings
1314
from django.core.files.base import ContentFile
1415
from django.utils.timezone import now
1516
from django.test import RequestFactory
@@ -47,8 +48,6 @@
4748
00:00:00,12 --> 00:00:00,100
4849
Привіт, edX вітає вас.
4950
""")
50-
51-
5251
def _create_srt_file(content=None):
5352
"""
5453
Create srt file in filesystem.
@@ -206,10 +205,17 @@ def test_handle_ajax(self):
206205
{'demoo�': 'sample'}
207206
]
208207
for sample in data:
209-
response = self.clients[self.users[0].username].post(
210-
self.get_url('save_user_state'),
211-
sample,
212-
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
208+
if settings.USE_EXTRACTED_VIDEO_BLOCK:
209+
handler_url = self.get_url('save_user_state', handler_name='ajax_handler')
210+
response = self.clients[self.users[0].username].post(
211+
handler_url,
212+
sample,
213+
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
214+
else:
215+
response = self.clients[self.users[0].username].post(
216+
self.get_url('save_user_state'),
217+
sample,
218+
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
213219
assert response.status_code == 200
214220

215221
assert self.block.speed is None

lms/djangoapps/courseware/tests/test_video_mongo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ def helper_get_html_with_edx_video_id(self, data):
931931

932932
# pylint: disable=invalid-name
933933
@patch('xblock.utils.resources.ResourceLoader.render_django_template', side_effect=mock_render_template)
934-
@patch('xmodule.video_block.video_block.rewrite_video_url')
934+
@patch(f'{VideoBlock.__module__}.rewrite_video_url')
935935
def test_get_html_cdn_source(self, mocked_get_video, mock_render_django_template):
936936
"""
937937
Test if sources got from CDN

xmodule/modulestore/tests/test_api.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ def test_get_root_module_name():
2626
Ensure the module name function works with different xblocks.
2727
"""
2828
assert get_root_module_name(LtiConsumerXBlock) == 'lti_consumer'
29-
assert get_root_module_name(VideoBlock) == 'xmodule'
29+
30+
expected_root_module = 'xblocks_contrib' if settings.USE_EXTRACTED_VIDEO_BLOCK else 'xmodule'
31+
assert get_root_module_name(VideoBlock) == expected_root_module
3032
assert get_root_module_name(DoneXBlock) == 'done'
3133

3234

xmodule/tests/test_video.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535

3636
from xmodule.tests import get_test_descriptor_system
3737
from xmodule.validation import StudioValidationMessage
38-
from xmodule.video_block import EXPORT_IMPORT_STATIC_DIR, VideoBlock, create_youtube_string
38+
from xmodule.video_block import EXPORT_IMPORT_STATIC_DIR, create_youtube_string
39+
from xmodule.video_block.video_block import _BuiltInVideoBlock as VideoBlock
3940
from openedx.core.djangoapps.video_config.transcripts_utils import save_to_store
4041
from xblock.core import XBlockAside
4142
from xmodule.modulestore.tests.test_asides import AsideTestType
@@ -319,7 +320,7 @@ def test_parse_xml(self):
319320
})
320321

321322
@XBlockAside.register_temp_plugin(AsideTestType, "test_aside")
322-
@patch('xmodule.video_block.video_block.VideoBlock.load_file')
323+
@patch('xmodule.video_block.video_block._BuiltInVideoBlock.load_file')
323324
@patch('xmodule.video_block.video_block.is_pointer_tag')
324325
@ddt.data(True, False)
325326
def test_parse_xml_with_asides(self, video_xml_has_aside, mock_is_pointer_tag, mock_load_file):

0 commit comments

Comments
 (0)