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
d5cee7b3
Commit
d5cee7b3
authored
Feb 10, 2016
by
sanfordstudent
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11471 from edx/sstudent/MA-1881-null-translation-check
ma-1881 handling empty translations and testing
parents
fb45a6f3
24c4c8ab
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
8 deletions
+44
-8
common/lib/xmodule/xmodule/tests/test_video.py
+35
-0
common/lib/xmodule/xmodule/video_module/transcripts_utils.py
+9
-8
No files found.
common/lib/xmodule/xmodule/tests/test_video.py
View file @
d5cee7b3
...
...
@@ -920,3 +920,38 @@ class VideoDescriptorIndexingTestCase(unittest.TestCase):
},
"content_type"
:
"Video"
})
def
test_video_with_multiple_transcripts_translation_retrieval
(
self
):
"""
Test translation retrieval of a video module with
multiple transcripts uploaded by a user.
"""
xml_data_transcripts
=
'''
<video display_name="Test Video"
youtube="1.0:p2Q6BrNhdh8,0.75:izygArpw-Qo,1.25:1EeWXzPdhSA,1.5:rABDYkeK0x8"
show_captions="false"
download_track="false"
start_time="00:00:01"
download_video="false"
end_time="00:01:00">
<source src="http://www.example.com/source.mp4"/>
<track src="http://www.example.com/track"/>
<handout src="http://www.example.com/handout"/>
<transcript language="ge" src="subs_grmtran1.srt" />
<transcript language="hr" src="subs_croatian1.srt" />
</video>
'''
descriptor
=
instantiate_descriptor
(
data
=
xml_data_transcripts
)
translations
=
descriptor
.
available_translations
(
descriptor
.
get_transcripts_info
(),
verify_assets
=
False
)
self
.
assertEqual
(
translations
,
[
'hr'
,
'ge'
])
def
test_video_with_no_transcripts_translation_retrieval
(
self
):
"""
Test translation retrieval of a video module with
no transcripts uploaded by a user- ie, that retrieval
does not throw an exception.
"""
descriptor
=
instantiate_descriptor
(
data
=
None
)
translations
=
descriptor
.
available_translations
(
descriptor
.
get_transcripts_info
(),
verify_assets
=
False
)
self
.
assertEqual
(
translations
,
[
'en'
])
common/lib/xmodule/xmodule/video_module/transcripts_utils.py
View file @
d5cee7b3
...
...
@@ -569,14 +569,15 @@ class VideoTranscriptsMixin(object):
Defaults to False
"""
translations
=
[]
sub
,
other_lang
=
transcripts
[
"sub"
],
transcripts
[
"transcripts"
]
sub
,
other_lang
s
=
transcripts
[
"sub"
],
transcripts
[
"transcripts"
]
# If we're not verifying the assets, we just trust our field values
if
not
verify_assets
:
translations
=
list
(
other_lang
)
if
other_langs
:
translations
=
list
(
other_langs
)
if
not
translations
or
sub
:
translations
+=
[
'en'
]
return
set
(
translations
)
return
translations
# If we've gotten this far, we're going to verify that the transcripts
# being referenced are actually in the contentstore.
...
...
@@ -589,16 +590,16 @@ class VideoTranscriptsMixin(object):
except
NotFoundError
:
pass
else
:
translations
=
[
'en'
]
translations
+
=
[
'en'
]
else
:
translations
=
[
'en'
]
translations
+
=
[
'en'
]
for
lang
in
other_lang
:
for
lang
in
other_lang
s
:
try
:
Transcript
.
asset
(
self
.
location
,
None
,
None
,
other_lang
[
lang
])
Transcript
.
asset
(
self
.
location
,
None
,
None
,
other_lang
s
[
lang
])
except
NotFoundError
:
continue
translations
.
append
(
lang
)
translations
+=
[
lang
]
return
translations
...
...
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