Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d0cd247
Deprecate Contentstore for Video Component Preview LMS/CMS
muhammad-ammar Mar 15, 2018
cda7fe9
update available translations retrieval interface
muhammad-ammar Mar 12, 2018
a6bfd5f
Deprecate Contentstore for Mobile Video Outline API
muhammad-ammar Mar 8, 2018
c5a30f8
update check_transcripts handler
muhammad-ammar Mar 20, 2018
597566a
Upload transcript to basic tab, add/fix unit and acceptance tests
Qubad786 Mar 7, 2018
9d7ed19
disable subs field syncying
muhammad-ammar Mar 20, 2018
d850fb2
Refactor download, update, choose, rename and replace handlers to use…
Qubad786 Mar 21, 2018
7afd3b6
remove sub from editable metadata fields
Qubad786 Mar 25, 2018
26a1f45
transcripts rendering on advanced tab
muhammad-ammar Mar 29, 2018
cadd437
updload/download/replace transcripts
Qubad786 Apr 1, 2018
d5758bd
delete transcript from advance tab
muhammad-ammar Mar 27, 2018
64231fd
Merge pull request #17794 from edx/ammar/EDUCATOR-1759-delete-transcr…
muhammad-ammar Apr 25, 2018
0025c28
Merge pull request #17848 from edx/mrehan/upload-transcript-advanced-tab
muhammad-ammar Apr 25, 2018
d428fa9
Merge pull request #17827 from edx/ammar/EDUCATOR-2170-transcripts-field
muhammad-ammar Apr 25, 2018
b181e6b
Update the get_transcript util with html5_sources - EDUCATOR-2651
Apr 17, 2018
1ba833f
Merge pull request #17976 from edx/mushtaq/html5_sources_transcript
Apr 25, 2018
bfbeeb1
added exception decorator
irfanuddinahmad Apr 18, 2018
f5eeec0
Merge pull request #17984 from edx/iahmad/exception_decorator
irfanuddinahmad Apr 26, 2018
aaaafee
remove video transcript enabled flag
muhammad-ammar Apr 11, 2018
16b0070
Merge pull request #17923 from edx/ammar/remove-video-transcript-enab…
muhammad-ammar Apr 30, 2018
c02955d
add check transcript ajax for edx_video_id
muhammad-ammar Apr 12, 2018
1c53360
basic tab attach uploads with edx_video_id
muhammad-ammar Apr 24, 2018
84ab9ca
address review and add test
muhammad-ammar Apr 27, 2018
b456b24
Merge pull request #18032 from edx/ammar/EDUCATOR-2761-basic-tab-uplo…
muhammad-ammar May 3, 2018
583bacf
Merge pull request #17938 from edx/ammar/add-check-transcript-ajax-on…
muhammad-ammar May 3, 2018
923897d
VAL version bump
May 4, 2018
5bd1a29
Merge pull request #18135 from edx/mushtaq/val_version_bump
May 4, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -261,22 +261,16 @@ def test_migrate_transcripts_exception_logging(self):
u'[Transcript migration] process for ge transcript started'),
(LOGGER_NAME,
'ERROR',
'[Transcript migration] Exception: u"SON(['
'(\'category\', \'asset\'), (\'name\', u\'not_found.srt\'),'
' (\'course\', u\'{}\'), (\'tag\', \'c4x\'), (\'org\', u\'{}\'),'
' (\'revision\', None)])"'.format(self.course_2.id.course, self.course_2.id.org)),
"[Transcript migration] Exception: u'No transcript for `ge` language'"),
(LOGGER_NAME,
'INFO',
u'[Transcript migration] process for course {} ended. Processed 1 transcripts'.format(
unicode(self.course_2.id)
)),
(LOGGER_NAME,
'INFO',
"[Transcript migration] Result: Failed: language ge of video test_edx_video_id_2 with exception SON(["
"('category', 'asset'), ('name', u'not_found.srt'), ('course', u'{}'),"
" ('tag', 'c4x'), ('org', u'{}'), ('revision', None)])".format(
self.course_2.id.course, self.course_2.id.org)
)
"[Transcript migration] Result: Failed: language ge of video test_edx_video_id_2 with exception "
"No transcript for `ge` language")
)

