Fix failing test and update docstrings for video player
Fixes BLD-1115
This commit is contained in:
@@ -25,7 +25,7 @@ from django.conf import settings
|
||||
from xblock.fields import ScopeIds
|
||||
from xblock.runtime import KvsFieldData
|
||||
|
||||
from xmodule.modulestore.inheritance import InheritanceKeyValueStore
|
||||
from xmodule.modulestore.inheritance import InheritanceKeyValueStore, own_metadata
|
||||
from xmodule.x_module import XModule, module_attr
|
||||
from xmodule.editing_module import TabsEditingDescriptor
|
||||
from xmodule.raw_module import EmptyDataRawDescriptor
|
||||
@@ -231,14 +231,34 @@ class VideoDescriptor(VideoFields, VideoStudioViewHandlers, TabsEditingDescripto
|
||||
|
||||
def editor_saved(self, user, old_metadata, old_content):
|
||||
"""
|
||||
Used to update video subtitles.
|
||||
Used to update video values during `self`:save method from CMS.
|
||||
|
||||
old_metadata: dict, values of fields of `self` with scope=settings which were explicitly set by user.
|
||||
old_content, same as `old_metadata` but for scope=content.
|
||||
|
||||
Due to nature of code flow in item.py::_save_item, before current function is called,
|
||||
fields of `self` instance have been already updated, but not yet saved.
|
||||
|
||||
To obtain values, which were changed by user input,
|
||||
one should compare own_metadata(self) and old_medatada.
|
||||
|
||||
Video player has two tabs, and due to nature of sync between tabs,
|
||||
metadata from Basic tab is always sent when video player is edited and saved first time, for example:
|
||||
{'youtube_id_1_0': u'OEoXaMPEzfM', 'display_name': u'Video', 'sub': u'OEoXaMPEzfM', 'html5_sources': []},
|
||||
that's why these fields will always present in old_metadata after first save. This should be fixed.
|
||||
|
||||
At consequent save requests html5_sources are always sent too, disregard of their change by user.
|
||||
That means that html5_sources are always in list of fields that were changed (`metadata` param in save_item).
|
||||
This should be fixed too.
|
||||
"""
|
||||
manage_video_subtitles_save(
|
||||
self,
|
||||
user,
|
||||
old_metadata if old_metadata else None,
|
||||
generate_translation=True
|
||||
)
|
||||
metadata_was_changed_by_user = old_metadata != own_metadata(self)
|
||||
if metadata_was_changed_by_user:
|
||||
manage_video_subtitles_save(
|
||||
self,
|
||||
user,
|
||||
old_metadata if old_metadata else None,
|
||||
generate_translation=True
|
||||
)
|
||||
|
||||
def save_with_metadata(self, user):
|
||||
"""
|
||||
|
||||
@@ -777,8 +777,8 @@ class XModuleDescriptor(XModuleMixin, HTMLSnippet, ResourceTemplates, XBlock):
|
||||
|
||||
Note that after this method is called, the modulestore update_item method will
|
||||
be called on this xmodule. Therefore, any modifications to the xmodule that are
|
||||
performed in editor_saved will automatically be persisted (implementors of this method
|
||||
should not call update_item themselves).
|
||||
performed in editor_saved will automatically be persisted (calling update_item
|
||||
from implementors of this method is not necessary).
|
||||
|
||||
Args:
|
||||
user: the user who requested the save (as obtained from the request)
|
||||
|
||||
@@ -267,7 +267,6 @@ class YouTubeVideoTest(VideoBaseTest):
|
||||
unicode_text = "好 各位同学".decode('utf-8')
|
||||
self.assertIn(unicode_text, self.video.captions_text())
|
||||
|
||||
@skip("Failing Intermittently in master. BLD-1115")
|
||||
def test_cc_button_transcripts_and_sub_fields_empty(self):
|
||||
"""
|
||||
Scenario: CC button works correctly if transcripts and sub fields are empty,
|
||||
@@ -276,8 +275,9 @@ class YouTubeVideoTest(VideoBaseTest):
|
||||
And I have uploaded a .srt.sjson file to assets
|
||||
Then I see the correct english text in the captions
|
||||
"""
|
||||
self.assets.append('subs_OEoXaMPEzfM.srt.sjson')
|
||||
self.navigate_to_video()
|
||||
self._install_course_fixture()
|
||||
self.course_fixture._upload_assets(['subs_OEoXaMPEzfM.srt.sjson'])
|
||||
self._navigate_to_courseware_video_and_render()
|
||||
self.video.show_captions()
|
||||
|
||||
# Verify that we see "Hi, welcome to Edx." text in the captions
|
||||
|
||||
Reference in New Issue
Block a user