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
e982d7fc
Commit
e982d7fc
authored
Jun 04, 2013
by
Peter Fogg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor test_contenstore to remove code duplication.
parent
266938a7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
24 deletions
+23
-24
cms/djangoapps/contentstore/tests/test_contentstore.py
+23
-24
No files found.
cms/djangoapps/contentstore/tests/test_contentstore.py
View file @
e982d7fc
...
...
@@ -77,14 +77,25 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
self
.
client
=
Client
()
self
.
client
.
login
(
username
=
uname
,
password
=
password
)
def
test_advanced_components_in_edit_unit
(
self
):
def
check_components_on_page
(
self
,
component_types
,
expected_types
):
"""
Ensure that the right types end up on the page.
component_types is the list of advanced components.
expected_types is the list of elements that should appear on the page.
expected_types and component_types should be similar, but not
exactly the same -- for example, 'videoalpha' in
component_types should cause 'Video Alpha' to be present.
"""
store
=
modulestore
(
'direct'
)
import_from_xml
(
store
,
'common/test/data/'
,
[
'simple'
])
course
=
store
.
get_item
(
Location
([
'i4x'
,
'edX'
,
'simple'
,
'course'
,
'2012_Fall'
,
None
]),
depth
=
None
)
course
.
advanced_modules
=
ADVANCED_COMPONENT_TYPES
course
.
advanced_modules
=
component_types
store
.
update_metadata
(
course
.
location
,
own_metadata
(
course
))
...
...
@@ -94,32 +105,20 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
resp
=
self
.
client
.
get
(
reverse
(
'edit_unit'
,
kwargs
=
{
'location'
:
descriptor
.
location
.
url
()}))
self
.
assertEqual
(
resp
.
status_code
,
200
)
for
expected
in
expected_types
:
self
.
assertIn
(
expected
,
resp
.
content
)
def
test_advanced_components_in_edit_unit
(
self
):
# This could be made better, but for now let's just assert that we see the advanced modules mentioned in the page
# response HTML
self
.
assertIn
(
'Video Alpha'
,
resp
.
content
)
self
.
assertIn
(
'Word cloud'
,
resp
.
content
)
self
.
assertIn
(
'Annotation'
,
resp
.
content
)
self
.
assertIn
(
'Open Ended Response'
,
resp
.
content
)
self
.
assertIn
(
'Peer Grading Interface'
,
resp
.
content
)
self
.
check_components_on_page
(
ADVANCED_COMPONENT_TYPES
,
[
'Video Alpha'
,
'Word cloud'
,
'Annotation'
,
'Open Ended Response'
,
'Peer Grading Interface'
]
)
def
test_advanced_components_require_two_clicks
(
self
):
store
=
modulestore
(
'direct'
)
import_from_xml
(
store
,
'common/test/data/'
,
[
'simple'
])
course
=
store
.
get_item
(
Location
([
'i4x'
,
'edX'
,
'simple'
,
'course'
,
'2012_Fall'
,
None
]),
depth
=
None
)
# Just add one advanced module to make sure that it does show templates even if there's only one.
course
.
advanced_modules
=
[
'videoalpha'
]
store
.
update_metadata
(
course
.
location
,
own_metadata
(
course
))
descriptor
=
store
.
get_items
(
Location
(
'i4x'
,
'edX'
,
'simple'
,
'vertical'
,
None
,
None
))[
0
]
resp
=
self
.
client
.
get
(
reverse
(
'edit_unit'
,
kwargs
=
{
'location'
:
descriptor
.
location
.
url
()}))
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertIn
(
'Video Alpha'
,
resp
.
content
)
self
.
check_components_on_page
([
'videoalpha'
],
[
'Video Alpha'
])
def
check_edit_unit
(
self
,
test_course_name
):
import_from_xml
(
modulestore
(
'direct'
),
'common/test/data/'
,
[
test_course_name
])
...
...
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