Catch exception if for en no default subs is uploaded.
This commit is contained in:
@@ -342,7 +342,7 @@ class VideoModule(VideoFields, XModule):
|
||||
|
||||
try:
|
||||
transcript = self.translation(request.GET.get('videoId'))
|
||||
except TranscriptException as ex:
|
||||
except (TranscriptException, NotFoundError) as ex:
|
||||
log.info(ex.message)
|
||||
response = Response(status=404)
|
||||
else:
|
||||
@@ -414,6 +414,9 @@ class VideoModule(VideoFields, XModule):
|
||||
Filenames naming:
|
||||
en: subs_videoid.srt.sjson
|
||||
non_en: uk_subs_videoid.srt.sjson
|
||||
|
||||
Raises:
|
||||
NotFoundError if for 'en' subtitles no asset is uploaded.
|
||||
"""
|
||||
if self.transcript_language == 'en':
|
||||
return asset(self.location, subs_id).data
|
||||
|
||||
@@ -161,6 +161,8 @@ class TestVideoTranscriptTranslation(TestVideo):
|
||||
self.item_descriptor.render('student_view')
|
||||
self.item = self.item_descriptor.xmodule_runtime.xmodule_instance
|
||||
|
||||
# Tests for `download` dispatch:
|
||||
|
||||
def test_language_is_not_supported(self):
|
||||
request = Request.blank('/download?language=ru')
|
||||
response = self.item.transcript(request=request, dispatch='download')
|
||||
@@ -177,6 +179,15 @@ class TestVideoTranscriptTranslation(TestVideo):
|
||||
response = self.item.transcript(request=request, dispatch='download')
|
||||
self.assertEqual(response.body, 'Subs!')
|
||||
|
||||
def test_download_en_no_sub(self):
|
||||
request = Request.blank('/download?language=en')
|
||||
response = self.item.transcript(request=request, dispatch='download')
|
||||
self.assertEqual(response.status, '404 Not Found')
|
||||
with self.assertRaises(NotFoundError):
|
||||
self.item.get_transcript()
|
||||
|
||||
# Tests for `translation` dispatch:
|
||||
|
||||
def test_translation_fails(self):
|
||||
# No videoId
|
||||
request = Request.blank('/translation?language=ru')
|
||||
|
||||
Reference in New Issue
Block a user