Commit 61e9519b by Shrhawk

Merge pull request #6709 from edx/shr/bug/TNL-1229-Burst-errors

Invalid youtube_id raise NotFoundError for transcripts
parents 175aeaf4 e2ecb0db
......@@ -104,6 +104,7 @@ class VideoStudentViewHandlers(object):
Raises:
NotFoundError if for 'en' subtitles no asset is uploaded.
NotFoundError if youtube_id does not exist / invalid youtube_id
"""
if youtube_id:
# Youtube case:
......@@ -111,7 +112,9 @@ class VideoStudentViewHandlers(object):
return Transcript.asset(self.location, youtube_id).data
youtube_ids = youtube_speed_dict(self)
assert youtube_id in youtube_ids
if youtube_id not in youtube_ids:
log.info("Youtube_id %s does not exist", youtube_id)
raise NotFoundError
try:
sjson_transcript = Transcript.asset(self.location, youtube_id, self.transcript_language).data
......
......@@ -322,6 +322,11 @@ class TestTranscriptTranslationGetDispatch(TestVideo):
response = self.item.transcript(request=request, dispatch='translation/ru')
self.assertEqual(response.status, '404 Not Found')
# Youtube_id is invalid or does not exist
request = Request.blank('/translation/uk?videoId=9855256955511225')
response = self.item.transcript(request=request, dispatch='translation/uk')
self.assertEqual(response.status, '404 Not Found')
def test_translaton_en_youtube_success(self):
subs = {"start": [10], "end": [100], "text": ["Hi, welcome to Edx."]}
good_sjson = _create_file(json.dumps(subs))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment