-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #651 from edx/ormsbee/enrollment_modes
Add mode and is_active to CourseEnrollment, shift enrollment logic to model
- Loading branch information
Showing
32 changed files
with
734 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
from django.test import TestCase | ||
|
||
from django_comment_common.models import Role | ||
from student.models import CourseEnrollment, User | ||
|
||
class RoleAssignmentTest(TestCase): | ||
""" | ||
Basic checks to make sure our Roles get assigned and unassigned as students | ||
are enrolled and unenrolled from a course. | ||
""" | ||
|
||
def setUp(self): | ||
self.staff_user = User.objects.create_user( | ||
"patty", | ||
"patty@fake.edx.org", | ||
) | ||
self.staff_user.is_staff = True | ||
|
||
self.student_user = User.objects.create_user( | ||
"hacky", | ||
"hacky@fake.edx.org" | ||
) | ||
self.course_id = "edX/Fake101/2012" | ||
CourseEnrollment.enroll(self.staff_user, self.course_id) | ||
CourseEnrollment.enroll(self.student_user, self.course_id) | ||
|
||
def test_enrollment_auto_role_creation(self): | ||
moderator_role = Role.objects.get( | ||
course_id=self.course_id, | ||
name="Moderator" | ||
) | ||
student_role = Role.objects.get( | ||
course_id=self.course_id, | ||
name="Student" | ||
) | ||
self.assertIn(moderator_role, self.staff_user.roles.all()) | ||
|
||
self.assertIn(student_role, self.student_user.roles.all()) | ||
self.assertNotIn(moderator_role, self.student_user.roles.all()) | ||
|
||
# The following was written on the assumption that unenrolling from a course | ||
# should remove all forum Roles for that student for that course. This is | ||
# not necessarily the case -- please see comments at the top of | ||
# django_comment_client.models.assign_default_role(). Leaving it for the | ||
# forums team to sort out. | ||
# | ||
# def test_unenrollment_auto_role_removal(self): | ||
# another_student = User.objects.create_user("sol", "sol@fake.edx.org") | ||
# CourseEnrollment.enroll(another_student, self.course_id) | ||
# | ||
# CourseEnrollment.unenroll(self.student_user, self.course_id) | ||
# # Make sure we didn't delete the actual Role | ||
# student_role = Role.objects.get( | ||
# course_id=self.course_id, | ||
# name="Student" | ||
# ) | ||
# self.assertNotIn(student_role, self.student_user.roles.all()) | ||
# self.assertIn(student_role, another_student.roles.all()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.