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
4fa970f9
Unverified
Commit
4fa970f9
authored
5 years ago
by
Awais Qureshi
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #23704 from edx/awais786/BOM-1515
BOM-1515
parents
ca3012c0
aefafab4
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/djangoapps/student/management/tests/test_bulk_change_enrollment.py
+35
-14
35 additions, 14 deletions
...s/student/management/tests/test_bulk_change_enrollment.py
with
35 additions
and
14 deletions
common/djangoapps/student/management/tests/test_bulk_change_enrollment.py
+
35
−
14
View file @
4fa970f9
...
...
@@ -95,7 +95,7 @@ class BulkChangeEnrollmentTests(SharedModuleStoreTestCase):
self
.
_enroll_users
(
self
.
course
,
self
.
users
,
'
audit
'
)
CourseModeFactory
(
course_id
=
self
.
course
.
id
,
mode_slug
=
'
no-id-professional
'
)
with
self
.
assertRaises
(
CommandError
):
with
self
.
assertRaises
(
CommandError
)
as
err
:
call_command
(
'
bulk_change_enrollment
'
,
org
=
self
.
org
,
...
...
@@ -105,6 +105,8 @@ class BulkChangeEnrollmentTests(SharedModuleStoreTestCase):
commit
=
True
,
)
self
.
assertEqual
(
'
Error: one of the arguments -c/--course -o/--org is required
'
,
text_type
(
err
.
exception
))
@patch
(
'
student.models.tracker
'
)
def
test_with_org_and_invalid_to_mode
(
self
,
mock_tracker
):
"""
Verify that enrollments are changed correctly when org was given.
"""
...
...
@@ -149,7 +151,7 @@ class BulkChangeEnrollmentTests(SharedModuleStoreTestCase):
self
.
_enroll_users
(
self
.
course
,
self
.
users
,
'
audit
'
)
CourseModeFactory
(
course_id
=
self
.
course
.
id
,
mode_slug
=
'
no-id-professional
'
)
with
self
.
assertRaises
(
CommandError
):
with
self
.
assertRaises
(
CommandError
)
as
err
:
args
=
'
--org {org} --from_mode {from_mode} --to_mode {to_mode} --commit
'
.
format
(
org
=
'
fakeX
'
,
from_mode
=
'
audit
'
,
...
...
@@ -157,10 +159,11 @@ class BulkChangeEnrollmentTests(SharedModuleStoreTestCase):
)
call_command
(
'
bulk_change_enrollment
'
,
*
args
.
split
(
'
'
)
'
bulk_change_enrollment
'
,
*
args
.
split
(
'
'
)
)
self
.
assertEqual
(
'
No courses exist for the org
"
fakeX
"
.
'
,
text_type
(
err
.
exception
))
def
test_without_commit
(
self
):
"""
Verify that nothing happens when the `commit` flag is not given.
"""
self
.
_enroll_users
(
self
.
course
,
self
.
users
,
'
audit
'
)
...
...
@@ -185,13 +188,19 @@ class BulkChangeEnrollmentTests(SharedModuleStoreTestCase):
self
.
_enroll_users
(
self
.
course
,
self
.
users
,
'
audit
'
)
CourseModeFactory
(
course_id
=
self
.
course
.
id
,
mode_slug
=
'
audit
'
)
with
self
.
assertRaises
(
CommandError
):
args
=
'
--course {course} --from_mode {from_mode}
'
.
format
(
course
=
'
yolo
'
,
from_mode
=
'
audit
'
)
with
self
.
assertRaises
(
CommandError
)
as
err
:
call_command
(
'
bulk_change_enrollment
'
,
course
=
text_type
(
self
.
course
.
id
),
from_mode
=
'
audit
'
,
*
args
.
split
(
'
'
)
)
self
.
assertEqual
(
'
Error: the following arguments are required: -t/--to_mode
'
,
text_type
(
err
.
exception
))
@ddt.data
(
'
from_mode
'
,
'
to_mode
'
,
'
course
'
)
def
test_without_options
(
self
,
option
):
"""
Verify that the command fails when some options are not given.
"""
...
...
@@ -207,19 +216,31 @@ class BulkChangeEnrollmentTests(SharedModuleStoreTestCase):
def
test_bad_course_id
(
self
):
"""
Verify that the command fails when the given course ID does not parse.
"""
with
self
.
assertRaises
(
CommandError
):
call_command
(
'
bulk_change_enrollment
'
,
from_mode
=
'
audit
'
,
to_mode
=
'
honor
'
,
course
=
'
yolo
'
,
commit
=
True
)
args
=
'
--course {course} --from_mode {from_mode} --to_mode {to_mode}
'
.
format
(
course
=
'
yolo
'
,
from_mode
=
'
audit
'
,
to_mode
=
'
honor
'
)
with
self
.
assertRaises
(
CommandError
)
as
err
:
call_command
(
'
bulk_change_enrollment
'
,
*
args
.
split
(
'
'
))
self
.
assertEqual
(
'
Course ID yolo is invalid.
'
,
text_type
(
err
.
exception
))
def
test_nonexistent_course_id
(
self
):
"""
Verify that the command fails when the given course does not exist.
"""
with
self
.
assertRaises
(
CommandError
):
args
=
'
--course {course} --from_mode {from_mode} --to_mode {to_mode}
'
.
format
(
course
=
'
course-v1:testX+test+2016
'
,
from_mode
=
'
audit
'
,
to_mode
=
'
honor
'
)
with
self
.
assertRaises
(
CommandError
)
as
err
:
call_command
(
'
bulk_change_enrollment
'
,
from_mode
=
'
audit
'
,
to_mode
=
'
honor
'
,
course
=
'
course-v1:testX+test+2016
'
,
commit
=
True
*
args
.
split
(
'
'
)
)
self
.
assertEqual
(
'
The given course course-v1:testX+test+2016 does not exist.
'
,
text_type
(
err
.
exception
))
def
_assert_mode_changed
(
self
,
mock_tracker
,
course
,
user
,
to_mode
):
"""
Confirm the analytics event was emitted.
"""
...
...
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