Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
d5cee7b3
Commit
d5cee7b3
authored
9 years ago
by
sanfordstudent
Browse files
Options
Downloads
Plain Diff
Merge pull request #11471 from edx/sstudent/MA-1881-null-translation-check
ma-1881 handling empty translations and testing
parents
fb45a6f3
24c4c8ab
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
common/lib/xmodule/xmodule/tests/test_video.py
+35
-0
35 additions, 0 deletions
common/lib/xmodule/xmodule/tests/test_video.py
common/lib/xmodule/xmodule/video_module/transcripts_utils.py
+9
-8
9 additions, 8 deletions
common/lib/xmodule/xmodule/video_module/transcripts_utils.py
with
44 additions
and
8 deletions
common/lib/xmodule/xmodule/tests/test_video.py
+
35
−
0
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
'
])
This diff is collapsed.
Click to expand it.
common/lib/xmodule/xmodule/video_module/transcripts_utils.py
+
9
−
8
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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment