def test_get_num_courses_in_program(self): """ 060A - Valid Get Number of Courses in Program """ test_course_1 = Course("ACIT2515", "123456", "CIT") test_course_1.add_student("A01000056") test_course_2 = Course("COMP1409", "123444", "CSD") test_course_2.add_student("A01000056") test_course_3 = Course("COMP1510", "123555", "CSD") test_course_3.add_student("A01000045") test_course_4 = Course("COMP2530", "123667", "CSD") test_course_4.add_student("A01000034") test_school = School("Computing and Academic Studies") test_school.add_course(test_course_1) test_school.add_course(test_course_2) test_school.add_course(test_course_3) test_school.add_course(test_course_4) self.assertEqual(test_school.get_num_courses_in_program("CIT"), 1, "Must be only 1 CIT course") self.assertEqual(test_school.get_num_courses_in_program("CSD"), 3, "Must be 3 CSD courses") self.assertEqual(test_school.get_num_courses_in_program("SSD"), 0, "Must be no SSD courses")
def test_add_course_already_exists(self): """ 020C - Course Already Exists """ test_course_1 = Course("ACIT2515", "123456", "CIT") test_course_1.add_student("A010000056") test_school = School("Computing and Academic Studies") self.assertEqual(test_school.get_num_courses(), 0, "School must have no courses") test_school.add_course(test_course_1) self.assertEqual(test_school.get_num_courses(), 1, "School must have 1 course") # Add the same course again test_school.add_course(test_course_1) self.assertEqual(test_school.get_num_courses(), 1, "School must still have only 1 course")
def test_get_non_existent_course(self): """ 050C - Invalid Get Course Non-Existent """ test_course_1 = Course("ACIT2515", "123456", "CIT") test_course_1.add_student("A010000056") test_course_2 = Course("COMP1510", "456321", "CST") test_course_2.add_student("A010000056") test_course_2.add_student("A010450012") test_school = School("Computing and Academic Studies") test_school.add_course(test_course_1) test_school.add_course(test_course_2) self.assertIsNone(test_school.get_course("ACIT1234"), "No course should exists for ACIT1234")
def test_course_exists_not_existent_course(self): """ 030C - Valid Course Does Not Exist """ test_course_1 = Course("ACIT2515", "123456", "CIT") test_course_1.add_student("A010000056") test_course_2 = Course("COMP1510", "456321", "CST") test_course_2.add_student("A010000056") test_course_2.add_student("A010450012") test_school = School("Computing and Academic Studies") test_school.add_course(test_course_1) test_school.add_course(test_course_2) self.assertFalse(test_school.course_exists("ACIT1234"), "Course ACIT1234 must NOT exist") self.assertFalse(test_school.course_exists("COMP4321"), "Course4321 must NOT exist")
def test_course_exists(self): """ 030A - Valid Course Exists """ test_course_1 = Course("ACIT2515", "123456", "CIT") test_course_1.add_student("A010000056") test_course_2 = Course("COMP1510", "456321", "CST") test_course_2.add_student("A010000056") test_course_2.add_student("A010450012") test_school = School("Computing and Academic Studies") test_school.add_course(test_course_1) test_school.add_course(test_course_2) self.assertTrue(test_school.course_exists("ACIT2515"), "Course ACIT2515 must exist") self.assertTrue(test_school.course_exists("COMP1510"), "Course COMP1510 must exist")
def test_add_course(self): """ 020A - Valid Add Course """ test_course_1 = Course("ACIT2515", "123456", "CIT") test_course_1.add_student("A010000056") test_course_2 = Course("COMP1510", "456321", "CST") test_course_2.add_student("A010000056") test_course_2.add_student("A010450012") test_school = School("Computing and Academic Studies") self.assertEqual(test_school.get_num_courses(), 0, "School must have no courses") test_school.add_course(test_course_1) self.assertEqual(test_school.get_num_courses(), 1, "School must have 1 course") test_school.add_course(test_course_2) self.assertEqual(test_school.get_num_courses(), 2, "School must have 2 courses")
def test_get_school_details(self): """ 050A - Valid Get Course """ test_course_1 = Course("ACIT2515", "123456", "CIT") test_course_1.add_student("A010000056") test_course_2 = Course("COMP1510", "456321", "CST") test_course_2.add_student("A010000056") test_course_2.add_student("A010450012") test_school = School("BCIT") test_school.add_course(test_course_1) test_school.add_course(test_course_2) retreived_school = test_school.get_school_details() self.assertEqual(retreived_school["school_name"], "BCIT", "School must be named BCIT") self.assertEqual(retreived_school["num_courses"], 2, "School must have two programs") self.assertEqual(sorted(retreived_school["programs"]), sorted(["CIT", "CST"]), "School must have CST as the program")
def test_get_course(self): """ 050A - Valid Get Course """ test_course_1 = Course("ACIT2515", "123456", "CIT") test_course_1.add_student("A010000056") test_course_2 = Course("COMP1510", "456321", "CST") test_course_2.add_student("A010000056") test_course_2.add_student("A010450012") test_school = School("Computing and Academic Studies") test_school.add_course(test_course_1) test_school.add_course(test_course_2) retrieved_course = test_school.get_course("ACIT2515") self.assertEqual(retrieved_course.get_course_id(), "ACIT2515", "Course must have course ID ACIT2515") self.assertEqual(retrieved_course.get_crn(), "123456", "Course must have CRN 123456") self.assertEqual(retrieved_course.get_program(), "CIT", "Course must be in CIT program")
def test_remove_non_existent_course(self): """ 040C - Invalid Remove Course Non-Existent """ test_course_1 = Course("ACIT2515", "123456", "CIT") test_course_1.add_student("A010000056") test_course_2 = Course("COMP1510", "456321", "CST") test_course_2.add_student("A010000056") test_course_2.add_student("A010450012") test_school = School("Computing and Academic Studies") test_school.add_course(test_course_1) test_school.add_course(test_course_2) self.assertEqual(test_school.get_num_courses(), 2, "School must have 2 courses") self.assertTrue(test_school.course_exists("ACIT2515")) self.assertTrue(test_school.course_exists("COMP1510")) test_school.remove_course("ACIT1234") self.assertEqual(test_school.get_num_courses(), 2, "School must have 2 courses")