Commit 5d34bb0d by Shrhawk

Merge pull request #6859 from edx/shr/bug/TNL-1253-mobile-api-transcript-filname-unicode

Unicode handling for transcript filename
parents e8a1e810 7b194a33
# -*- coding: utf-8 -*-
"""
Tests for video outline API
"""
......@@ -100,11 +101,11 @@ class TestVideoAPITestCase(MobileAPITestCase):
}
]})
def _create_video_with_subs(self):
def _create_video_with_subs(self, custom_subid=None):
"""
Creates and returns a video with stored subtitles.
"""
subid = uuid4().hex
subid = custom_subid or uuid4().hex
transcripts_utils.save_subs_to_store(
{
'start': [100, 200, 240, 390, 1000],
......@@ -578,3 +579,8 @@ class TestTranscriptsDetail(TestVideoAPITestCase, MobileAuthTestMixin, MobileEnr
def test_incorrect_language(self):
self.login_and_enroll()
self.api_response(expected_response_code=404, lang='pl')
def test_transcript_with_unicode_file_name(self):
self.video = self._create_video_with_subs(custom_subid=u'你好')
self.login_and_enroll()
self.api_response(expected_response_code=200, lang='en')
......@@ -121,6 +121,6 @@ class VideoTranscripts(generics.RetrieveAPIView):
raise Http404(u"Transcript not found for {}, lang: {}".format(block_id, lang))
response = HttpResponse(content, content_type=mimetype)
response['Content-Disposition'] = 'attachment; filename="{}"'.format(filename)
response['Content-Disposition'] = 'attachment; filename="{}"'.format(filename.encode('utf-8'))
return response
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