34
34
TEST_DATA_CONTENTSTORE = copy .deepcopy (settings .CONTENTSTORE )
35
35
TEST_DATA_CONTENTSTORE ['DOC_STORE_CONFIG' ]['db' ] = 'test_xcontent_%s' % uuid4 ().hex
36
36
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
+ """
38
42
39
43
SJSON_TRANSCRIPT_CONTENT = Transcript .convert (
40
44
SRT_TRANSCRIPT_CONTENT ,
@@ -160,11 +164,11 @@ def setUp(self):
160
164
self .bom_srt_file = self .create_transcript_file (content = self .contents ['good' ], suffix = '.srt' , include_bom = True )
161
165
self .good_transcript_data = {
162
166
"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. "
164
168
}
165
169
self .bad_transcript_data = {
166
170
"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. "
168
172
}
169
173
170
174
# 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):
211
215
Uploads a transcript for a video
212
216
"""
213
217
payload = {}
214
- transcript_srt = transcript_data .get ('transcript_srt' , '' )
215
218
if locator :
216
219
payload .update ({'locator' : locator })
217
220
218
221
if edx_video_id is not None :
219
222
payload .update ({'edx_video_id' : edx_video_id })
220
223
221
224
if transcript_data :
222
- payload .update ({'transcript-file' : transcript_srt })
225
+ payload .update ({'transcript-file' : transcript_data })
223
226
224
227
upload_url = reverse ('upload_transcripts' )
225
228
response = self .client .post (upload_url , payload )
@@ -247,7 +250,7 @@ def test_transcript_upload_success(self, edx_video_id, include_bom):
247
250
modulestore ().update_item (self .item , self .user .id )
248
251
249
252
# Upload a transcript
250
- transcript_data = self .good_transcript_data
253
+ transcript_data = self .good_transcript_data [ "transcript_srt" ]
251
254
response = self .upload_transcript (self .video_usage_key , transcript_data , '' )
252
255
253
256
# Verify the response
@@ -273,7 +276,7 @@ def test_transcript_upload_without_locator(self):
273
276
"""
274
277
Test that transcript upload validation fails if the video locator is missing
275
278
"""
276
- transcript_data = self .good_transcript_data
279
+ transcript_data = self .good_transcript_data [ "transcript_srt" ]
277
280
response = self .upload_transcript (locator = None , transcript_data = transcript_data , edx_video_id = '' )
278
281
self .assert_response (
279
282
response ,
@@ -304,7 +307,7 @@ def test_transcript_upload_bad_format(self):
304
307
self .assert_response (
305
308
response ,
306
309
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 .'
308
311
)
309
312
310
313
def test_transcript_upload_bad_content (self ):
@@ -320,7 +323,7 @@ def test_transcript_upload_bad_content(self):
320
323
self .assert_response (
321
324
response ,
322
325
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 .'
324
327
)
325
328
326
329
def test_transcript_upload_unknown_category (self ):
@@ -330,7 +333,7 @@ def test_transcript_upload_unknown_category(self):
330
333
# non_video module setup - i.e. an item whose category is not 'video'.
331
334
usage_key = self .create_non_video_module ()
332
335
# Request to upload transcript for the item
333
- transcript_data = self .good_transcript_data
336
+ transcript_data = self .good_transcript_data [ "transcript_srt" ]
334
337
response = self .upload_transcript (locator = usage_key , transcript_data = transcript_data , edx_video_id = '' )
335
338
self .assert_response (
336
339
response ,
@@ -343,7 +346,7 @@ def test_transcript_upload_non_existent_item(self):
343
346
Test that transcript upload validation fails in case of invalid item's locator.
344
347
"""
345
348
# Request to upload transcript for the item
346
- transcript_data = self .good_transcript_data
349
+ transcript_data = self .good_transcript_data [ "transcript_srt" ]
347
350
response = self .upload_transcript (
348
351
locator = 'non_existent_locator' ,
349
352
transcript_data = transcript_data ,
@@ -355,25 +358,13 @@ def test_transcript_upload_non_existent_item(self):
355
358
expected_message = u'Cannot find item by locator.'
356
359
)
357
360
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
-
370
361
def test_transcript_upload_with_non_existant_edx_video_id (self ):
371
362
"""
372
363
Test that transcript upload works as expected if `edx_video_id` set on
373
364
video descriptor is different from `edx_video_id` received in POST request.
374
365
"""
375
366
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" ]
377
368
# Upload with non-existant `edx_video_id`
378
369
response = self .upload_transcript (
379
370
locator = self .video_usage_key ,
@@ -383,7 +374,7 @@ def test_transcript_upload_with_non_existant_edx_video_id(self):
383
374
# Verify the response
384
375
self .assert_response (
385
376
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."
387
378
)
388
379
389
380
# Verify transcript does not exist for non-existant `edx_video_id`
0 commit comments