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.contrib.auth.models import Group, User
......@@ -12,9 +14,11 @@ from student.models import CourseEnrollment, CourseEnrollmentAllowed
@override_settings(MODULESTORE=TEST_DATA_XML_MODULESTORE)
class TestInstructorEnrollsStudent(LoginEnrollmentTestCase):
'''
Check Enrollment/Unenrollment with/without auto-enrollment on activation
'''
def setUp(self):
xmodule.modulestore.django._MODULESTORES = {}
self.full = modulestore().get_course("edX/full/6.002_Spring_2012")
self.toy = modulestore().get_course("edX/toy/2012_Fall")
......@@ -52,9 +56,11 @@ class TestInstructorEnrollsStudent(LoginEnrollmentTestCase):
self.login(self.instructor, self.password)
self.enroll(self.toy)
def test_unenrollment(self):
#Do un-enrollment
'''
Do un-enrollment test
'''
course = self.toy
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'})
......@@ -73,8 +79,10 @@ class TestInstructorEnrollsStudent(LoginEnrollmentTestCase):
ce = CourseEnrollment.objects.filter(course_id=course.id, user=user)
self.assertEqual(0, len(ce))
def test_enrollmemt_new_student_autoenroll_on(self):
'''
Do auto-enroll on test
'''
#Run the Enroll students command
course = self.toy
......@@ -115,8 +123,10 @@ class TestInstructorEnrollsStudent(LoginEnrollmentTestCase):
ce = CourseEnrollment.objects.filter(course_id=course.id, user=user)
self.assertEqual(1, len(ce))
def test_enrollmemt_new_student_autoenroll_off(self):
'''
Do auto-enroll off test
'''
#Run the Enroll students command
course = self.toy
......@@ -155,4 +165,3 @@ class TestInstructorEnrollsStudent(LoginEnrollmentTestCase):
user = User.objects.get(email='test2_2@student.com')
ce = CourseEnrollment.objects.filter(course_id=course.id, user=user)
self.assertEqual(0, len(ce))
\ No newline at end of file
......@@ -542,8 +542,8 @@ def instructor_dashboard(request, course_id):
elif action == 'Enroll multiple students':
students = request.POST.get('multiple_students', '')
auto_enroll = request.POST.get('auto_enroll', False) != False
ret = _do_enroll_students(course_id, students, auto_enroll=auto_enroll)
auto_enroll = request.POST.get('auto_enroll', False) is not False
ret = _do_enroll_students(course, course_id, students, auto_enroll=auto_enroll)
datatable = ret['datatable']
elif action == 'Unenroll multiple students':
......@@ -967,11 +967,11 @@ def grade_summary(request, course_id):
#-----------------------------------------------------------------------------
# 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
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)
if overload: # delete all but staff
......@@ -1035,7 +1035,7 @@ def _do_unenroll_students(course_id, students):
"""Do the actual work of un-enrolling multiple students, presented as a string
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)
for student in old_students:
......@@ -1079,7 +1079,7 @@ def get_and_clean_student_list(students):
if '' in students:
students.remove('')
return students
return students, students_lc
#-----------------------------------------------------------------------------
# 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