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
28b0ba5e
Commit
28b0ba5e
authored
Aug 08, 2013
by
Vasyl Nakvasiuk
Committed by
Anton Stupak
Aug 12, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate video tests to videoalpha tests, remove video tests.
parent
4f321897
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
253 deletions
+73
-253
common/lib/xmodule/xmodule/tests/test_video_module.py
+0
-104
common/lib/xmodule/xmodule/tests/test_video_xml.py
+0
-120
lms/djangoapps/courseware/tests/test_video_mongo.py
+0
-27
lms/djangoapps/courseware/tests/test_videoalpha_xml.py
+73
-2
No files found.
common/lib/xmodule/xmodule/tests/test_video_module.py
deleted
100644 → 0
View file @
4f321897
# -*- coding: utf-8 -*-
import
unittest
from
xmodule.modulestore
import
Location
from
xmodule.video_module
import
VideoDescriptor
from
.test_import
import
DummySystem
class
VideoDescriptorImportTestCase
(
unittest
.
TestCase
):
"""
Make sure that VideoDescriptor can import an old XML-based video correctly.
"""
def
test_constructor
(
self
):
sample_xml
=
'''
<video display_name="Test Video"
youtube="1.0:p2Q6BrNhdh8,0.75:izygArpw-Qo,1.25:1EeWXzPdhSA,1.5:rABDYkeK0x8"
show_captions="false"
from="00:00:01"
to="00:01:00">
<source src="http://www.example.com/source.mp4"/>
<track src="http://www.example.com/track"/>
</video>
'''
location
=
Location
([
"i4x"
,
"edX"
,
"video"
,
"default"
,
"SampleProblem1"
])
model_data
=
{
'data'
:
sample_xml
,
'location'
:
location
}
system
=
DummySystem
(
load_error_modules
=
True
)
descriptor
=
VideoDescriptor
(
system
,
model_data
)
self
.
assertEquals
(
descriptor
.
youtube_id_0_75
,
'izygArpw-Qo'
)
self
.
assertEquals
(
descriptor
.
youtube_id_1_0
,
'p2Q6BrNhdh8'
)
self
.
assertEquals
(
descriptor
.
youtube_id_1_25
,
'1EeWXzPdhSA'
)
self
.
assertEquals
(
descriptor
.
youtube_id_1_5
,
'rABDYkeK0x8'
)
self
.
assertEquals
(
descriptor
.
show_captions
,
False
)
self
.
assertEquals
(
descriptor
.
start_time
,
1.0
)
self
.
assertEquals
(
descriptor
.
end_time
,
60
)
self
.
assertEquals
(
descriptor
.
track
,
'http://www.example.com/track'
)
self
.
assertEquals
(
descriptor
.
source
,
'http://www.example.com/source.mp4'
)
def
test_from_xml
(
self
):
module_system
=
DummySystem
(
load_error_modules
=
True
)
xml_data
=
'''
<video display_name="Test Video"
youtube="1.0:p2Q6BrNhdh8,0.75:izygArpw-Qo,1.25:1EeWXzPdhSA,1.5:rABDYkeK0x8"
show_captions="false"
from="00:00:01"
to="00:01:00">
<source src="http://www.example.com/source.mp4"/>
<track src="http://www.example.com/track"/>
</video>
'''
output
=
VideoDescriptor
.
from_xml
(
xml_data
,
module_system
)
self
.
assertEquals
(
output
.
youtube_id_0_75
,
'izygArpw-Qo'
)
self
.
assertEquals
(
output
.
youtube_id_1_0
,
'p2Q6BrNhdh8'
)
self
.
assertEquals
(
output
.
youtube_id_1_25
,
'1EeWXzPdhSA'
)
self
.
assertEquals
(
output
.
youtube_id_1_5
,
'rABDYkeK0x8'
)
self
.
assertEquals
(
output
.
show_captions
,
False
)
self
.
assertEquals
(
output
.
start_time
,
1.0
)
self
.
assertEquals
(
output
.
end_time
,
60
)
self
.
assertEquals
(
output
.
track
,
'http://www.example.com/track'
)
self
.
assertEquals
(
output
.
source
,
'http://www.example.com/source.mp4'
)
def
test_from_xml_missing_attributes
(
self
):
"""
Ensure that attributes have the right values if they aren't
explicitly set in XML.
"""
module_system
=
DummySystem
(
load_error_modules
=
True
)
xml_data
=
'''
<video display_name="Test Video"
youtube="1.0:p2Q6BrNhdh8,1.25:1EeWXzPdhSA"
show_captions="true">
<source src="http://www.example.com/source.mp4"/>
<track src="http://www.example.com/track"/>
</video>
'''
output
=
VideoDescriptor
.
from_xml
(
xml_data
,
module_system
)
self
.
assertEquals
(
output
.
youtube_id_0_75
,
''
)
self
.
assertEquals
(
output
.
youtube_id_1_0
,
'p2Q6BrNhdh8'
)
self
.
assertEquals
(
output
.
youtube_id_1_25
,
'1EeWXzPdhSA'
)
self
.
assertEquals
(
output
.
youtube_id_1_5
,
''
)
self
.
assertEquals
(
output
.
show_captions
,
True
)
self
.
assertEquals
(
output
.
start_time
,
0.0
)
self
.
assertEquals
(
output
.
end_time
,
0.0
)
self
.
assertEquals
(
output
.
track
,
'http://www.example.com/track'
)
self
.
assertEquals
(
output
.
source
,
'http://www.example.com/source.mp4'
)
def
test_from_xml_no_attributes
(
self
):
"""
Make sure settings are correct if none are explicitly set in XML.
"""
module_system
=
DummySystem
(
load_error_modules
=
True
)
xml_data
=
'<video></video>'
output
=
VideoDescriptor
.
from_xml
(
xml_data
,
module_system
)
self
.
assertEquals
(
output
.
youtube_id_0_75
,
''
)
self
.
assertEquals
(
output
.
youtube_id_1_0
,
'OEoXaMPEzfM'
)
self
.
assertEquals
(
output
.
youtube_id_1_25
,
''
)
self
.
assertEquals
(
output
.
youtube_id_1_5
,
''
)
self
.
assertEquals
(
output
.
show_captions
,
True
)
self
.
assertEquals
(
output
.
start_time
,
0.0
)
self
.
assertEquals
(
output
.
end_time
,
0.0
)
self
.
assertEquals
(
output
.
track
,
''
)
self
.
assertEquals
(
output
.
source
,
''
)
common/lib/xmodule/xmodule/tests/test_video_xml.py
deleted
100644 → 0
View file @
4f321897
# -*- coding: utf-8 -*-
"""Test for Video Xmodule functional logic.
These tests data readed from xml, not from mongo.
We have a ModuleStoreTestCase class defined in
common/lib/xmodule/xmodule/modulestore/tests/django_utils.py.
You can search for usages of this in the cms and lms tests for examples.
You use this so that it will do things like point the modulestore
setting to mongo, flush the contentstore before and after, load the
templates, etc.
You can then use the CourseFactory and XModuleItemFactory as defined in
common/lib/xmodule/xmodule/modulestore/tests/factories.py to create the
course, section, subsection, unit, etc.
"""
from
mock
import
Mock
from
xmodule.video_module
import
VideoDescriptor
,
VideoModule
,
_parse_time
,
_parse_youtube
from
xmodule.modulestore
import
Location
from
xmodule.tests
import
get_test_system
from
xmodule.tests
import
LogicTest
class
VideoFactory
(
object
):
"""A helper class to create video modules with various parameters
for testing.
"""
# tag that uses youtube videos
sample_problem_xml_youtube
=
"""
<video show_captions="true"
youtube="0.75:jNCf2gIqpeE,1.0:ZwkTiUPN0mg,1.25:rsq9auxASqI,1.50:kMyNdzVHHgg"
data_dir=""
caption_asset_path=""
autoplay="true"
from="01:00:03" to="01:00:10"
>
<source src=".../mit-3091x/M-3091X-FA12-L21-3_100.mp4"/>
</video>
"""
@staticmethod
def
create
():
"""Method return Video Xmodule instance."""
location
=
Location
([
"i4x"
,
"edX"
,
"video"
,
"default"
,
"SampleProblem1"
])
model_data
=
{
'data'
:
VideoFactory
.
sample_problem_xml_youtube
,
'location'
:
location
}
descriptor
=
Mock
(
weight
=
"1"
,
url_name
=
"SampleProblem1"
)
system
=
get_test_system
()
system
.
render_template
=
lambda
template
,
context
:
context
module
=
VideoModule
(
system
,
descriptor
,
model_data
)
return
module
class
VideoModuleLogicTest
(
LogicTest
):
"""Tests for logic of Video Xmodule."""
descriptor_class
=
VideoDescriptor
raw_model_data
=
{
'data'
:
'<video />'
}
def
test_parse_time
(
self
):
"""Ensure that times are parsed correctly into seconds."""
output
=
_parse_time
(
'00:04:07'
)
self
.
assertEqual
(
output
,
247
)
def
test_parse_time_none
(
self
):
"""Check parsing of None."""
output
=
_parse_time
(
None
)
self
.
assertEqual
(
output
,
''
)
def
test_parse_time_empty
(
self
):
"""Check parsing of the empty string."""
output
=
_parse_time
(
''
)
self
.
assertEqual
(
output
,
''
)
def
test_parse_youtube
(
self
):
"""Test parsing old-style Youtube ID strings into a dict."""
youtube_str
=
'0.75:jNCf2gIqpeE,1.00:ZwkTiUPN0mg,1.25:rsq9auxASqI,1.50:kMyNdzVHHgg'
output
=
_parse_youtube
(
youtube_str
)
self
.
assertEqual
(
output
,
{
'0.75'
:
'jNCf2gIqpeE'
,
'1.00'
:
'ZwkTiUPN0mg'
,
'1.25'
:
'rsq9auxASqI'
,
'1.50'
:
'kMyNdzVHHgg'
})
def
test_parse_youtube_one_video
(
self
):
"""
Ensure that all keys are present and missing speeds map to the
empty string.
"""
youtube_str
=
'0.75:jNCf2gIqpeE'
output
=
_parse_youtube
(
youtube_str
)
self
.
assertEqual
(
output
,
{
'0.75'
:
'jNCf2gIqpeE'
,
'1.00'
:
''
,
'1.25'
:
''
,
'1.50'
:
''
})
def
test_parse_youtube_key_format
(
self
):
"""
Make sure that inconsistent speed keys are parsed correctly.
"""
youtube_str
=
'1.00:p2Q6BrNhdh8'
youtube_str_hack
=
'1.0:p2Q6BrNhdh8'
self
.
assertEqual
(
_parse_youtube
(
youtube_str
),
_parse_youtube
(
youtube_str_hack
))
def
test_parse_youtube_empty
(
self
):
"""
Some courses have empty youtube attributes, so we should handle
that well.
"""
self
.
assertEqual
(
_parse_youtube
(
''
),
{
'0.75'
:
''
,
'1.00'
:
''
,
'1.25'
:
''
,
'1.50'
:
''
})
lms/djangoapps/courseware/tests/test_video_mongo.py
deleted
100644 → 0
View file @
4f321897
# -*- coding: utf-8 -*-
"""Video xmodule tests in mongo."""
from
.
import
BaseTestXmodule
class
TestVideo
(
BaseTestXmodule
):
"""Integration tests: web client + mongo."""
TEMPLATE_NAME
=
"video"
DATA
=
'<video youtube="0.75:JMD_ifUUfsU,1.0:OEoXaMPEzfM,1.25:AKqURZnYqpk,1.50:DYpADpL7jAY"/>'
def
test_handle_ajax_dispatch
(
self
):
responses
=
{
user
.
username
:
self
.
clients
[
user
.
username
]
.
post
(
self
.
get_url
(
'whatever'
),
{},
HTTP_X_REQUESTED_WITH
=
'XMLHttpRequest'
)
for
user
in
self
.
users
}
self
.
assertEqual
(
set
([
response
.
status_code
for
_
,
response
in
responses
.
items
()
])
.
pop
(),
404
)
lms/djangoapps/courseware/tests/test_videoalpha_xml.py
View file @
28b0ba5e
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
# pylint: disable=W0212
"""Test for VideoAlpha Xmodule functional logic.
"""Test for VideoAlpha Xmodule functional logic.
These test data read from xml, not from mongo.
These test data read from xml, not from mongo.
...
@@ -18,9 +20,10 @@ import unittest
...
@@ -18,9 +20,10 @@ import unittest
from
django.conf
import
settings
from
django.conf
import
settings
from
xmodule.videoalpha_module
import
VideoAlphaDescriptor
,
_create_youtube_string
from
xmodule.videoalpha_module
import
(
VideoAlphaDescriptor
,
_create_youtube_string
)
from
xmodule.modulestore
import
Location
from
xmodule.modulestore
import
Location
from
xmodule.tests
import
get_test_system
from
xmodule.tests
import
get_test_system
,
LogicTest
SOURCE_XML
=
"""
SOURCE_XML
=
"""
...
@@ -101,3 +104,71 @@ class VideoAlphaModuleUnitTest(unittest.TestCase):
...
@@ -101,3 +104,71 @@ class VideoAlphaModuleUnitTest(unittest.TestCase):
self
.
assertDictEqual
(
self
.
assertDictEqual
(
json
.
loads
(
module
.
get_instance_state
()),
json
.
loads
(
module
.
get_instance_state
()),
{
'position'
:
0
})
{
'position'
:
0
})
class
VideoAlphaModuleLogicTest
(
LogicTest
):
"""Tests for logic of VideoAlpha Xmodule."""
descriptor_class
=
VideoAlphaDescriptor
raw_model_data
=
{
'data'
:
'<video />'
}
def
test_parse_time
(
self
):
"""Ensure that times are parsed correctly into seconds."""
output
=
VideoAlphaDescriptor
.
_parse_time
(
'00:04:07'
)
self
.
assertEqual
(
output
,
247
)
def
test_parse_time_none
(
self
):
"""Check parsing of None."""
output
=
VideoAlphaDescriptor
.
_parse_time
(
None
)
self
.
assertEqual
(
output
,
''
)
def
test_parse_time_empty
(
self
):
"""Check parsing of the empty string."""
output
=
VideoAlphaDescriptor
.
_parse_time
(
''
)
self
.
assertEqual
(
output
,
''
)
def
test_parse_youtube
(
self
):
"""Test parsing old-style Youtube ID strings into a dict."""
youtube_str
=
'0.75:jNCf2gIqpeE,1.00:ZwkTiUPN0mg,1.25:rsq9auxASqI,1.50:kMyNdzVHHgg'
output
=
VideoAlphaDescriptor
.
_parse_youtube
(
youtube_str
)
self
.
assertEqual
(
output
,
{
'0.75'
:
'jNCf2gIqpeE'
,
'1.00'
:
'ZwkTiUPN0mg'
,
'1.25'
:
'rsq9auxASqI'
,
'1.50'
:
'kMyNdzVHHgg'
})
def
test_parse_youtube_one_video
(
self
):
"""
Ensure that all keys are present and missing speeds map to the
empty string.
"""
youtube_str
=
'0.75:jNCf2gIqpeE'
output
=
VideoAlphaDescriptor
.
_parse_youtube
(
youtube_str
)
self
.
assertEqual
(
output
,
{
'0.75'
:
'jNCf2gIqpeE'
,
'1.00'
:
''
,
'1.25'
:
''
,
'1.50'
:
''
})
def
test_parse_youtube_key_format
(
self
):
"""
Make sure that inconsistent speed keys are parsed correctly.
"""
youtube_str
=
'1.00:p2Q6BrNhdh8'
youtube_str_hack
=
'1.0:p2Q6BrNhdh8'
self
.
assertEqual
(
VideoAlphaDescriptor
.
_parse_youtube
(
youtube_str
),
VideoAlphaDescriptor
.
_parse_youtube
(
youtube_str_hack
)
)
def
test_parse_youtube_empty
(
self
):
"""
Some courses have empty youtube attributes, so we should handle
that well.
"""
self
.
assertEqual
(
VideoAlphaDescriptor
.
_parse_youtube
(
''
),
{
'0.75'
:
''
,
'1.00'
:
''
,
'1.25'
:
''
,
'1.50'
:
''
})
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