def test_not_allowed_perms(self): teacher = create_teacher() f_mng = FacultyManagement(combine_faculty(FacultyTypes.tech)) f_mng.set_manager(teacher) self.assertRaises(NotAllowedException, f_mng.hire, StaffType.teachers, create_teacher(), 'teacher')
def test_change_topic_teacher(self): faculty = combine_faculty(FacultyTypes.tech) f_mng = FacultyManagement(faculty) manager = f_mng.management_obj.staff()[StaffType.management].list()[0] f_mng.set_manager(manager) topic_dict = TOPICS[0] kn_area = topic_dict.keys()[0] teacher1 = create_teacher(knowledge_area=kn_area) teacher2 = create_teacher(knowledge_area=kn_area) topic = Topic(topic_dict[kn_area][0], teacher1) f_mng.change_topic_teacher(topic, teacher2) self.assertEqual(topic.teacher, teacher2)
def test_university_creation(self): u1 = University() f1 = Faculty('f1', FacultyTypes.tech) f2 = Faculty('f2', FacultyTypes.hum) g1 = Group('g1') g2 = Group('g2') g3 = Group('g3') people = [] people_count = 100 f1.add_group(g1) f2.add_group(g2) f2.add_group(g3) u1.add(f1) u1.add(f2) for i in range(people_count): if i < 50: g = g1 elif 50 < i < 80: g = g2 else: g = g3 p = Student(f1, g, name='test_' + unicode(i)) g.add(p) people.append(p) dean = create_teacher() f1.hire(StaffType.management, dean, 'dean') self.assertTrue(u1.list()) self.assertTrue(u1.staff()) for f in u1.list(): self.assertTrue(f.groups) for g in f.groups: self.assertTrue(g.list())
def test_tech_fac_enrollments(self): faculty = combine_faculty(FacultyTypes.tech) s = Semester(1, 1, faculty) for topics in TOPICS: for topic in topics.values(): s.add_topic(Topic(topic, create_teacher())) self.assertTrue( s.enroll(create_student(faculty, faculty.groups[0]), list(s.topics)[:len(s.topics) / 2]))
def test_allowed_perms(self): f_mng = FacultyManagement(combine_faculty(FacultyTypes.tech)) manager = f_mng.management_obj.staff()[StaffType.management].list()[0] f_mng.set_manager(manager) teacher = create_teacher() f_mng.hire(StaffType.teachers, teacher, 'teacher') self.assertIn(teacher, f_mng.staff()[StaffType.teachers].list())
def test_enrollments_non_existing(self): faculty = combine_faculty(FacultyTypes.hum) s = Semester(1, 1, faculty) for topics in TOPICS: for topic in topics.values(): s.add_topic(Topic(topic, create_teacher())) non_existing_topic = '' self.assertRaises(SemesterException, s.enroll, create_student(faculty, faculty.groups[0]), [non_existing_topic])
def test_multiple_enrollments(self): faculty = combine_faculty(FacultyTypes.tech) s = Semester(1, 1, faculty) for topics in TOPICS: for topic in topics.values(): s.add_topic(Topic(topic, create_teacher())) enrolments = 10 for current in range(enrolments): s.enroll(create_student(faculty, faculty.groups[0]), list(s.topics)[:len(s.topics) / 2]) self.assertEqual(len(s.enrollments), enrolments)