示例#1
0
    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]))
示例#2
0
    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])
示例#3
0
    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)
示例#4
0
    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)
示例#5
0
    def test_no_entry_schedule(self):
        teachers = self.faculty.staff()[StaffType.teachers].list()
        topic = Topic('sda', teachers[0])
        attend_date = datetime.now()
        self.assertTrue(teachers)

        groups = self.faculty.groups
        self.assertTrue(groups)

        group = groups[0]
        students = group.list()
        teacher = teachers[0]
        st_count = len(students)
        attended = students[:st_count]
        skipped = students[st_count:]
        self.assertRaises(ValueError, teacher.set_attending, group,
                          attend_date, topic, attended, skipped)
示例#6
0
    def test_attending(self):
        teachers = self.faculty.staff()[StaffType.teachers].list()
        topic = Topic('sda', teachers[0])
        attend_date = datetime.now()
        self.assertTrue(teachers)

        groups = self.faculty.groups
        self.assertTrue(groups)

        group = groups[0]
        students = group.list()
        teacher = teachers[0]
        st_count = len(students)
        attended = students[:st_count]
        skipped = students[st_count:]
        teacher.schedule_topic(group, attend_date, topic)
        teacher.set_attending(group, attend_date, topic, attended, skipped)

        schedules = group.get_schedules(attend_date, topic)
        for schedule in schedules:
            self.assertEqual(skipped, schedule.student_skipped)
            self.assertEqual(attended, schedule.student_attended)
示例#7
0
def combine_faculty(f_type, count=1, staff_count=10, student_count=30):
    f_list = []
    for i in range(count):
        f = Faculty(faker.name(), f_type)
        for p_count in range(staff_count):
            t1 = create_teacher()
            t2 = create_teacher()
            f.hire(StaffType.teachers, t1, faker.job())
            f.hire(StaffType.management, t2, faker.job())

        f.add_group(create_group(f, students_count=student_count))
        teachers = f.staff()[StaffType.teachers].list()
        teachers_count = len(teachers)
        for number in range(1, 4):
            s = Semester(1, number, f)
            for _ in range(random.randrange(10, len(TOPICS))):
                s.add_topic(
                    Topic(faker.word(),
                          teachers[random.randrange(0, teachers_count)]))
            f.add_semester(s)

        f_list.append(f)
    return f_list
示例#8
0
    return next(_gen_teacher(**kwargs))


TOPICS = [
    # knowledge area: lesson list
    {
        'math': ['matan', 'algebra']
    },
    {
        'lang': ['grammar', 'writing']
    },
]

for i in range(100):
    TOPICS.append(
        {faker.word(): [Topic(w, create_teacher()) for w in faker.words()]})


def create_student(faculty, group):
    return next(_gen_student(faculty, group))


def one_or_many(f):
    @wraps(f)
    def inner(*args, **kwargs):
        result = f(*args, **kwargs)
        return result[0] if len(result) == 1 else result

    return inner