def test_view_ta_assign4(self): mod_course1 = models.ModelCourse.objects.get(course_id="CS101") mod_ta_course1 = models.ModelTACourse() mod_ta_course1.course = mod_course1 mod_ta1 = models.ModelPerson.objects.get(email="*****@*****.**") mod_ta_course1.TA = mod_ta1 mod_ta_course1.save() mod_course2 = models.ModelCourse.objects.get(course_id="CS201") mod_ta_course2 = models.ModelTACourse() mod_ta_course2.course = mod_course2 mod_ta2 = models.ModelPerson.objects.get(email="*****@*****.**") mod_ta_course2.TA = mod_ta2 mod_ta_course2.save() mod_course3 = models.ModelCourse.objects.get(course_id="CS301") mod_ta_course3 = models.ModelTACourse() mod_ta_course3.course = mod_course3 mod_ta3 = models.ModelPerson.objects.get(email="*****@*****.**") mod_ta_course3.TA = mod_ta3 mod_ta_course3.save() self.assertEqual(self.inst0.view_ta_assign()[0], "Course: CS101 TA: DEFAULT, [email protected]") self.assertEqual(self.inst0.view_ta_assign()[1], "Course: CS201 TA: DEFAULT, [email protected]") self.assertEqual(self.inst0.view_ta_assign()[2], "Course: CS301 TA: DEFAULT, [email protected]") self.assertEqual(self.inst0.view_ta_assign(), [ 'Course: CS101 TA: DEFAULT, [email protected]', 'Course: CS201 TA: DEFAULT, [email protected]', 'Course: CS301 TA: DEFAULT, [email protected]' ])
def test_access_info_all_the_things(self): # ALL THE THINGS self.inst1 = Instructor("*****@*****.**", "password", "instructor") self.inst2 = Instructor("*****@*****.**", "password", "instructor") self.ta1 = TA("*****@*****.**", "password", "ta") self.ta2 = TA("*****@*****.**", "password", "ta") self.course1 = Course("CS101", 0) self.course2 = Course("CS102", 0) self.course1.instructor = "*****@*****.**" mod_course1 = models.ModelCourse.objects.get(course_id="CS101") mod_course1.instructor = "*****@*****.**" mod_course1.save() self.course2.instructor = "*****@*****.**" mod_course2 = models.ModelCourse.objects.get(course_id="CS102") mod_course2.instructor = "*****@*****.**" mod_course2.save() mod_ta_course1 = models.ModelTACourse() mod_ta_course1.course = mod_course1 mod_ta1 = models.ModelPerson.objects.get(email="*****@*****.**") mod_ta_course1.TA = mod_ta1 mod_ta_course1.save() mod_ta_course2 = models.ModelTACourse() mod_ta_course2.course = mod_course2 mod_ta2 = models.ModelPerson.objects.get(email="*****@*****.**") mod_ta_course2.TA = mod_ta2 mod_ta_course2.save() access_info = self.ad1.access_info() parse_info = access_info.split("\n") self.assertEqual(parse_info[0], "Administrator:") self.assertEqual(parse_info[1], "DEFAULT | [email protected] | 000.000.0000") self.assertEqual(parse_info[2], "") self.assertEqual(parse_info[3], "Supervisor:") self.assertEqual(parse_info[4], "DEFAULT | [email protected] | 000.000.0000") self.assertEqual(parse_info[5], "") self.assertEqual(parse_info[6], "Instructors:") self.assertEqual(parse_info[7], "DEFAULT | [email protected] | 000.000.0000") self.assertEqual(parse_info[8], "\tCourse: CS101") self.assertEqual(parse_info[9], "") self.assertEqual(parse_info[10], "DEFAULT | [email protected] | 000.000.0000") self.assertEqual(parse_info[11], "\tCourse: CS102") self.assertEqual(parse_info[12], "") self.assertEqual(parse_info[13], "") self.assertEqual(parse_info[14], "TAs:") self.assertEqual(parse_info[15], "DEFAULT | [email protected] | 000.000.0000") self.assertEqual(parse_info[16], "\tCourse: CS101") self.assertEqual(parse_info[17], "") self.assertEqual(parse_info[18], "DEFAULT | [email protected] | 000.000.0000") self.assertEqual(parse_info[19], "\tCourse: CS102") self.assertEqual(parse_info[20], "") self.assertEqual(parse_info[21], "") self.assertEqual(parse_info[22], "Courses:") self.assertEqual(parse_info[23], "CS101") self.assertEqual(parse_info[24], "CS102")
def assign_ta_course(self, ta, course): """ assigns the given TA's course to the course parameter """ if ta.type != "ta": raise TypeError("invalid type") try: find_course = models.ModelCourse.objects.get( course_id=course.course_id) except models.ModelCourse.DoesNotExist: find_course = "none" try: find_ta = models.ModelPerson.objects.get(email=ta.email) except models.ModelCourse.DoesNotExist: find_ta = "none" if find_course != "none" and find_ta != "none": ta_course = models.ModelTACourse() ta_course.TA = find_ta ta_course.course = find_course ta_course.save() return True else: return False
def test_view_ta_assign3(self): mod_course3 = models.ModelCourse.objects.get(course_id="CS301") mod_ta_course3 = models.ModelTACourse() mod_ta_course3.course = mod_course3 mod_ta3 = models.ModelPerson.objects.get(email="*****@*****.**") mod_ta_course3.TA = mod_ta3 mod_ta_course3.save() self.assertEqual(self.inst0.view_ta_assign()[0], "Course: CS301 TA: DEFAULT, [email protected]")
def test_view_ta_assignments2(self): mod_course2 = models.ModelCourse.objects.get(course_id="CS201") mod_ta_course2 = models.ModelTACourse() mod_ta_course2.course = mod_course2 mod_ta2 = models.ModelPerson.objects.get(email="*****@*****.**") mod_ta_course2.TA = mod_ta2 mod_ta_course2.save() self.assertEqual(self.ta2.view_ta_assignments()[0], "Course: CS201 TA: DEFAULT, [email protected]")
def test_view_ta_assignments1(self): mod_course1 = models.ModelCourse.objects.get(course_id="CS101") mod_ta_course1 = models.ModelTACourse() mod_ta_course1.course = mod_course1 mod_ta1 = models.ModelPerson.objects.get(email="*****@*****.**") mod_ta_course1.TA = mod_ta1 mod_ta_course1.save() self.assertEqual(self.ta1.view_ta_assignments()[0], "Course: CS101 TA: DEFAULT, [email protected]")
def test_access_info_ta_one_course(self): # TA with a course self.ta1 = TA("*****@*****.**", "password", "ta") mod_ta_course1 = models.ModelTACourse() self.course1 = Course("CS101", 0) mod_course1 = models.ModelCourse.objects.get(course_id="CS101") mod_ta_course1.course = mod_course1 mod_ta1 = models.ModelPerson.objects.get(email="*****@*****.**") mod_ta_course1.TA = mod_ta1 mod_ta_course1.save() access_info = self.sup1.access_info() parse_info = access_info.split("\n") self.assertEqual(parse_info[10], "\tCourse: CS101")