@@ -592,10 +592,8 @@ def test_save_without_min_count(self):
592
592
self .assertEqual (response .status_code , 200 )
593
593
594
594
@ddt .data (
595
- ('ccx_invite' , True , 1 , 'student-ids' , ('enrollment-button' , 'Enroll' )),
596
- ('ccx_invite' , False , 0 , 'student-ids' , ('enrollment-button' , 'Enroll' )),
597
- ('ccx_manage_student' , True , 1 , 'student-id' , ('student-action' , 'add' )),
598
- ('ccx_manage_student' , False , 0 , 'student-id' , ('student-action' , 'add' )),
595
+ ('ccx-manage-students' , True , 1 , 'student-ids' , ('enrollment-button' , 'Enroll' )),
596
+ ('ccx-manage-students' , False , 0 , 'student-ids' , ('enrollment-button' , 'Enroll' )),
599
597
)
600
598
@ddt .unpack
601
599
def test_enroll_member_student (self , view_name , send_email , outbox_count , student_form_input_name , button_tuple ):
@@ -656,7 +654,7 @@ def test_ccx_invite_enroll_up_to_limit(self):
656
654
]
657
655
658
656
url = reverse (
659
- 'ccx_invite ' ,
657
+ 'ccx-manage-students ' ,
660
658
kwargs = {'course_id' : ccx_course_key }
661
659
)
662
660
data = {
@@ -687,81 +685,11 @@ def test_ccx_invite_enroll_up_to_limit(self):
687
685
CourseEnrollment .objects .filter (course_id = ccx_course_key , user = students [5 ]).exists ()
688
686
)
689
687
690
- def test_manage_student_enrollment_limit (self ):
691
- """
692
- Enroll students up to the enrollment limit.
693
-
694
- This test is specific to one of the enrollment views: the reason is because
695
- the view used in this test cannot perform bulk enrollments.
696
- """
697
- students_limit = 1
698
- self .make_coach ()
699
- staff = self .make_staff ()
700
- ccx = self .make_ccx (max_students_allowed = students_limit )
701
- ccx_course_key = CCXLocator .from_course_locator (self .course .id , ccx .id )
702
- students = [
703
- UserFactory .create (is_staff = False ) for _ in range (2 )
704
- ]
705
-
706
- url = reverse (
707
- 'ccx_manage_student' ,
708
- kwargs = {'course_id' : CCXLocator .from_course_locator (self .course .id , ccx .id )}
709
- )
710
- # enroll the first student
711
- data = {
712
- 'student-action' : 'add' ,
713
- 'student-id' : students [0 ].email ,
714
- }
715
- response = self .client .post (url , data = data , follow = True )
716
- self .assertEqual (response .status_code , 200 )
717
- # a CcxMembership exists for this student
718
- self .assertTrue (
719
- CourseEnrollment .objects .filter (course_id = ccx_course_key , user = students [0 ]).exists ()
720
- )
721
-
722
- # try to enroll the second student without success
723
- # enroll the first student
724
- data = {
725
- 'student-action' : 'add' ,
726
- 'student-id' : students [1 ].email ,
727
- }
728
- response = self .client .post (url , data = data , follow = True )
729
- self .assertEqual (response .status_code , 200 )
730
- # a CcxMembership does not exist for this student
731
- self .assertFalse (
732
- CourseEnrollment .objects .filter (course_id = ccx_course_key , user = students [1 ]).exists ()
733
- )
734
- error_message = 'The course is full: the limit is {students_limit}' .format (
735
- students_limit = students_limit
736
- )
737
- self .assertContains (response , error_message , status_code = 200 )
738
-
739
- # try to enroll the 3rd student which is staff
740
- data = {
741
- 'student-action' : 'add' ,
742
- 'student-id' : staff .email ,
743
- }
744
- response = self .client .post (url , data = data , follow = True )
745
- self .assertEqual (response .status_code , 200 )
746
- # staff gets enroll
747
- self .assertTrue (
748
- CourseEnrollment .objects .filter (course_id = ccx_course_key , user = staff ).exists ()
749
- )
750
-
751
- self .assertEqual (CourseEnrollment .objects .num_enrolled_in_exclude_admins (ccx_course_key ), 1 )
752
-
753
- # asert that number of enroll is still 0 because staff and instructor do not count.
754
- CourseEnrollment .enroll (staff , self .course .id )
755
- self .assertEqual (CourseEnrollment .objects .num_enrolled_in_exclude_admins (self .course .id ), 0 )
756
- # assert that handles wrong ccx id code
757
- ccx_course_key_fake = CCXLocator .from_course_locator (self .course .id , 55 )
758
- self .assertEqual (CourseEnrollment .objects .num_enrolled_in_exclude_admins (ccx_course_key_fake ), 0 )
759
-
760
688
@ddt .data (
761
- ('ccx_invite ' , True , 1 , 'student-ids' , ('enrollment-button' , 'Unenroll' )),
762
- ('ccx_invite ' , False , 0 , 'student-ids' , ('enrollment-button' , 'Unenroll' )),
763
- ('ccx_manage_student ' , True , 1 , 'student-id' , ('student-action' , 'revoke' )),
764
- ('ccx_manage_student ' , False , 0 , 'student-id' , ('student-action' , 'revoke' )),
689
+ ('ccx-manage-students ' , True , 1 , 'student-ids' , ('enrollment-button' , 'Unenroll' )),
690
+ ('ccx-manage-students ' , False , 0 , 'student-ids' , ('enrollment-button' , 'Unenroll' )),
691
+ ('ccx-manage-students ' , True , 1 , 'student-id' , ('student-action' , 'revoke' )),
692
+ ('ccx-manage-students ' , False , 0 , 'student-id' , ('student-action' , 'revoke' )),
765
693
)
766
694
@ddt .unpack
767
695
def test_unenroll_member_student (self , view_name , send_email , outbox_count , student_form_input_name , button_tuple ):
@@ -803,14 +731,10 @@ def test_unenroll_member_student(self, view_name, send_email, outbox_count, stud
803
731
)
804
732
805
733
@ddt .data (
806
- ('ccx_invite' , True , 1 , 'student-ids' , ('enrollment-button' , 'Enroll' ), '[email protected] ' ),
807
- ('ccx_invite' , False , 0 , 'student-ids' , ('enrollment-button' , 'Enroll' ), '[email protected] ' ),
808
- ('ccx_invite' , True , 0 , 'student-ids' , ('enrollment-button' , 'Enroll' ), 'nobody' ),
809
- ('ccx_invite' , False , 0 , 'student-ids' , ('enrollment-button' , 'Enroll' ), 'nobody' ),
810
- ('ccx_manage_student' , True , 0 , 'student-id' , ('student-action' , 'add' ), 'dummy_student_id' ),
811
- ('ccx_manage_student' , False , 0 , 'student-id' , ('student-action' , 'add' ), 'dummy_student_id' ),
812
- ('ccx_manage_student' , True , 1 , 'student-id' , ('student-action' , 'add' ), '[email protected] ' ),
813
- ('ccx_manage_student' , False , 0 , 'student-id' , ('student-action' , 'add' ), '[email protected] ' ),
734
+ ('ccx-manage-students' , True , 1 , 'student-ids' , ('enrollment-button' , 'Enroll' ), '[email protected] ' ),
735
+ ('ccx-manage-students' , False , 0 , 'student-ids' , ('enrollment-button' , 'Enroll' ), '[email protected] ' ),
736
+ ('ccx-manage-students' , True , 0 , 'student-ids' , ('enrollment-button' , 'Enroll' ), 'nobody' ),
737
+ ('ccx-manage-students' , False , 0 , 'student-ids' , ('enrollment-button' , 'Enroll' ), 'nobody' ),
814
738
)
815
739
@ddt .unpack
816
740
def test_enroll_non_user_student (
@@ -860,10 +784,10 @@ def test_enroll_non_user_student(
860
784
)
861
785
862
786
@ddt .data (
863
- ('ccx_invite ' , True , 0 , 'student-ids' , ('enrollment-button' , 'Unenroll' ), '[email protected] ' ),
864
- ('ccx_invite ' , False , 0 , 'student-ids' , ('enrollment-button' , 'Unenroll' ), '[email protected] ' ),
865
- ('ccx_invite ' , True , 0 , 'student-ids' , ('enrollment-button' , 'Unenroll' ), 'nobody' ),
866
- ('ccx_invite ' , False , 0 , 'student-ids' , ('enrollment-button' , 'Unenroll' ), 'nobody' ),
787
+ ('ccx-manage-students ' , True , 0 , 'student-ids' , ('enrollment-button' , 'Unenroll' ), '[email protected] ' ),
788
+ ('ccx-manage-students ' , False , 0 , 'student-ids' , ('enrollment-button' , 'Unenroll' ), '[email protected] ' ),
789
+ ('ccx-manage-students ' , True , 0 , 'student-ids' , ('enrollment-button' , 'Unenroll' ), 'nobody' ),
790
+ ('ccx-manage-students ' , False , 0 , 'student-ids' , ('enrollment-button' , 'Unenroll' ), 'nobody' ),
867
791
)
868
792
@ddt .unpack
869
793
def test_unenroll_non_user_student (
0 commit comments