Commit 6a1a9073 by dcadams

Fix pep8 violations.

parent 7c7471d3
""" Unit tests for enrollment methods in views.py """ '''
Unit tests for enrollment methods in views.py
'''
from django.test.utils import override_settings from django.test.utils import override_settings
from django.contrib.auth.models import Group, User from django.contrib.auth.models import Group, User
...@@ -12,9 +14,11 @@ from student.models import CourseEnrollment, CourseEnrollmentAllowed ...@@ -12,9 +14,11 @@ from student.models import CourseEnrollment, CourseEnrollmentAllowed
@override_settings(MODULESTORE=TEST_DATA_XML_MODULESTORE) @override_settings(MODULESTORE=TEST_DATA_XML_MODULESTORE)
class TestInstructorEnrollsStudent(LoginEnrollmentTestCase): class TestInstructorEnrollsStudent(LoginEnrollmentTestCase):
'''
Check Enrollment/Unenrollment with/without auto-enrollment on activation
'''
def setUp(self): def setUp(self):
xmodule.modulestore.django._MODULESTORES = {}
self.full = modulestore().get_course("edX/full/6.002_Spring_2012") self.full = modulestore().get_course("edX/full/6.002_Spring_2012")
self.toy = modulestore().get_course("edX/toy/2012_Fall") self.toy = modulestore().get_course("edX/toy/2012_Fall")
...@@ -52,9 +56,11 @@ class TestInstructorEnrollsStudent(LoginEnrollmentTestCase): ...@@ -52,9 +56,11 @@ class TestInstructorEnrollsStudent(LoginEnrollmentTestCase):
self.login(self.instructor, self.password) self.login(self.instructor, self.password)
self.enroll(self.toy) self.enroll(self.toy)
def test_unenrollment(self): def test_unenrollment(self):
#Do un-enrollment '''
Do un-enrollment test
'''
course = self.toy course = self.toy
url = reverse('instructor_dashboard', kwargs={'course_id': course.id}) url = reverse('instructor_dashboard', kwargs={'course_id': course.id})
response = self.client.post(url, {'action': 'Unenroll multiple students', 'multiple_students': 'student1@test.com, student2@test.com'}) response = self.client.post(url, {'action': 'Unenroll multiple students', 'multiple_students': 'student1@test.com, student2@test.com'})
...@@ -73,8 +79,10 @@ class TestInstructorEnrollsStudent(LoginEnrollmentTestCase): ...@@ -73,8 +79,10 @@ class TestInstructorEnrollsStudent(LoginEnrollmentTestCase):
ce = CourseEnrollment.objects.filter(course_id=course.id, user=user) ce = CourseEnrollment.objects.filter(course_id=course.id, user=user)
self.assertEqual(0, len(ce)) self.assertEqual(0, len(ce))
def test_enrollmemt_new_student_autoenroll_on(self): def test_enrollmemt_new_student_autoenroll_on(self):
'''
Do auto-enroll on test
'''
#Run the Enroll students command #Run the Enroll students command
course = self.toy course = self.toy
...@@ -115,8 +123,10 @@ class TestInstructorEnrollsStudent(LoginEnrollmentTestCase): ...@@ -115,8 +123,10 @@ class TestInstructorEnrollsStudent(LoginEnrollmentTestCase):
ce = CourseEnrollment.objects.filter(course_id=course.id, user=user) ce = CourseEnrollment.objects.filter(course_id=course.id, user=user)
self.assertEqual(1, len(ce)) self.assertEqual(1, len(ce))
def test_enrollmemt_new_student_autoenroll_off(self): def test_enrollmemt_new_student_autoenroll_off(self):
'''
Do auto-enroll off test
'''
#Run the Enroll students command #Run the Enroll students command
course = self.toy course = self.toy
...@@ -155,4 +165,3 @@ class TestInstructorEnrollsStudent(LoginEnrollmentTestCase): ...@@ -155,4 +165,3 @@ class TestInstructorEnrollsStudent(LoginEnrollmentTestCase):
user = User.objects.get(email='test2_2@student.com') user = User.objects.get(email='test2_2@student.com')
ce = CourseEnrollment.objects.filter(course_id=course.id, user=user) ce = CourseEnrollment.objects.filter(course_id=course.id, user=user)
self.assertEqual(0, len(ce)) self.assertEqual(0, len(ce))
\ No newline at end of file
...@@ -542,8 +542,8 @@ def instructor_dashboard(request, course_id): ...@@ -542,8 +542,8 @@ def instructor_dashboard(request, course_id):
elif action == 'Enroll multiple students': elif action == 'Enroll multiple students':
students = request.POST.get('multiple_students', '') students = request.POST.get('multiple_students', '')
auto_enroll = request.POST.get('auto_enroll', False) != False auto_enroll = request.POST.get('auto_enroll', False) is not False
ret = _do_enroll_students(course_id, students, auto_enroll=auto_enroll) ret = _do_enroll_students(course, course_id, students, auto_enroll=auto_enroll)
datatable = ret['datatable'] datatable = ret['datatable']
elif action == 'Unenroll multiple students': elif action == 'Unenroll multiple students':
...@@ -967,11 +967,11 @@ def grade_summary(request, course_id): ...@@ -967,11 +967,11 @@ def grade_summary(request, course_id):
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# enrollment # enrollment
def _do_enroll_students(course_id, students, overload=False, auto_enroll=False): def _do_enroll_students(course, course_id, students, overload=False, auto_enroll=False):
"""Do the actual work of enrolling multiple students, presented as a string """Do the actual work of enrolling multiple students, presented as a string
of emails separated by commas or returns""" of emails separated by commas or returns"""
new_students = get_and_clean_student_list(students) new_students, new_students_lc = get_and_clean_student_list(students)
status = dict([x, 'unprocessed'] for x in new_students) status = dict([x, 'unprocessed'] for x in new_students)
if overload: # delete all but staff if overload: # delete all but staff
...@@ -1035,7 +1035,7 @@ def _do_unenroll_students(course_id, students): ...@@ -1035,7 +1035,7 @@ def _do_unenroll_students(course_id, students):
"""Do the actual work of un-enrolling multiple students, presented as a string """Do the actual work of un-enrolling multiple students, presented as a string
of emails separated by commas or returns""" of emails separated by commas or returns"""
old_students = get_and_clean_student_list(students) old_students, old_students_lc = get_and_clean_student_list(students)
status = dict([x, 'unprocessed'] for x in old_students) status = dict([x, 'unprocessed'] for x in old_students)
for student in old_students: for student in old_students:
...@@ -1079,7 +1079,7 @@ def get_and_clean_student_list(students): ...@@ -1079,7 +1079,7 @@ def get_and_clean_student_list(students):
if '' in students: if '' in students:
students.remove('') students.remove('')
return students return students, students_lc
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# answer distribution # answer distribution
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment