edx-videoi-id strip fix
LEARNER-1871
This commit is contained in:
committed by
muzaffaryousaf
parent
a0da9b895c
commit
edcd64e90f
@@ -304,16 +304,20 @@ class VideoModule(VideoFields, VideoTranscriptsMixin, VideoStudentViewHandlers,
|
||||
if xblock_settings and 'YOUTUBE_API_KEY' in xblock_settings:
|
||||
yt_api_key = xblock_settings['YOUTUBE_API_KEY']
|
||||
|
||||
poster = None
|
||||
if edxval_api and self.edx_video_id:
|
||||
poster = edxval_api.get_course_video_image_url(
|
||||
course_id=self.runtime.course_id.for_branch(None),
|
||||
edx_video_id=self.edx_video_id.strip()
|
||||
)
|
||||
|
||||
metadata = {
|
||||
'saveStateUrl': self.system.ajax_url + '/save_user_state',
|
||||
'autoplay': settings.FEATURES.get('AUTOPLAY_VIDEOS', False),
|
||||
'streams': self.youtube_streams,
|
||||
'sub': self.sub,
|
||||
'sources': sources,
|
||||
'poster': edxval_api and edxval_api.get_course_video_image_url(
|
||||
course_id=self.runtime.course_id.for_branch(None),
|
||||
edx_video_id=self.edx_video_id.strip()
|
||||
),
|
||||
'poster': poster,
|
||||
# This won't work when we move to data that
|
||||
# isn't on the filesystem
|
||||
'captionDataDir': getattr(self, 'data_dir', None),
|
||||
@@ -508,7 +512,7 @@ class VideoDescriptor(VideoFields, VideoTranscriptsMixin, VideoStudioViewHandler
|
||||
break
|
||||
|
||||
if metadata_was_changed_by_user:
|
||||
self.edx_video_id = self.edx_video_id.strip()
|
||||
self.edx_video_id = self.edx_video_id and self.edx_video_id.strip()
|
||||
|
||||
# We want to override `youtube_id_1_0` with val youtube profile in the first place when someone adds/edits
|
||||
# an `edx_video_id` or its underlying YT val profile. Without this, override will only happen when a user
|
||||
|
||||
@@ -934,6 +934,19 @@ class TestGetHtmlMethod(BaseTestXmodule):
|
||||
|
||||
self.assertIn('"poster": "/media/video-images/poster.png"', context)
|
||||
|
||||
@patch('xmodule.video_module.video_module.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.
|
||||
"""
|
||||
video_xml = '<video display_name="Video" download_video="true" edx_video_id="null">[]</video>'
|
||||
get_course_video_image_url.return_value = '/media/video-images/poster.png'
|
||||
|
||||
self.initialize_module(data=video_xml)
|
||||
context = self.item_descriptor.render(STUDENT_VIEW).content
|
||||
|
||||
self.assertIn("\'poster\': \'null\'", context)
|
||||
|
||||
|
||||
@attr(shard=1)
|
||||
class TestVideoCDNRewriting(BaseTestXmodule):
|
||||
|
||||
Reference in New Issue
Block a user