Do not override Default Video URL with value from VAL

This commit is contained in:
noraiz-anwar
2017-08-18 15:11:21 +05:00
parent 56eee715c1
commit 1203eb5835
2 changed files with 62 additions and 35 deletions

View File

@@ -1085,46 +1085,28 @@ class TestVideoDescriptorInitialization(BaseTestXmodule):
@ddt.data(
(
{
'desktop_webm': 'https://webm.com/dw.webm',
'hls': 'https://hls.com/hls.m3u8',
'youtube': 'v0TFmdO4ZP0',
'desktop_mp4': 'https://mp4.com/dm.mp4'
'hls': 'https://hls.com/hls.m3u8',
'desktop_mp4': 'https://mp4.com/dm.mp4',
'desktop_webm': 'https://webm.com/dw.webm',
},
['https://www.youtube.com/watch?v=v0TFmdO4ZP0']
),
(
{
'desktop_webm': 'https://webm.com/dw.webm',
'youtube': None,
'hls': 'https://hls.com/hls.m3u8',
'youtube': None,
'desktop_mp4': 'https://mp4.com/dm.mp4'
},
['https://hls.com/hls.m3u8']
),
(
{
'desktop_mp4': 'https://mp4.com/dm.mp4',
'desktop_webm': 'https://webm.com/dw.webm',
'hls': None,
'youtube': None,
'desktop_mp4': 'https://mp4.com/dm.mp4'
},
['https://mp4.com/dm.mp4']
['https://www.youtube.com/watch?v=3_yD_cEKoCk']
),
(
{
'desktop_webm': 'https://webm.com/dw.webm',
'hls': None,
'youtube': None,
'desktop_mp4': None
},
['https://webm.com/dw.webm']
),
(
{
'hls': None,
'desktop_mp4': None,
'desktop_webm': None,
'hls': None,
'youtube': None,
'desktop_mp4': None
},
['https://www.youtube.com/watch?v=3_yD_cEKoCk']
),
@@ -1135,6 +1117,12 @@ class TestVideoDescriptorInitialization(BaseTestXmodule):
"""
Tests that the val encodings correctly override the video url when the edx video id is set and
one or more encodings are present.
Accepted order of source priority is:
VAL's youtube source > external youtube source > hls > mp4 > webm.
Note that `https://www.youtube.com/watch?v=3_yD_cEKoCk` is the default youtube source with which
a video component is initialized. Current implementation considers this youtube source as a valid
external youtube source.
"""
with patch('xmodule.video_module.video_module.edxval_api.get_urls_for_profiles') as get_urls_for_profiles:
get_urls_for_profiles.return_value = val_video_encodings
@@ -1142,7 +1130,44 @@ class TestVideoDescriptorInitialization(BaseTestXmodule):
data='<video display_name="Video" download_video="true" edx_video_id="12345-67890">[]</video>'
)
context = self.item_descriptor.get_context()
self.assertEqual(context['transcripts_basic_tab_metadata']['video_url']['value'], video_url)
self.assertEqual(context['transcripts_basic_tab_metadata']['video_url']['value'], video_url)
@ddt.data(
(
{
'youtube': None,
'hls': 'https://hls.com/hls.m3u8',
'desktop_mp4': 'https://mp4.com/dm.mp4',
'desktop_webm': 'https://webm.com/dw.webm',
},
['https://hls.com/hls.m3u8']
),
(
{
'youtube': 'v0TFmdO4ZP0',
'hls': 'https://hls.com/hls.m3u8',
'desktop_mp4': None,
'desktop_webm': 'https://webm.com/dw.webm',
},
['https://www.youtube.com/watch?v=v0TFmdO4ZP0']
),
)
@ddt.unpack
@patch('xmodule.video_module.video_module.HLSPlaybackEnabledFlag.feature_enabled', Mock(return_value=True))
def test_val_encoding_in_context_without_external_youtube_source(self, val_video_encodings, video_url):
"""
Tests that the val encodings correctly override the video url when the edx video id is set and
one or more encodings are present. In this scenerio no external youtube source is provided.
Accepted order of source priority is:
VAL's youtube source > external youtube source > hls > mp4 > webm.
"""
with patch('xmodule.video_module.video_module.edxval_api.get_urls_for_profiles') as get_urls_for_profiles:
get_urls_for_profiles.return_value = val_video_encodings
self.initialize_module(
data='<video display_name="Video" youtube_id_1_0="" download_video="true" edx_video_id="12345-67890">[]</video>'
)
context = self.item_descriptor.get_context()
self.assertEqual(context['transcripts_basic_tab_metadata']['video_url']['value'], video_url)
@attr(shard=1)