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
bdf2c286
Commit
bdf2c286
authored
Sep 19, 2014
by
zubair-arbi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update video module to always set download_video field on export
parent
3f026c1e
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
40 deletions
+15
-40
common/lib/xmodule/xmodule/tests/test_video.py
+4
-37
common/lib/xmodule/xmodule/video_module/video_module.py
+8
-0
lms/djangoapps/courseware/management/commands/tests/test_dump_course.py
+1
-1
lms/djangoapps/courseware/tests/test_video_mongo.py
+2
-2
No files found.
common/lib/xmodule/xmodule/tests/test_video.py
View file @
bdf2c286
...
@@ -202,40 +202,6 @@ class VideoDescriptorImportTestCase(unittest.TestCase):
...
@@ -202,40 +202,6 @@ class VideoDescriptorImportTestCase(unittest.TestCase):
'transcripts'
:
{
'ua'
:
'ukrainian_translation.srt'
,
'ge'
:
'german_translation.srt'
}
'transcripts'
:
{
'ua'
:
'ukrainian_translation.srt'
,
'ge'
:
'german_translation.srt'
}
})
})
def
test_constructor_for_download_video
(
self
):
"""
Test that "download_video" field is False (default value) if not explicitly set in xml
"""
sample_xml
=
'''
<video display_name="Test Video" youtube="1.0:p2Q6BrNhdh8">
<source src="http://www.example.com/source.mp4"/>
</video>
'''
descriptor
=
instantiate_descriptor
(
data
=
sample_xml
)
self
.
assert_attributes_equal
(
descriptor
,
{
'youtube_id_1_0'
:
'p2Q6BrNhdh8'
,
'download_video'
:
False
,
'html5_sources'
:
[
'http://www.example.com/source.mp4'
],
'data'
:
''
})
# Now construct video from xml with explicitly set download_video and check that
# resulting video descriptor has same value for "download_video"
sample_xml
=
'''
<video display_name="Test Video"
youtube="1.0:p2Q6BrNhdh8"
download_video="true">
<source src="http://www.example.com/source.mp4"/>
</video>
'''
descriptor
=
instantiate_descriptor
(
data
=
sample_xml
)
self
.
assert_attributes_equal
(
descriptor
,
{
'youtube_id_1_0'
:
'p2Q6BrNhdh8'
,
'download_video'
:
True
,
'html5_sources'
:
[
'http://www.example.com/source.mp4'
],
'data'
:
''
})
def
test_from_xml
(
self
):
def
test_from_xml
(
self
):
module_system
=
DummySystem
(
load_error_modules
=
True
)
module_system
=
DummySystem
(
load_error_modules
=
True
)
xml_data
=
'''
xml_data
=
'''
...
@@ -296,7 +262,7 @@ class VideoDescriptorImportTestCase(unittest.TestCase):
...
@@ -296,7 +262,7 @@ class VideoDescriptorImportTestCase(unittest.TestCase):
'track'
:
''
,
'track'
:
''
,
'handout'
:
None
,
'handout'
:
None
,
'download_track'
:
False
,
'download_track'
:
False
,
'download_video'
:
Fals
e
,
'download_video'
:
Tru
e
,
'html5_sources'
:
[
'http://www.example.com/source.mp4'
],
'html5_sources'
:
[
'http://www.example.com/source.mp4'
],
'data'
:
''
'data'
:
''
})
})
...
@@ -326,7 +292,7 @@ class VideoDescriptorImportTestCase(unittest.TestCase):
...
@@ -326,7 +292,7 @@ class VideoDescriptorImportTestCase(unittest.TestCase):
'end_time'
:
datetime
.
timedelta
(
seconds
=
0.0
),
'end_time'
:
datetime
.
timedelta
(
seconds
=
0.0
),
'track'
:
'http://www.example.com/track'
,
'track'
:
'http://www.example.com/track'
,
'download_track'
:
True
,
'download_track'
:
True
,
'download_video'
:
Fals
e
,
'download_video'
:
Tru
e
,
'html5_sources'
:
[
'http://www.example.com/source.mp4'
],
'html5_sources'
:
[
'http://www.example.com/source.mp4'
],
'data'
:
''
,
'data'
:
''
,
'transcripts'
:
{},
'transcripts'
:
{},
...
@@ -583,7 +549,8 @@ class VideoExportTestCase(VideoDescriptorTestBase):
...
@@ -583,7 +549,8 @@ class VideoExportTestCase(VideoDescriptorTestBase):
Test XML export with defaults.
Test XML export with defaults.
"""
"""
xml
=
self
.
descriptor
.
definition_to_xml
(
None
)
xml
=
self
.
descriptor
.
definition_to_xml
(
None
)
expected
=
'<video url_name="SampleProblem"/>
\n
'
# Check that download_video field is also set to default (False) in xml for backward compatibility
expected
=
'<video url_name="SampleProblem" download_video="false"/>
\n
'
self
.
assertEquals
(
expected
,
etree
.
tostring
(
xml
,
pretty_print
=
True
))
self
.
assertEquals
(
expected
,
etree
.
tostring
(
xml
,
pretty_print
=
True
))
...
...
common/lib/xmodule/xmodule/video_module/video_module.py
View file @
bdf2c286
...
@@ -230,13 +230,21 @@ class VideoDescriptor(VideoFields, VideoStudioViewHandlers, TabsEditingDescripto
...
@@ -230,13 +230,21 @@ class VideoDescriptor(VideoFields, VideoStudioViewHandlers, TabsEditingDescripto
editable_fields
=
super
(
VideoDescriptor
,
self
)
.
editable_metadata_fields
editable_fields
=
super
(
VideoDescriptor
,
self
)
.
editable_metadata_fields
self
.
source_visible
=
False
self
.
source_visible
=
False
# Set download_video field to default value if its not explicitly set for backward compatibility.
download_video
=
editable_fields
[
'download_video'
]
if
not
download_video
[
'explicitly_set'
]:
self
.
download_video
=
self
.
download_video
if
self
.
source
:
if
self
.
source
:
# If `source` field value exist in the `html5_sources` field values,
# If `source` field value exist in the `html5_sources` field values,
# then delete `source` field value and use value from `html5_sources` field.
# then delete `source` field value and use value from `html5_sources` field.
if
self
.
source
in
self
.
html5_sources
:
if
self
.
source
in
self
.
html5_sources
:
self
.
source
=
''
# Delete source field value.
self
.
source
=
''
# Delete source field value.
self
.
download_video
=
True
else
:
# Otherwise, `source` field value will be used.
else
:
# Otherwise, `source` field value will be used.
self
.
source_visible
=
True
self
.
source_visible
=
True
if
not
download_video
[
'explicitly_set'
]:
self
.
download_video
=
True
# for backward compatibility.
# for backward compatibility.
# If course was existed and was not re-imported by the moment of adding `download_track` field,
# If course was existed and was not re-imported by the moment of adding `download_track` field,
...
...
lms/djangoapps/courseware/management/commands/tests/test_dump_course.py
View file @
bdf2c286
...
@@ -104,7 +104,7 @@ class CommandsTestBase(TestCase):
...
@@ -104,7 +104,7 @@ class CommandsTestBase(TestCase):
video_id
=
test_course_key
.
make_usage_key
(
'video'
,
'Welcome'
)
.
to_deprecated_string
()
video_id
=
test_course_key
.
make_usage_key
(
'video'
,
'Welcome'
)
.
to_deprecated_string
()
self
.
assertEqual
(
dump
[
video_id
][
'category'
],
'video'
)
self
.
assertEqual
(
dump
[
video_id
][
'category'
],
'video'
)
self
.
assertEqual
(
len
(
dump
[
video_id
][
'metadata'
]),
4
)
self
.
assertEqual
(
len
(
dump
[
video_id
][
'metadata'
]),
5
)
self
.
assertIn
(
'youtube_id_1_0'
,
dump
[
video_id
][
'metadata'
])
self
.
assertIn
(
'youtube_id_1_0'
,
dump
[
video_id
][
'metadata'
])
# Check if there are the right number of elements
# Check if there are the right number of elements
...
...
lms/djangoapps/courseware/tests/test_video_mongo.py
View file @
bdf2c286
...
@@ -487,7 +487,7 @@ class TestVideoDescriptorInitialization(BaseTestXmodule):
...
@@ -487,7 +487,7 @@ class TestVideoDescriptorInitialization(BaseTestXmodule):
self
.
assertIn
(
'source'
,
fields
)
self
.
assertIn
(
'source'
,
fields
)
self
.
assertEqual
(
self
.
item_descriptor
.
source
,
'http://example.org/video.mp4'
)
self
.
assertEqual
(
self
.
item_descriptor
.
source
,
'http://example.org/video.mp4'
)
self
.
assert
Fals
e
(
self
.
item_descriptor
.
download_video
)
self
.
assert
Tru
e
(
self
.
item_descriptor
.
download_video
)
self
.
assertTrue
(
self
.
item_descriptor
.
source_visible
)
self
.
assertTrue
(
self
.
item_descriptor
.
source_visible
)
def
test_source_in_html5sources
(
self
):
def
test_source_in_html5sources
(
self
):
...
@@ -500,7 +500,7 @@ class TestVideoDescriptorInitialization(BaseTestXmodule):
...
@@ -500,7 +500,7 @@ class TestVideoDescriptorInitialization(BaseTestXmodule):
fields
=
self
.
item_descriptor
.
editable_metadata_fields
fields
=
self
.
item_descriptor
.
editable_metadata_fields
self
.
assertNotIn
(
'source'
,
fields
)
self
.
assertNotIn
(
'source'
,
fields
)
self
.
assert
Fals
e
(
self
.
item_descriptor
.
download_video
)
self
.
assert
Tru
e
(
self
.
item_descriptor
.
download_video
)
self
.
assertFalse
(
self
.
item_descriptor
.
source_visible
)
self
.
assertFalse
(
self
.
item_descriptor
.
source_visible
)
def
test_download_video_is_explicitly_set
(
self
):
def
test_download_video_is_explicitly_set
(
self
):
...
...
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