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
a4006c86
Commit
a4006c86
authored
Dec 10, 2015
by
Feanil Patel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add another test and fix existing tests.
parent
07f015bb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
4 deletions
+12
-4
cms/djangoapps/contentstore/management/commands/delete_course.py
+1
-1
cms/djangoapps/contentstore/management/commands/tests/test_delete_course.py
+11
-3
No files found.
cms/djangoapps/contentstore/management/commands/delete_course.py
View file @
a4006c86
...
...
@@ -31,7 +31,7 @@ class Command(BaseCommand):
try
:
course_key
=
CourseKey
.
from_string
(
options
[
'course_key'
])
except
InvalidKeyError
:
raise
CommandError
(
"Invalid course_key: '
%
s'.
Proper syntax: 'org/number/run'
"
%
options
[
'course_key'
])
raise
CommandError
(
"Invalid course_key: '
%
s'."
%
options
[
'course_key'
])
if
not
modulestore
()
.
get_course
(
course_key
):
raise
CommandError
(
"Course with '
%
s' key not found."
%
options
[
'course_key'
])
...
...
cms/djangoapps/contentstore/management/commands/tests/test_delete_course.py
View file @
a4006c86
...
...
@@ -33,13 +33,21 @@ class DeleteCourseTest(CourseTestCase):
run
=
course_run
)
def
test_invalid_key_not_found
(
self
):
"""
Test for when a course key is malformed
"""
errstring
=
"Invalid course_key: 'foo/TestX/TS01/2015_Q7'."
with
self
.
assertRaisesRegexp
(
CommandError
,
errstring
):
call_command
(
'delete_course'
,
'foo/TestX/TS01/2015_Q7'
)
def
test_course_key_not_found
(
self
):
"""
Test for when a non-existing course key is entered
"""
errstring
=
"
Invalid course_key: 'TestX/TS01/2015_Q7'. Proper syntax: 'org/number/run'
"
errstring
=
"
Course with 'TestX/TS01/2015_Q7' key not found.
"
with
self
.
assertRaisesRegexp
(
CommandError
,
errstring
):
call_command
(
'delete_course'
,
'TestX/TS01/2015_Q7'
)
call_command
(
'delete_course'
,
'TestX/TS01/2015_Q7'
)
def
test_course_deleted
(
self
):
"""
...
...
@@ -51,5 +59,5 @@ class DeleteCourseTest(CourseTestCase):
with
mock
.
patch
(
self
.
YESNO_PATCH_LOCATION
)
as
patched_yes_no
:
patched_yes_no
.
return_value
=
True
call_command
(
'delete_course'
,
'TestX/TS01/2015_Q1'
,
"commit"
)
call_command
(
'delete_course'
,
'TestX/TS01/2015_Q1'
)
self
.
assertIsNone
(
modulestore
()
.
get_course
(
SlashSeparatedCourseKey
(
"TestX"
,
"TS01"
,
"2015_Q1"
)))
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