with LogCapture(LOGGER_NAME, level=logging.INFO) as logger:
Expand Down
143 changes: 102 additions & 41 deletions cms/djangoapps/contentstore/tests/test_transcripts_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ def setUpClass(cls):

@override_settings(CONTENTSTORE=TEST_DATA_CONTENTSTORE)
class TestDownloadYoutubeSubs(TestYoutubeSubsBase):
"""Tests for `download_youtube_subs` function."""
"""
Tests for `download_youtube_subs` function.
"""

org = 'MITx'
number = '999'
Expand Down Expand Up @@ -238,13 +240,6 @@ def test_success_downloading_subs(self):

mock_get.assert_any_call('http://video.google.com/timedtext', params={'lang': 'en', 'v': 'good_id_2'})

# Check asset status after import of transcript.
filename = 'subs_{0}.srt.sjson'.format(good_youtube_sub)
content_location = StaticContent.compute_location(self.course.id, filename)
self.assertTrue(contentstore().find(content_location))

self.clear_sub_content(good_youtube_sub)

def test_subs_for_html5_vid_with_periods(self):
"""
This is to verify a fix whereby subtitle files uploaded against
Expand All @@ -269,16 +264,6 @@ def test_fail_downloading_subs(self, mock_get):
with self.assertRaises(transcripts_utils.GetTranscriptsFromYouTubeException):
transcripts_utils.download_youtube_subs(bad_youtube_sub, self.course, settings)

# Check asset status after import of transcript.
filename = 'subs_{0}.srt.sjson'.format(bad_youtube_sub)
content_location = StaticContent.compute_location(
self.course.id, filename
)
with self.assertRaises(NotFoundError):
contentstore().find(content_location)

self.clear_sub_content(bad_youtube_sub)

def test_success_downloading_chinese_transcripts(self):

# Disabled 11/14/13
Expand Down Expand Up @@ -367,13 +352,6 @@ def test_downloading_subs_using_transcript_name(self, mock_get):
params={'lang': 'en', 'v': 'good_id_2', 'name': 'Custom'}
)

# Check asset status after import of transcript.
filename = 'subs_{0}.srt.sjson'.format(good_youtube_sub)
content_location = StaticContent.compute_location(self.course.id, filename)
self.assertTrue(contentstore().find(content_location))

self.clear_sub_content(good_youtube_sub)


class TestGenerateSubsFromSource(TestDownloadYoutubeSubs):
"""Tests for `generate_subs_from_source` function."""
Expand Down Expand Up @@ -766,29 +744,34 @@ def setUp(self):
edx_video_id=u'1234-5678-90'
)

def create_transcript(self, subs_id, language=u'en', filename='video.srt'):
def create_transcript(self, subs_id, language=u'en', filename='video.srt', youtube_id_1_0='', html5_sources=None):
"""
create transcript.
"""
transcripts = {}
if language != u'en':
transcripts = {language: filename}

html5_sources = html5_sources or []
self.video = ItemFactory.create(
category='video',
parent_location=self.vertical.location,
sub=subs_id,
youtube_id_1_0=youtube_id_1_0,
transcripts=transcripts,
edx_video_id=u'1234-5678-90'
edx_video_id=u'1234-5678-90',
html5_sources=html5_sources
)

if subs_id:
transcripts_utils.save_subs_to_store(
self.subs_sjson,
subs_id,
self.video,
language=language,
)
possible_subs = [subs_id, youtube_id_1_0] + transcripts_utils.get_html5_ids(html5_sources)
for possible_sub in possible_subs:
if possible_sub:
transcripts_utils.save_subs_to_store(
self.subs_sjson,
possible_sub,
self.video,
language=language,
)

def create_srt_file(self, content):
"""
Expand Down Expand Up @@ -834,31 +817,69 @@ def test_get_transcript_not_found(self, lang):
)

