Merge pull request #6709 from edx/shr/bug/TNL-1229-Burst-errors
Invalid youtube_id raise NotFoundError for transcripts
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user