3434TEST_DATA_CONTENTSTORE = copy .deepcopy (settings .CONTENTSTORE )
3535TEST_DATA_CONTENTSTORE ['DOC_STORE_CONFIG' ]['db' ] = 'test_xcontent_%s' % uuid4 ().hex
3636
37- SRT_TRANSCRIPT_CONTENT = "1\n 00:00:00,030 --> 00:00:00,030\n Hello world"
37+ SRT_TRANSCRIPT_CONTENT = """0
38+ 00:00:00,260 --> 00:00:00,260
39+ Hello, welcome to Open edX.
40+
41+ """
3842
3943SJSON_TRANSCRIPT_CONTENT = Transcript .convert (
4044 SRT_TRANSCRIPT_CONTENT ,
@@ -160,11 +164,11 @@ def setUp(self):
160164 self .bom_srt_file = self .create_transcript_file (content = self .contents ['good' ], suffix = '.srt' , include_bom = True )
161165 self .good_transcript_data = {
162166 "transcript_srt" :
163- "1 \n 00:00:00,030 --> 00:00:00,030 \n Hello world "
167+ "0 \n 00:00:00,260 --> 00:00:00,260 \n Hello, welcome to Open edX. "
164168 }
165169 self .bad_transcript_data = {
166170 "srt" :
167- "1 \n 00:00:00,030 --> 00:00:00,030 \n Hello world "
171+ "0 \n 00:00:00,260 --> 00:00:00,260 \n Hello, welcome to Open edX. "
168172 }
169173
170174 # Setup a VEDA produced video and persist `edx_video_id` in VAL.
@@ -211,15 +215,14 @@ def upload_transcript(self, locator, transcript_data, edx_video_id=None):
211215 Uploads a transcript for a video
212216 """
213217 payload = {}
214- transcript_srt = transcript_data .get ('transcript_srt' , '' )
215218 if locator :
216219 payload .update ({'locator' : locator })
217220
218221 if edx_video_id is not None :
219222 payload .update ({'edx_video_id' : edx_video_id })
220223
221224 if transcript_data :
222- payload .update ({'transcript-file' : transcript_srt })
225+ payload .update ({'transcript-file' : transcript_data })
223226
224227 upload_url = reverse ('upload_transcripts' )
225228 response = self .client .post (upload_url , payload )
@@ -247,7 +250,7 @@ def test_transcript_upload_success(self, edx_video_id, include_bom):
247250 modulestore ().update_item (self .item , self .user .id )
248251
249252 # Upload a transcript
250- transcript_data = self .good_transcript_data
253+ transcript_data = self .good_transcript_data [ "transcript_srt" ]
251254 response = self .upload_transcript (self .video_usage_key , transcript_data , '' )
252255
253256 # Verify the response
@@ -273,7 +276,7 @@ def test_transcript_upload_without_locator(self):
273276 """
274277 Test that transcript upload validation fails if the video locator is missing
275278 """
276- transcript_data = self .good_transcript_data
279+ transcript_data = self .good_transcript_data [ "transcript_srt" ]
277280 response = self .upload_transcript (locator = None , transcript_data = transcript_data , edx_video_id = '' )
278281 self .assert_response (
279282 response ,
@@ -304,7 +307,7 @@ def test_transcript_upload_bad_format(self):
304307 self .assert_response (
305308 response ,
306309 expected_status_code = 400 ,
307- expected_message = u'Transcript data misses transcript_srt field .'
310+ expected_message = u'There is a problem with this transcript file. Try to upload a different file .'
308311 )
309312
310313 def test_transcript_upload_bad_content (self ):
@@ -320,7 +323,7 @@ def test_transcript_upload_bad_content(self):
320323 self .assert_response (
321324 response ,
322325 expected_status_code = 400 ,
323- expected_message = u'Transcript data misses transcript_srt field .'
326+ expected_message = u'There is a problem with this transcript file. Try to upload a different file .'
324327 )
325328
326329 def test_transcript_upload_unknown_category (self ):
@@ -330,7 +333,7 @@ def test_transcript_upload_unknown_category(self):
330333 # non_video module setup - i.e. an item whose category is not 'video'.
331334 usage_key = self .create_non_video_module ()
332335 # Request to upload transcript for the item
333- transcript_data = self .good_transcript_data
336+ transcript_data = self .good_transcript_data [ "transcript_srt" ]
334337 response = self .upload_transcript (locator = usage_key , transcript_data = transcript_data , edx_video_id = '' )
335338 self .assert_response (
336339 response ,
@@ -343,7 +346,7 @@ def test_transcript_upload_non_existent_item(self):
343346 Test that transcript upload validation fails in case of invalid item's locator.
344347 """
345348 # Request to upload transcript for the item
346- transcript_data = self .good_transcript_data
349+ transcript_data = self .good_transcript_data [ "transcript_srt" ]
347350 response = self .upload_transcript (
348351 locator = 'non_existent_locator' ,
349352 transcript_data = transcript_data ,
@@ -355,25 +358,13 @@ def test_transcript_upload_non_existent_item(self):
355358 expected_message = u'Cannot find item by locator.'
356359 )
357360
358- def test_transcript_upload_without_edx_video_id (self ):
359- """
360- Test that transcript upload validation fails if the `edx_video_id` is missing
361- """
362- transcript_data = self .good_transcript_data
363- response = self .upload_transcript (locator = self .video_usage_key , transcript_data = transcript_data )
364- self .assert_response (
365- response ,
366- expected_status_code = 400 ,
367- expected_message = u'There is a problem with this transcript file. Try to upload a different file.'
368- )
369-
370361 def test_transcript_upload_with_non_existant_edx_video_id (self ):
371362 """
372363 Test that transcript upload works as expected if `edx_video_id` set on
373364 video descriptor is different from `edx_video_id` received in POST request.
374365 """
375366 non_existant_edx_video_id = '1111-2222-3333-4444'
376- transcript_data = self .good_transcript_data
367+ transcript_data = self .good_transcript_data [ "transcript_srt" ]
377368 # Upload with non-existant `edx_video_id`
378369 response = self .upload_transcript (
379370 locator = self .video_usage_key ,
@@ -383,7 +374,7 @@ def test_transcript_upload_with_non_existant_edx_video_id(self):
383374 # Verify the response
384375 self .assert_response (
385376 response , expected_status_code = 400 ,
386- expected_message = 'There is a problem with this transcript file. Try to upload a different file.'
377+ expected_message = "edx_video_id doesn't exist."
387378 )
388379
389380 # Verify transcript does not exist for non-existant `edx_video_id`
0 commit comments