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
d0e3f99e
Commit
d0e3f99e
authored
Jun 03, 2013
by
Vasyl Nakvasiuk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BaseTestXmodule: create module on the fly
parent
45e32107
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
7 deletions
+18
-7
lms/djangoapps/courseware/tests/__init__.py
+16
-5
lms/djangoapps/courseware/tests/test_video_xml.py
+2
-2
No files found.
lms/djangoapps/courseware/tests/__init__.py
View file @
d0e3f99e
...
...
@@ -13,6 +13,7 @@ from django.test.client import Client
from
student.tests.factories
import
UserFactory
,
CourseEnrollmentFactory
from
courseware.tests.tests
import
TEST_DATA_MONGO_MODULESTORE
from
xmodule.tests
import
test_system
from
xmodule.modulestore
import
Location
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
...
...
@@ -30,7 +31,8 @@ class BaseTestXmodule(ModuleStoreTestCase):
Any xmodule should overwrite only next parameters for test:
1. TEMPLATE_NAME
2. DATA
3. COURSE_DATA and USER_COUNT if needed
3. MODEL_DATA
4. COURSE_DATA and USER_COUNT if needed
This class should not contain any tests, because TEMPLATE_NAME
should be defined in child class.
...
...
@@ -40,7 +42,8 @@ class BaseTestXmodule(ModuleStoreTestCase):
# Data from YAML common/lib/xmodule/xmodule/templates/NAME/default.yaml
TEMPLATE_NAME
=
""
DATA
=
{}
DATA
=
''
MODEL_DATA
=
{
'data'
:
'<some_module></some_module>'
}
def
setUp
(
self
):
...
...
@@ -68,12 +71,20 @@ class BaseTestXmodule(ModuleStoreTestCase):
for
user
in
self
.
users
:
CourseEnrollmentFactory
.
create
(
user
=
user
,
course_id
=
self
.
course
.
id
)
item
=
ItemFactory
.
create
(
self
.
item_descriptor
=
ItemFactory
.
create
(
parent_location
=
section
.
location
,
template
=
self
.
TEMPLATE_NAME
,
data
=
self
.
DATA
)
self
.
item_url
=
Location
(
item
.
location
)
.
url
()
location
=
self
.
item_descriptor
.
location
system
=
test_system
()
system
.
render_template
=
lambda
template
,
context
:
context
self
.
item_module
=
self
.
item_descriptor
.
module_class
(
system
,
location
,
self
.
item_descriptor
,
self
.
MODEL_DATA
)
self
.
item_url
=
Location
(
location
)
.
url
()
# login all users for acces to Xmodule
self
.
clients
=
{
user
.
username
:
Client
()
for
user
in
self
.
users
}
...
...
@@ -86,7 +97,7 @@ class BaseTestXmodule(ModuleStoreTestCase):
self
.
assertTrue
(
all
(
self
.
login_statuses
))
def
get_url
(
self
,
dispatch
):
"""Return
word cloud
url with dispatch."""
"""Return
item
url with dispatch."""
return
reverse
(
'modx_dispatch'
,
args
=
(
self
.
course
.
id
,
self
.
item_url
,
dispatch
)
...
...
lms/djangoapps/courseware/tests/test_video_xml.py
View file @
d0e3f99e
...
...
@@ -46,7 +46,7 @@ class VideoFactory(object):
def
create
():
"""Method return Video Xmodule instance."""
location
=
Location
([
"i4x"
,
"edX"
,
"video"
,
"default"
,
"SampleProblem
{0}"
.
format
(
1
)
])
"SampleProblem
1"
])
model_data
=
{
'data'
:
VideoFactory
.
sample_problem_xml_youtube
}
descriptor
=
Mock
(
weight
=
"1"
)
...
...
@@ -107,7 +107,7 @@ class VideoModuleUnitTest(unittest.TestCase):
'track'
:
None
,
'show_captions'
:
'true'
,
'display_name'
:
'SampleProblem1'
,
'id'
:
'i4x-edX-video-default-SampleProblem1'
,
'id'
:
module
.
location
.
html_id
()
,
'end'
:
3610.0
,
'caption_asset_path'
:
'/static/subs/'
,
'source'
:
'.../mit-3091x/M-3091X-FA12-L21-3_100.mp4'
,
...
...
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