Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
3cd48e4d
Commit
3cd48e4d
authored
9 years ago
by
Awais Jibran
Browse files
Options
Downloads
Plain Diff
Merge pull request #8317 from edx/aj/plat643-cms-export-command-export-to-wrong-place
Fixed cms course export using management command.
parents
0003bf7a
3e6670d1
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cms/djangoapps/contentstore/management/commands/export.py
+3
-0
3 additions, 0 deletions
cms/djangoapps/contentstore/management/commands/export.py
cms/djangoapps/contentstore/management/commands/tests/test_export.py
+65
-0
65 additions, 0 deletions
...pps/contentstore/management/commands/tests/test_export.py
with
68 additions
and
0 deletions
cms/djangoapps/contentstore/management/commands/export.py
+
3
−
0
View file @
3cd48e4d
...
...
@@ -32,6 +32,9 @@ class Command(BaseCommand):
print
(
"
Exporting course id = {0} to {1}
"
.
format
(
course_key
,
output_path
))
if
not
output_path
.
endswith
(
'
/
'
):
output_path
+=
'
/
'
root_dir
=
os
.
path
.
dirname
(
output_path
)
course_dir
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
output_path
))[
0
]
...
...
This diff is collapsed.
Click to expand it.
cms/djangoapps/contentstore/management/commands/tests/test_export.py
0 → 100644
+
65
−
0
View file @
3cd48e4d
"""
Tests for exporting courseware to the desired path
"""
import
unittest
import
shutil
import
ddt
from
django.core.management
import
CommandError
,
call_command
from
tempfile
import
mkdtemp
from
opaque_keys
import
InvalidKeyError
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.django
import
modulestore
class
TestArgParsingCourseExport
(
unittest
.
TestCase
):
"""
Tests for parsing arguments for the `export` management command
"""
def
setUp
(
self
):
super
(
TestArgParsingCourseExport
,
self
).
setUp
()
def
test_no_args
(
self
):
errstring
=
"
export requires two arguments: <course id> <output path>
"
with
self
.
assertRaises
(
SystemExit
)
as
ex
:
with
self
.
assertRaisesRegexp
(
CommandError
,
errstring
):
call_command
(
'
export
'
)
self
.
assertEqual
(
ex
.
exception
.
code
,
1
)
@ddt.ddt
class
TestCourseExport
(
ModuleStoreTestCase
):
"""
Test exporting a course
"""
def
setUp
(
self
):
super
(
TestCourseExport
,
self
).
setUp
()
# Temp directories (temp_dir_1: relative path, temp_dir_2: absolute path)
self
.
temp_dir_1
=
mkdtemp
()
self
.
temp_dir_2
=
mkdtemp
(
dir
=
""
)
# Clean temp directories
self
.
addCleanup
(
shutil
.
rmtree
,
self
.
temp_dir_1
)
self
.
addCleanup
(
shutil
.
rmtree
,
self
.
temp_dir_2
)
@ddt.data
(
ModuleStoreEnum
.
Type
.
mongo
,
ModuleStoreEnum
.
Type
.
split
)
def
test_export_course_with_directory_name
(
self
,
store
):
"""
Create a new course try exporting in a path specified
"""
course
=
CourseFactory
.
create
(
default_store
=
store
)
course_id
=
unicode
(
course
.
id
)
self
.
assertTrue
(
modulestore
().
has_course
(
course
.
id
),
"
Could not find course in {}
"
.
format
(
store
)
)
# Test `export` management command with invalid course_id
with
self
.
assertRaises
(
InvalidKeyError
):
call_command
(
'
export
'
,
"
InvalidCourseID
"
,
self
.
temp_dir_1
)
# Test `export` management command with correct course_id
for
output_dir
in
[
self
.
temp_dir_1
,
self
.
temp_dir_2
]:
call_command
(
'
export
'
,
course_id
,
output_dir
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment