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
69518652
Commit
69518652
authored
Dec 27, 2012
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add unit tests for course cloning and deleting
parent
9dff39dd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
5 deletions
+22
-5
cms/djangoapps/contentstore/tests/tests.py
+22
-5
No files found.
cms/djangoapps/contentstore/tests/tests.py
View file @
69518652
...
...
@@ -17,6 +17,7 @@ from xmodule.modulestore.store_utilities import clone_course
from
xmodule.modulestore.store_utilities
import
delete_course
from
xmodule.modulestore.django
import
modulestore
from
xmodule.contentstore.django
import
contentstore
from
xmodule.course_module
import
CourseDescriptor
def
parse_json
(
response
):
"""Parse response, which is assumed to be json"""
...
...
@@ -346,26 +347,42 @@ class ContentStoreTest(TestCase):
def
test_clone_course
(
self
):
import_from_xml
(
modulestore
(),
'common/test/data/'
,
[
'full'
])
CourseFactory
.
create
(
org
=
'edX'
,
course
=
'1001'
,
display_name
=
'Clone target'
)
resp
=
self
.
client
.
post
(
reverse
(
'create_new_course'
),
self
.
course_data
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
data
=
parse_json
(
resp
)
self
.
assertEqual
(
data
[
'id'
],
'i4x://MITx/999/course/Robot_Super_Course'
)
ms
=
modulestore
(
'direct'
)
cs
=
contentstore
()
source_location
=
CourseDescriptor
.
id_to_location
(
'edX/full/6.002_Spring_2012'
)
dest_location
=
CourseDescriptor
.
id_to_location
(
'
edX/1001/Clone_target
'
)
dest_location
=
CourseDescriptor
.
id_to_location
(
'
MITx/999/Robot_Super_Course
'
)
clone_course
(
ms
,
cs
,
source_location
,
dest_location
)
# now loop through all the units in the course and verify that the clone can render them, which
# means the objects are at least present
items
=
ms
.
get_items
(
Location
(
'edX'
,
'full'
,
'vertical'
,
None
,
None
))
items
=
ms
.
get_items
(
Location
(
[
'i4x'
,
'edX'
,
'full'
,
'vertical'
,
None
]
))
self
.
assertGreater
(
len
(
items
),
0
)
clone_items
=
ms
.
get_items
(
Location
(
'edX'
,
'1001'
,
'Clone_target'
))
clone_items
=
ms
.
get_items
(
Location
(
[
'i4x'
,
'MITx'
,
'999'
,
'vertical'
,
None
]
))
self
.
assertGreater
(
len
(
clone_items
),
0
)
for
descriptor
in
items
:
new_loc
=
descriptor
.
location
.
_
update
({
'course'
:
'1001'
}
)
new_loc
=
descriptor
.
location
.
_
replace
(
org
=
'MITx'
,
course
=
'999'
)
print
"Checking {0} should now also be at {1}"
.
format
(
descriptor
.
location
.
url
(),
new_loc
.
url
())
resp
=
self
.
client
.
get
(
reverse
(
'edit_unit'
,
kwargs
=
{
'location'
:
new_loc
.
url
()}))
self
.
assertEqual
(
resp
.
status_code
,
200
)
def
test_delete_course
(
self
):
import_from_xml
(
modulestore
(),
'common/test/data/'
,
[
'full'
])
ms
=
modulestore
(
'direct'
)
cs
=
contentstore
()
location
=
CourseDescriptor
.
id_to_location
(
'edX/full/6.002_Spring_2012'
)
delete_course
(
ms
,
cs
,
location
)
items
=
ms
.
get_items
(
Location
([
'i4x'
,
'edX'
,
'full'
,
'vertical'
,
None
]))
self
.
assertEqual
(
len
(
items
),
0
)
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