def test_LTICourse_get_course_by_id(self): """ Checks that you can get a course given an id. """ instructor = LTIProfile.objects.get(user=self.user) course_object = LTICourse.create_course('test_course_id', instructor) course_to_test = LTICourse.get_course_by_id('test_course_id') self.assertTrue(isinstance(course_to_test, LTICourse)) self.assertEqual(course_object, course_to_test) self.assertEqual(course_to_test.course_id, 'test_course_id')
def test_LTICourse_get_courses_of_admin(self): """ Checks that it returns a list of all the courses that admin is a part of. """ instructor = LTIProfile.objects.get(user=self.user) course_object = LTICourse.create_course('test_course_id', instructor) list_of_courses = LTICourse.get_courses_of_admin(instructor) self.assertTrue(isinstance(list_of_courses, list)) self.assertTrue(len(list_of_courses) == 1) self.assertTrue(course_object in list_of_courses) course_object2 = LTICourse.create_course('test_course_id2', instructor) list_of_courses2 = LTICourse.get_courses_of_admin(instructor) self.assertTrue(len(list_of_courses2) == 2) self.assertTrue(course_object2 in list_of_courses2)
def test_LTICourse_create_course(self): """ Checks that you can make a course given a course id and an instructor """ instructor = LTIProfile.objects.get(user=self.user) course_object = LTICourse.create_course('test_course_id', instructor) self.assertTrue(isinstance(course_object, LTICourse)) self.assertEqual(course_object.__unicode__(), course_object.course_name)
def test_LTICourse_get_all_courses(self): """ Checks that all courses are returned regardless of admin user """ user2 = self.createFakeUser("FakeUsername2", "AnOnYmOuSiD2") instructor1 = LTIProfile.objects.get(user=self.user) instructor2 = LTIProfile.objects.get(user=user2) list_of_courses = LTICourse.get_all_courses() self.assertTrue(isinstance(list_of_courses, list)) self.assertTrue(len(list_of_courses) == 0) LTICourse.create_course('test_course_id', instructor1) list_of_courses2 = LTICourse.get_all_courses() self.assertTrue(isinstance(list_of_courses2, list)) self.assertTrue(len(list_of_courses2) == 1) LTICourse.create_course('test_course_id2', instructor2) list_of_courses3 = LTICourse.get_all_courses() self.assertTrue(isinstance(list_of_courses3, list)) self.assertTrue(len(list_of_courses3) == 2)