Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
193bce30
Commit
193bce30
authored
Nov 30, 2017
by
muhammad-ammar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
3f5f8a0c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
12 deletions
+49
-12
common/lib/xmodule/xmodule/video_module/video_handlers.py
+1
-1
lms/djangoapps/courseware/tests/test_video_handlers.py
+48
-11
No files found.
common/lib/xmodule/xmodule/video_module/video_handlers.py
View file @
193bce30
...
...
@@ -417,7 +417,7 @@ class VideoStudioViewHandlers(object):
for
video_id
in
video_ids
:
edxval_api
.
create_or_update_video_transcript
(
video_id
=
video_id
,
language_code
=
'en'
,
language_code
=
language
,
file_name
=
'subs.sjson'
,
# S3 filename will be `uuid.sjson` like 5d30d3e44ceb163976388cae.sjson
file_format
=
'sjson'
,
provider
=
'Custom'
,
...
...
lms/djangoapps/courseware/tests/test_video_handlers.py
View file @
193bce30
...
...
@@ -9,18 +9,22 @@ from datetime import datetime, timedelta
import
ddt
import
freezegun
from
common.test.utils
import
normalize_repr
from
mock
import
MagicMock
,
Mock
,
patch
from
nose.plugins.attrib
import
attr
from
webob
import
Request
,
Response
from
common.test.utils
import
normalize_repr
from
openedx.core.djangoapps.contentserver.caching
import
del_cached_content
from
webob
import
Request
,
Response
from
xmodule.contentstore.content
import
StaticContent
from
xmodule.contentstore.django
import
contentstore
from
xmodule.exceptions
import
NotFoundError
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.django
import
modulestore
from
xmodule.video_module.transcripts_utils
import
TranscriptException
,
TranscriptsGenerationException
from
xmodule.video_module.transcripts_utils
import
(
Transcript
,
TranscriptException
,
TranscriptsGenerationException
,
get_video_transcript_content
)
from
xmodule.x_module
import
STUDENT_VIEW
from
.helpers
import
BaseTestXmodule
...
...
@@ -30,7 +34,7 @@ TRANSCRIPT = {"start": [10], "end": [100], "text": ["Hi, welcome to Edx."]}
BUMPER_TRANSCRIPT
=
{
"start"
:
[
1
],
"end"
:
[
10
],
"text"
:
[
"A bumper"
]}
SRT_content
=
textwrap
.
dedent
(
"""
0
00:00:00,12 --> 00:00:00,100
00:00:00,
0
12 --> 00:00:00,100
Привіт, edX вітає вас.
"""
)
...
...
@@ -897,16 +901,43 @@ class TestStudioTranscriptTranslationPostDispatch(TestVideo):
METADATA
=
{}
def
assert_transcript_upload
(
self
,
item
,
subs_id
,
language
,
expected_transcript_content
):
"""
Verify that transcript is uploaded as expected.
Arguments:
item (descriptor): Video descriptor
subs_id (str): subtitle id
language (str): transcript language
expected_transcript_content (str): transcript content be checked
"""
# verify that transcript should not be in contentstore
content_location
=
StaticContent
.
compute_location
(
self
.
course
.
id
,
subs_id
)
with
self
.
assertRaises
(
NotFoundError
):
contentstore
()
.
find
(
content_location
)
# verify uploaded transcript content
transcript_data
=
get_video_transcript_content
(
language_code
=
language
,
edx_video_id
=
item
.
edx_video_id
,
youtube_id_1_0
=
item
.
youtube_id_1_0
,
html5_sources
=
item
.
html5_sources
,
)
uploaded_transcript_content
=
Transcript
.
convert
(
transcript_data
[
'content'
],
input_format
=
'sjson'
,
output_format
=
'srt'
)
self
.
assertIn
(
expected_transcript_content
.
decode
(
'utf-8'
)
.
strip
(),
uploaded_transcript_content
.
strip
())
def
test_studio_transcript_post
(
self
):
# Check for exceptons:
# Language is passed, bad content or filename:
# should be first, as other tests save transcrips to store.
request
=
Request
.
blank
(
'/translation/uk'
,
POST
=
{
'file'
:
(
'filename.srt'
,
SRT_content
)})
with
patch
(
'xmodule.video_module.video_handlers.save_to_store'
):
with
self
.
assertRaises
(
TranscriptException
):
# transcripts were not saved to store for some reason.
response
=
self
.
item_descriptor
.
studio_transcript
(
request
=
request
,
dispatch
=
'translation/uk'
)
request
=
Request
.
blank
(
'/translation/uk'
,
POST
=
{
'file'
:
(
'filename'
,
'content'
)})
with
self
.
assertRaises
(
TranscriptsGenerationException
):
# Not an srt filename
self
.
item_descriptor
.
studio_transcript
(
request
=
request
,
dispatch
=
'translation/uk'
)
...
...
@@ -932,7 +963,13 @@ class TestStudioTranscriptTranslationPostDispatch(TestVideo):
self
.
assertEqual
(
response
.
status
,
'201 Created'
)
self
.
assertDictEqual
(
json
.
loads
(
response
.
body
),
{
'filename'
:
u'filename.srt'
,
'status'
:
'Success'
})
self
.
assertDictEqual
(
self
.
item_descriptor
.
transcripts
,
{})
self
.
assertTrue
(
_check_asset
(
self
.
item_descriptor
.
location
,
u'filename.srt'
))
self
.
assert_transcript_upload
(
self
.
item_descriptor
,
'filename.srt'
,
'uk'
,
SRT_content
,
)
@attr
(
shard
=
1
)
...
...
@@ -1091,7 +1128,7 @@ class TestGetTranscript(TestVideo):
text
,
filename
,
mime_type
=
self
.
item
.
get_transcript
(
transcripts
)
expected_text
=
textwrap
.
dedent
(
"""
0
00:00:00,12 --> 00:00:00,100
00:00:00,
0
12 --> 00:00:00,100
Привіт, edX вітає вас.
"""
)
self
.
assertEqual
(
text
,
expected_text
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment