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
3eee6589
Commit
3eee6589
authored
Jan 28, 2014
by
David Baumgold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added command to delete split-mongo course
parent
c3b8d52d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
85 additions
and
1 deletions
+85
-1
cms/djangoapps/contentstore/management/commands/delete_split_course.py
+31
-0
cms/djangoapps/contentstore/management/commands/tests/test_delete_split_course.py
+53
-0
cms/djangoapps/contentstore/management/commands/tests/test_migrate_to_split.py
+1
-1
No files found.
cms/djangoapps/contentstore/management/commands/delete_split_course.py
0 → 100644
View file @
3eee6589
"""
Django management command to rollback a migration to split. The way to do this
is to delete the course from the split mongo datastore.
"""
from
django.core.management.base
import
BaseCommand
,
CommandError
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
from
xmodule.modulestore.locator
import
CourseLocator
class
Command
(
BaseCommand
):
"Delete a course from the split Mongo datastore"
help
=
"Delete a course from the split Mongo datastore"
args
=
"locator"
def
handle
(
self
,
*
args
,
**
options
):
if
len
(
args
)
<
1
:
raise
CommandError
(
"delete_split_course requires at least one argument (locator)"
)
try
:
locator
=
CourseLocator
(
url
=
args
[
0
])
except
ValueError
:
raise
CommandError
(
"Invalid locator string {}"
.
format
(
args
[
0
]))
try
:
modulestore
(
'split'
)
.
delete_course
(
locator
.
package_id
)
except
ItemNotFoundError
:
raise
CommandError
(
"No course found with locator {}"
.
format
(
locator
))
cms/djangoapps/contentstore/management/commands/tests/test_delete_split_course.py
0 → 100644
View file @
3eee6589
"""
Unittests for deleting a split mongo course
"""
import
unittest
from
django.core.management
import
CommandError
,
call_command
from
django.test.utils
import
override_settings
from
contentstore.management.commands.delete_split_course
import
Command
from
contentstore.tests.modulestore_config
import
TEST_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.persistent_factories
import
PersistentCourseFactory
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
class
TestArgParsing
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
command
=
Command
()
def
test_no_args
(
self
):
errstring
=
"delete_split_course requires at least one argument"
with
self
.
assertRaisesRegexp
(
CommandError
,
errstring
):
self
.
command
.
handle
()
def
test_invalid_locator
(
self
):
errstring
=
"Invalid locator string !?!"
with
self
.
assertRaisesRegexp
(
CommandError
,
errstring
):
self
.
command
.
handle
(
"!?!"
)
def
test_nonexistant_locator
(
self
):
errstring
=
"No course found with locator course/branch/name"
with
self
.
assertRaisesRegexp
(
CommandError
,
errstring
):
self
.
command
.
handle
(
"course/branch/name"
)
@override_settings
(
MODULESTORE
=
TEST_MODULESTORE
)
class
TestDeleteSplitCourse
(
ModuleStoreTestCase
):
"""
Unit tests for deleting a split-mongo course from command line
"""
def
setUp
(
self
):
super
(
TestDeleteSplitCourse
,
self
)
.
setUp
()
self
.
course
=
PersistentCourseFactory
()
def
test_happy_path
(
self
):
locator
=
self
.
course
.
location
call_command
(
"delete_split_course"
,
str
(
locator
),
)
with
self
.
assertRaises
(
ItemNotFoundError
):
modulestore
(
'split'
)
.
get_course
(
locator
)
cms/djangoapps/contentstore/management/commands/tests/test_migrate_to_split.py
View file @
3eee6589
"""
Unittests for
importing a course via management command
Unittests for
migrating a course to split mongo
"""
import
unittest
...
...
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