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
3fa425c5
Commit
3fa425c5
authored
Dec 27, 2012
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add unit test for import->export->import simple flow
parent
62523760
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
0 deletions
+34
-0
cms/djangoapps/contentstore/tests/tests.py
+34
-0
No files found.
cms/djangoapps/contentstore/tests/tests.py
View file @
3fa425c5
import
json
import
json
import
shutil
from
django.test
import
TestCase
from
django.test
import
TestCase
from
django.test.client
import
Client
from
django.test.client
import
Client
from
override_settings
import
override_settings
from
override_settings
import
override_settings
from
django.conf
import
settings
from
django.conf
import
settings
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
from
path
import
path
from
path
import
path
from
tempfile
import
mkdtemp
from
student.models
import
Registration
from
student.models
import
Registration
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
...
@@ -18,6 +20,7 @@ from xmodule.modulestore.store_utilities import delete_course
...
@@ -18,6 +20,7 @@ from xmodule.modulestore.store_utilities import delete_course
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.django
import
modulestore
from
xmodule.contentstore.django
import
contentstore
from
xmodule.contentstore.django
import
contentstore
from
xmodule.course_module
import
CourseDescriptor
from
xmodule.course_module
import
CourseDescriptor
from
xmodule.modulestore.xml_exporter
import
export_to_xml
def
parse_json
(
response
):
def
parse_json
(
response
):
"""Parse response, which is assumed to be json"""
"""Parse response, which is assumed to be json"""
...
@@ -385,4 +388,35 @@ class ContentStoreTest(TestCase):
...
@@ -385,4 +388,35 @@ class ContentStoreTest(TestCase):
items
=
ms
.
get_items
(
Location
([
'i4x'
,
'edX'
,
'full'
,
'vertical'
,
None
]))
items
=
ms
.
get_items
(
Location
([
'i4x'
,
'edX'
,
'full'
,
'vertical'
,
None
]))
self
.
assertEqual
(
len
(
items
),
0
)
self
.
assertEqual
(
len
(
items
),
0
)
def
test_export_course
(
self
):
ms
=
modulestore
(
'direct'
)
cs
=
contentstore
()
import_from_xml
(
ms
,
'common/test/data/'
,
[
'full'
])
location
=
CourseDescriptor
.
id_to_location
(
'edX/full/6.002_Spring_2012'
)
root_dir
=
path
(
mkdtemp
())
print
'Exporting to tempdir = {0}'
.
format
(
root_dir
)
# export out to a tempdir
export_to_xml
(
ms
,
cs
,
location
,
root_dir
,
'test_export'
)
# remove old course
delete_course
(
ms
,
cs
,
location
)
# reimport
import_from_xml
(
ms
,
root_dir
,
[
'test_export'
])
items
=
ms
.
get_items
(
Location
([
'i4x'
,
'edX'
,
'full'
,
'vertical'
,
None
]))
self
.
assertGreater
(
len
(
items
),
0
)
for
descriptor
in
items
:
print
"Checking {0}...."
.
format
(
descriptor
.
location
.
url
())
resp
=
self
.
client
.
get
(
reverse
(
'edit_unit'
,
kwargs
=
{
'location'
:
descriptor
.
location
.
url
()}))
self
.
assertEqual
(
resp
.
status_code
,
200
)
shutil
.
rmtree
(
root_dir
)
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