@ddt.data(
# video.sub transcript
{
'language': u'en',
'subs_id': 'video_101',
'filename': 'en_video_101.srt',
'youtube_id_1_0': '',
'html5_sources': [],
'expected_filename': 'en_video_101.srt',
},
# if video.sub is present, rest will be skipped.
{
'language': u'en',
'subs_id': 'video_101',
'youtube_id_1_0': 'test_yt_id',
'html5_sources': ['www.abc.com/foo.mp4'],
'expected_filename': 'en_video_101.srt',
},
# video.youtube_id_1_0 transcript
{
'language': u'en',
'subs_id': '',
'youtube_id_1_0': 'test_yt_id',
'html5_sources': [],
'expected_filename': 'en_test_yt_id.srt',
},
# video.html5_sources transcript
{
'language': u'en',
'subs_id': '',
'youtube_id_1_0': '',
'html5_sources': ['www.abc.com/foo.mp4'],
'expected_filename': 'en_foo.srt',
},
# non-english transcript
{
'language': u'ur',
'subs_id': '',
'filename': 'ur_video_101.srt',
'youtube_id_1_0': '',
'html5_sources': [],
'expected_filename': 'ur_video_101.srt',
},
)
@ddt.unpack
def test_get_transcript_from_content_store(self, language, subs_id, filename):
def test_get_transcript_from_contentstore(
self,
language,
subs_id,
youtube_id_1_0,
html5_sources,
expected_filename
):
"""
Verify that `get_transcript` function returns correct data when transcript is in content store.
"""
self.upload_file(self.create_srt_file(self.subs_srt), self.video.location, filename)
self.create_transcript(subs_id, language, filename)
content, filename, mimetype = transcripts_utils.get_transcript(
base_filename = 'video_101.srt'
self.upload_file(self.create_srt_file(self.subs_srt), self.video.location, base_filename)
self.create_transcript(subs_id, language, base_filename, youtube_id_1_0, html5_sources)
content, file_name, mimetype = transcripts_utils.get_transcript(
self.video,
language
)

self.assertEqual(content, self.subs[language])
self.assertEqual(filename, filename)
self.assertEqual(file_name, expected_filename)
self.assertEqual(mimetype, self.srt_mime_type)

def test_get_transcript_from_content_store_for_ur(self):
Expand Down Expand Up @@ -938,3 +959,43 @@ def test_get_transcript_no_en_transcript(self):

exception_message = text_type(no_en_transcript_exception.exception)
self.assertEqual(exception_message, 'No transcript for `en` language')

@ddt.data(
transcripts_utils.TranscriptsGenerationException,
UnicodeDecodeError('aliencodec', b'\x02\x01', 1, 2, 'alien codec found!')
)
@patch('xmodule.video_module.transcripts_utils.Transcript')
def test_get_transcript_val_exceptions(self, exception_to_raise, mock_Transcript):
"""
Verify that `get_transcript_from_val` function raises `NotFoundError` when specified exceptions raised.
"""
mock_Transcript.convert.side_effect = exception_to_raise
transcripts_info = self.video.get_transcripts_info()
lang = self.video.get_default_transcript_language(transcripts_info)
edx_video_id = transcripts_utils.clean_video_id(self.video.edx_video_id)
with self.assertRaises(NotFoundError):
transcripts_utils.get_transcript_from_val(
edx_video_id,
lang=lang,
output_format=transcripts_utils.Transcript.SRT
)

@ddt.data(
transcripts_utils.TranscriptsGenerationException,
UnicodeDecodeError('aliencodec', b'\x02\x01', 1, 2, 'alien codec found!')
)
@patch('xmodule.video_module.transcripts_utils.Transcript')
def test_get_transcript_content_store_exceptions(self, exception_to_raise, mock_Transcript):
"""
Verify that `get_transcript_from_contentstore` function raises `NotFoundError` when specified exceptions raised.
"""
mock_Transcript.asset.side_effect = exception_to_raise
transcripts_info = self.video.get_transcripts_info()
lang = self.video.get_default_transcript_language(transcripts_info)
with self.assertRaises(NotFoundError):
transcripts_utils.get_transcript_from_contentstore(
self.video,
language=lang,
output_format=transcripts_utils.Transcript.SRT,
transcripts_info=transcripts_info
)
Loading