def test_download_transcript_handler_response_object(self, get_mock, get_filename_mock):
"""
Test transcripts downloading works properly.
"""
# Arrange
get_filename_mock.return_value = 'transcript.vtt'
get_mock.return_value.text = 'vtt transcripts'
request_mock = MagicMock()
request_mock.host_url = 'test.host'
request_mock.query_string = '/test-query-string'
# Act
vtt_response = self.xblock.download_transcript(request_mock, 'unused suffix')
# Assert
self.assertIsInstance(vtt_response, Response)
self.assertEqual(vtt_response.text, 'vtt transcripts')
self.assertEqual(vtt_response.headerlist, [
('Content-Type', 'text/plain'),
('Content-Disposition', 'attachment; filename={}'.format('transcript.vtt'))
])
get_mock.assert_called_once_with('test.host/test-query-string')
评论列表
文章目录