Exemple #1
0
    def setUpTestData(cls):
        cls.academic_year_calendar = AcademicYearCalendarFactory()
        cls.school_unit = RegisteredSchoolUnitFactory()
        cls.principal = cls.school_unit.school_principal
        cls.subject1 = SubjectFactory()
        cls.subject2 = SubjectFactory()
        cls.subject3 = SubjectFactory()

        cls.study_class = StudyClassFactory(school_unit=cls.school_unit,
                                            class_grade_arabic=10,
                                            class_grade='X',
                                            class_letter='B')
        TeacherClassThroughFactory(study_class=cls.study_class,
                                   teacher=cls.study_class.class_master,
                                   subject=cls.subject1,
                                   is_class_master=True)
        TeacherClassThroughFactory(study_class=cls.study_class,
                                   teacher=cls.study_class.class_master,
                                   subject=cls.subject2,
                                   is_class_master=True)

        cls.source_study_class = StudyClassFactory(class_grade='X',
                                                   class_grade_arabic=10,
                                                   school_unit=cls.school_unit)
        cls.student = UserProfileFactory(
            user_role=UserProfile.UserRoles.STUDENT,
            school_unit=cls.school_unit,
            student_in_class=cls.source_study_class)

        cls.expected_fields = [
            'id', 'class_grade', 'class_letter', 'academic_year',
            'academic_program', 'academic_program_name', 'class_master',
            'teachers_class_through', 'students', 'has_previous_catalog_data'
        ]
Exemple #2
0
    def test_own_study_class_detail_is_class_master(self):
        self.client.login(username=self.teacher.username, password='******')

        TeacherClassThroughFactory(study_class=self.study_class,
                                   teacher=self.teacher,
                                   subject=self.subject1,
                                   is_class_master=True)
        TeacherClassThroughFactory(study_class=self.study_class,
                                   teacher=self.teacher,
                                   subject=self.subject2,
                                   is_class_master=True,
                                   is_optional_subject=True)

        response = self.client.get(self.build_url(self.study_class.id))
        self.assertEqual(response.status_code, status.HTTP_200_OK)

        self.assertCountEqual(response.data.keys(), self.expected_fields)
        self.assertCountEqual(response.data['class_master'].keys(),
                              self.class_master_fields)
        self.assertEqual(len(response.data['taught_subjects']), 3)
        self.assertCountEqual(response.data['taught_subjects'][0].keys(),
                              self.taught_subject_fields)
        self.assertTrue(response.data['is_class_master'])

        self.assertEqual(response.data['taught_subjects'][0]['id'],
                         self.coordination_subject.id)
        self.assertFalse(response.data['taught_subjects'][0]['is_optional'])
        self.assertEqual(response.data['taught_subjects'][1]['id'],
                         self.subject2.id)
        self.assertTrue(response.data['taught_subjects'][1]['is_optional'])
        self.assertEqual(response.data['taught_subjects'][2]['id'],
                         self.subject1.id)
        self.assertFalse(response.data['taught_subjects'][2]['is_optional'])
Exemple #3
0
    def test_study_class_partially_update_teachers_primary_school(self):
        self.client.login(username=self.principal.username, password='******')

        primary_study_class = StudyClassFactory(school_unit=self.school_unit, class_grade='I', class_grade_arabic=1)
        class_master = primary_study_class.class_master
        TeacherClassThroughFactory(study_class=primary_study_class, teacher=class_master, is_class_master=True)

        teacher = UserProfileFactory(user_role=UserProfile.UserRoles.TEACHER, school_unit=self.school_unit)
        subject = SubjectFactory()
        teacher.taught_subjects.add(subject)
        teacher_class_through = TeacherClassThroughFactory(study_class=primary_study_class, teacher=teacher, is_class_master=False)

        url = self.build_url(primary_study_class.id)
        request_data = {
            'updated_teachers': [
                {
                    'id': teacher_class_through.id,
                    'teacher': class_master.id
                }
            ]
        }

        # This is allowed even if the teacher doesn't have the subject in taught subjects list
        # (because the teacher is the class master)
        response = self.client.patch(url, request_data)
        self.assertEqual(response.status_code, status.HTTP_200_OK)

        teacher_class_through.refresh_from_db()
        self.assertEqual(teacher_class_through.teacher, class_master)
        self.assertTrue(teacher_class_through.is_class_master)
    def test_teacher_detail(self, profile_param):
        self.client.login(username=getattr(self, profile_param).username, password='******')

        profile = UserProfileFactory(user_role=UserProfile.UserRoles.TEACHER, school_unit=self.school_unit)
        profile.labels.add(LabelFactory(user_role=UserProfile.UserRoles.TEACHER))
        profile.taught_subjects.add(self.subject)

        study_class1 = StudyClassFactory(school_unit=self.school_unit, class_master=profile, class_grade='IX', class_grade_arabic=9)
        teacher_class_through1 = TeacherClassThroughFactory(study_class=study_class1, teacher=profile, is_class_master=True,
                                                            subject=SubjectFactory(name='A subject'))
        teacher_class_through2 = TeacherClassThroughFactory(study_class=study_class1, teacher=profile, is_class_master=True,
                                                            subject=SubjectFactory(name='Dirigentie', is_coordination=True))
        study_class2 = StudyClassFactory(school_unit=self.school_unit)
        teacher_class_through3 = TeacherClassThroughFactory(study_class=study_class2, teacher=profile)
        study_class3 = StudyClassFactory(school_unit=self.school_unit, academic_year=2019)
        TeacherClassThroughFactory(study_class=study_class3, teacher=profile)

        response = self.client.get(self.build_url(profile.id))
        self.assertEqual(response.status_code, status.HTTP_200_OK)

        expected_fields = ['id', 'full_name', 'user_role', 'email', 'phone_number', 'use_phone_as_username',
                           'is_active', 'last_online', 'labels', 'taught_subjects', 'assigned_study_classes']
        self.assertCountEqual(response.data.keys(), expected_fields)
        self.assertCountEqual(response.data['labels'][0].keys(), ['id', 'text'])
        self.assertCountEqual(response.data['taught_subjects'][0].keys(), ['id', 'name'])
        self.assertEqual(len(response.data['assigned_study_classes']), 3)
        self.assertCountEqual(response.data['assigned_study_classes'][0].keys(), ['id', 'study_class_id', 'class_grade', 'class_letter',
                                                                                  'subject_id', 'subject_name', 'is_optional_subject'])
        self.assertEqual(response.data['assigned_study_classes'][0]['id'], teacher_class_through3.id)
        self.assertEqual(response.data['assigned_study_classes'][1]['id'], teacher_class_through1.id)
        self.assertEqual(response.data['assigned_study_classes'][2]['id'], teacher_class_through2.id)
Exemple #5
0
    def test_study_class_name_list_teacher(self):
        self.client.login(username=self.teacher.username, password='******')

        class1 = StudyClassFactory(class_grade='VII', class_grade_arabic=7, class_letter='A', school_unit=self.school_unit)
        class2 = StudyClassFactory(class_grade='P', class_grade_arabic=0, class_letter='A', school_unit=self.school_unit)
        class3 = StudyClassFactory(class_grade='IX', class_grade_arabic=9, class_letter='B', school_unit=self.school_unit)
        class4 = StudyClassFactory(class_grade='IX', class_grade_arabic=9, class_letter='A', school_unit=self.school_unit)

        for study_class in [class1, class2, class3, class4]:
            TeacherClassThroughFactory(teacher=self.teacher, study_class=study_class)

        # A class where the user doesn't teach
        StudyClassFactory(school_unit=self.school_unit)
        # A class from another year
        class5 = StudyClassFactory(school_unit=self.school_unit, academic_year=2018)
        TeacherClassThroughFactory(teacher=self.teacher, study_class=class5)

        response = self.client.get(self.url)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(len(response.data), 4)
        self.assertCountEqual(response.data[0].keys(), ['id', 'class_grade', 'class_letter'])

        self.assertEqual(response.data[0]['id'], class2.id)
        self.assertEqual(response.data[1]['id'], class1.id)
        self.assertEqual(response.data[2]['id'], class4.id)
        self.assertEqual(response.data[3]['id'], class3.id)
Exemple #6
0
    def test_study_class_partially_update_move_student_from_different_school(self):
        self.client.login(username=self.principal.username, password='******')

        self.new_student.labels.add(
            LabelFactory(text=TRANSFERRED_LABEL, is_label_for_transfers_between_schools=True)
        )
        another_school_unit = RegisteredSchoolUnitFactory()
        another_school_profile = UserProfileFactory(school_unit=another_school_unit, full_name=self.new_student.full_name,
                                                    username='******'.format(another_school_unit.id, self.new_student.email),
                                                    email=self.new_student.email,
                                                    phone_number=self.new_student.phone_number, user_role=UserProfile.UserRoles.STUDENT)

        prev_study_class = StudyClassFactory(school_unit=self.school_unit, class_master=self.teacher1, academic_program=self.academic_program,
                                             class_grade='IX', class_grade_arabic=9, class_letter='A', academic_year=self.calendar.academic_year - 1)
        TeacherClassThroughFactory(study_class=prev_study_class, teacher=self.teacher1, subject=self.coordination_subject, is_class_master=True)
        TeacherClassThroughFactory(study_class=prev_study_class, teacher=self.teacher1, subject=self.subject1, is_class_master=True)
        TeacherClassThroughFactory(study_class=prev_study_class, teacher=self.teacher2, subject=self.subject2, is_class_master=True,
                                   is_optional_subject=True)

        student_prev_study_class = StudyClassFactory(school_unit=another_school_unit, class_grade='IX', class_grade_arabic=9,
                                                     academic_year=self.calendar.academic_year - 1)
        StudentCatalogPerYearFactory(student=another_school_profile, study_class=student_prev_study_class,
                                     avg_sem1=9, avg_sem2=9, avg_annual=9, avg_final=9)
        catalog1 = StudentCatalogPerSubjectFactory(student=another_school_profile, study_class=student_prev_study_class,
                                                   subject=self.coordination_subject, avg_sem1=8, avg_sem2=8, avg_annual=8, avg_final=8)
        SubjectGradeFactory(student=another_school_profile, catalog_per_subject=catalog1, grade=8)
        SubjectAbsenceFactory(student=another_school_profile, catalog_per_subject=catalog1, is_founded=True)

        catalog2 = StudentCatalogPerSubjectFactory(student=another_school_profile, study_class=student_prev_study_class, subject=self.subject2,
                                                   avg_sem1=10, avg_sem2=10, avg_annual=10, avg_final=10)
        ExaminationGradeFactory(student=another_school_profile, catalog_per_subject=catalog2)

        self.request_data = {
            "new_students": [self.new_student.id]
        }

        response = self.client.patch(self.build_url(self.study_class.id), self.request_data)
        self.assertEqual(response.status_code, status.HTTP_200_OK)

        catalog_per_year = StudentCatalogPerYear.objects.get(student=self.new_student, study_class=prev_study_class)
        for average in [catalog_per_year.avg_sem1, catalog_per_year.avg_sem2, catalog_per_year.avg_annual, catalog_per_year.avg_final]:
            self.assertEqual(average, 9)

        new_catalog1 = StudentCatalogPerSubject.objects.get(student=self.new_student, study_class=prev_study_class,
                                                            subject=self.coordination_subject, teacher=self.teacher1)
        for average in [new_catalog1.avg_sem1, new_catalog1.avg_sem2, new_catalog1.avg_annual, new_catalog1.avg_final]:
            self.assertEqual(average, 8)
        self.assertEqual(new_catalog1.grades.count(), 1)
        self.assertEqual(new_catalog1.absences.count(), 1)

        new_catalog2 = StudentCatalogPerSubject.objects.get(student=self.new_student, study_class=prev_study_class,
                                                            subject=self.subject2, teacher=self.teacher2)
        for average in [new_catalog2.avg_sem1, new_catalog2.avg_sem2, new_catalog2.avg_annual, new_catalog2.avg_final]:
            self.assertEqual(average, 10)
        self.assertEqual(new_catalog2.examination_grades.count(), 1)

        new_catalog3 = StudentCatalogPerSubject.objects.get(student=self.new_student, study_class=prev_study_class,
                                                            subject=self.subject1, teacher=self.teacher1)
        for average in [new_catalog3.avg_sem1, new_catalog3.avg_sem2, new_catalog3.avg_annual, new_catalog3.avg_final]:
            self.assertEqual(average, None)
    def test_send_message_for_one_parent(self, profile_param, mocked_send_sms, mocked_send_mail, mocked_send_mass_mail):
        profile = getattr(self, profile_param)
        self.client.login(username=profile.username, password='******')

        another_study_class = StudyClassFactory(school_unit=self.school_unit)
        another_student = UserProfileFactory(user_role=UserProfile.UserRoles.STUDENT, school_unit=self.school_unit,
                                             student_in_class=another_study_class)
        another_student.parents.add(self.parent)

        response = self.client.post(self.url, self.notification_for_one_parent)
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        self.assertCountEqual(response.data.keys(), self.expected_fields)

        message = Notification.objects.get(id=response.data['id'])
        self.assertEqual(message.from_user_id, profile.id)
        self.assertEqual(message.from_user_role, profile.user_role)
        if profile_param == 'principal':
            self.assertIsNone(message.from_user_subjects)
        else:
            self.assertEqual(message.from_user_subjects, self.subject.name)
        self.assertEqual(message.target_users_role, UserProfile.UserRoles.PARENT)
        self.assertIsNone(message.target_study_class)
        self.assertEqual(message.targets_count, 1)

        self.assertEqual(TargetUserThrough.objects.filter(notification=message).count(), 1)
        target_user_through = TargetUserThrough.objects.get(notification=message, user_profile=self.parent)
        if profile_param == 'principal':
            self.assertEqual(target_user_through.children.count(), 2)
        else:
            self.assertEqual(target_user_through.children.count(), 1)

        self.assertEqual(mocked_send_mail.call_count, 1)
        self.assertEqual(mocked_send_mass_mail.call_count, 0)
        # self.assertEqual(mocked_send_sms.call_count, 1)
        self.assertEqual(mocked_send_sms.call_count, 0)

        if profile_param == 'teacher':
            # Add as teacher to the other class too
            TeacherClassThroughFactory(teacher=self.teacher, study_class=another_study_class, subject=self.another_subject)
            TeacherClassThroughFactory(teacher=self.teacher, study_class=another_study_class, subject=self.subject)

            response = self.client.post(self.url, self.notification_for_one_parent)
            self.assertEqual(response.status_code, status.HTTP_201_CREATED)

            message = Notification.objects.get(id=response.data['id'])
            self.assertEqual(message.from_user_subjects, self.another_subject.name + '__' + self.subject.name)

            target_user_through = TargetUserThrough.objects.get(notification=message, user_profile=self.parent)
            self.assertEqual(target_user_through.children.count(), 2)

            self.assertEqual(mocked_send_mail.call_count, 2)
            self.assertEqual(mocked_send_mass_mail.call_count, 0)
            # self.assertEqual(mocked_send_sms.call_count, 2)
            self.assertEqual(mocked_send_sms.call_count, 0)
    def setUpTestData(cls):
        cls.calendar = AcademicYearCalendarFactory()
        cls.school_unit = RegisteredSchoolUnitFactory()
        cls.school_stats = SchoolUnitStatsFactory(school_unit=cls.school_unit)

        cls.teacher = UserProfileFactory(user_role=UserProfile.UserRoles.TEACHER, school_unit=cls.school_unit)
        cls.study_class = StudyClassFactory(school_unit=cls.school_unit, class_master=cls.teacher)
        cls.subject = SubjectFactory()
        ProgramSubjectThroughFactory(academic_program=cls.study_class.academic_program, subject=cls.subject, weekly_hours_count=3,
                                     class_grade=cls.study_class.class_grade, class_grade_arabic=cls.study_class.class_grade_arabic)
        TeacherClassThroughFactory(teacher=cls.teacher, study_class=cls.study_class, is_class_master=True, subject=cls.subject)

        cls.student1 = UserProfileFactory(user_role=UserProfile.UserRoles.STUDENT, school_unit=cls.school_unit, student_in_class=cls.study_class)
        cls.catalog1 = StudentCatalogPerSubjectFactory(student=cls.student1, study_class=cls.study_class, teacher=cls.teacher, subject=cls.subject)
        cls.catalog_per_year1 = StudentCatalogPerYearFactory(student=cls.student1, study_class=cls.study_class)
        cls.student2 = UserProfileFactory(user_role=UserProfile.UserRoles.STUDENT, school_unit=cls.school_unit, student_in_class=cls.study_class)
        cls.catalog2 = StudentCatalogPerSubjectFactory(student=cls.student2, study_class=cls.study_class, teacher=cls.teacher, subject=cls.subject)
        cls.catalog_per_year2 = StudentCatalogPerYearFactory(student=cls.student2, study_class=cls.study_class)

        cls.expected_fields = [
            'id', 'student', 'avg_sem1', 'avg_sem2', 'avg_annual', 'avg_after_2nd_examination', 'avg_limit', 'abs_count_sem1', 'abs_count_sem2',
            'abs_count_annual', 'founded_abs_count_sem1', 'founded_abs_count_sem2', 'founded_abs_count_annual', 'unfounded_abs_count_sem1',
            'unfounded_abs_count_sem2', 'unfounded_abs_count_annual', 'grades_sem1', 'grades_sem2', 'abs_sem1', 'abs_sem2',
            'second_examination_grades', 'difference_grades_sem1', 'difference_grades_sem2', 'wants_thesis', 'is_exempted',
            'third_of_hours_count_sem1', 'third_of_hours_count_sem2', 'third_of_hours_count_annual', 'is_coordination_subject'
        ]
    def test_send_message_for_one_student(self, profile_param, mocked_send_sms, mocked_send_mail, mocked_send_mass_mail):
        profile = getattr(self, profile_param)
        self.client.login(username=profile.username, password='******')

        subject2 = SubjectFactory(name='Subject 2')
        TeacherClassThroughFactory(teacher=self.teacher, study_class=self.study_class, subject=subject2)

        response = self.client.post(self.url, self.notification_for_one_student)
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        self.assertCountEqual(response.data.keys(), self.expected_fields)

        message = Notification.objects.get(id=response.data['id'])
        self.assertEqual(message.from_user_id, profile.id)
        self.assertEqual(message.from_user_role, profile.user_role)
        if profile_param == 'principal':
            self.assertIsNone(message.from_user_subjects)
        else:
            self.assertEqual(message.from_user_subjects, self.subject.name + '__' + subject2.name)
        self.assertEqual(message.target_users_role, UserProfile.UserRoles.STUDENT)
        self.assertEqual(message.target_study_class_id, self.study_class.id)
        self.assertEqual(message.targets_count, 1)

        self.assertEqual(mocked_send_mail.call_count, 1)
        self.assertEqual(mocked_send_mass_mail.call_count, 0)
        # self.assertEqual(mocked_send_sms.call_count, 1)
        self.assertEqual(mocked_send_sms.call_count, 0)

        self.assertEqual(TargetUserThrough.objects.filter(notification=message).count(), 1)
    def setUpTestData(cls):
        cls.academic_calendar = AcademicYearCalendarFactory()
        cls.corigente_event = SchoolEventFactory(event_type=SchoolEvent.EventTypes.CORIGENTE, academic_year_calendar=cls.academic_calendar,
                                                 starts_at=datetime.date(2020, 8, 20), ends_at=datetime.date(2020, 8, 27))
        cls.diferente_event = SchoolEventFactory(event_type=SchoolEvent.EventTypes.DIFERENTE, academic_year_calendar=cls.academic_calendar,
                                                 starts_at=datetime.date(2020, 9, 1), ends_at=datetime.date(2020, 9, 8))

        cls.school_unit = RegisteredSchoolUnitFactory()
        cls.school_stats = SchoolUnitStatsFactory(school_unit=cls.school_unit)

        cls.teacher = UserProfileFactory(user_role=UserProfile.UserRoles.TEACHER, school_unit=cls.school_unit)
        cls.study_class = StudyClassFactory(school_unit=cls.school_unit, class_grade='IX', class_grade_arabic=9)
        cls.subject = SubjectFactory()
        ProgramSubjectThroughFactory(academic_program=cls.study_class.academic_program, class_grade='IX',
                                     subject=cls.subject, weekly_hours_count=3)

        cls.teacher_class_through = TeacherClassThroughFactory(
            study_class=cls.study_class,
            teacher=cls.teacher,
            subject=cls.subject
        )
        cls.student = UserProfileFactory(user_role=UserProfile.UserRoles.STUDENT, student_in_class=cls.study_class)
        cls.catalog = StudentCatalogPerSubjectFactory(
            subject=cls.subject,
            teacher=cls.teacher,
            student=cls.student,
            study_class=cls.study_class,
            is_enrolled=True
        )
        cls.catalog_per_year = StudentCatalogPerYearFactory(
            student=cls.student,
            study_class=cls.study_class
        )
Exemple #11
0
    def setUpTestData(cls):
        cls.school_unit = RegisteredSchoolUnitFactory()
        cls.teacher = UserProfileFactory(
            user_role=UserProfile.UserRoles.TEACHER,
            school_unit=cls.school_unit)
        cls.academic_year = 2020
        cls.study_class = StudyClassFactory(school_unit=cls.school_unit,
                                            class_master=cls.teacher,
                                            class_grade='IX',
                                            class_grade_arabic=9)
        cls.coordination_subject = SubjectFactory(name='Dirigentie',
                                                  is_coordination=True)
        TeacherClassThroughFactory(study_class=cls.study_class,
                                   teacher=cls.teacher,
                                   subject=cls.coordination_subject,
                                   is_class_master=True)

        cls.subject1 = SubjectFactory(name='Subject')
        cls.subject2 = SubjectFactory(name='Another Subject')

        cls.expected_fields = [
            'id', 'class_grade', 'class_letter', 'academic_year',
            'academic_program_name', 'class_master', 'taught_subjects',
            'is_class_master'
        ]
        cls.class_master_fields = ['id', 'full_name']
        cls.taught_subject_fields = [
            'id', 'name', 'is_coordination', 'allows_exemption', 'is_optional'
        ]
Exemple #12
0
    def setUpTestData(cls):
        cls.academic_calendar = AcademicYearCalendarFactory()
        cls.school_unit = RegisteredSchoolUnitFactory()
        cls.school_stats = SchoolUnitStatsFactory(school_unit=cls.school_unit)

        cls.teacher = UserProfileFactory(
            user_role=UserProfile.UserRoles.TEACHER,
            school_unit=cls.school_unit)
        cls.study_class = StudyClassFactory(school_unit=cls.school_unit)
        cls.subject = SubjectFactory()
        cls.teacher_class_through = TeacherClassThroughFactory(
            study_class=cls.study_class,
            teacher=cls.teacher,
            subject=cls.subject)
        ProgramSubjectThroughFactory(
            academic_program=cls.study_class.academic_program,
            subject=cls.subject,
            weekly_hours_count=1,
            class_grade=cls.study_class.class_grade,
            class_grade_arabic=cls.study_class.class_grade_arabic)

        cls.student = UserProfileFactory(
            user_role=UserProfile.UserRoles.STUDENT,
            full_name='a',
            student_in_class=cls.study_class)
        cls.catalog = StudentCatalogPerSubjectFactory(
            subject=cls.subject,
            teacher=cls.teacher,
            student=cls.student,
            study_class=cls.study_class,
            is_enrolled=True)
        cls.catalog_per_year = StudentCatalogPerYearFactory(
            student=cls.student, study_class=cls.study_class)
Exemple #13
0
    def setUpTestData(cls):
        cls.academic_calendar = AcademicYearCalendarFactory()
        cls.corigente_event = SchoolEventFactory(
            event_type=SchoolEvent.EventTypes.CORIGENTE,
            academic_year_calendar=cls.academic_calendar,
            starts_at=datetime.date(2020, 8, 20),
            ends_at=datetime.date(2020, 8, 27))
        cls.diferente_event = SchoolEventFactory(
            event_type=SchoolEvent.EventTypes.DIFERENTE,
            academic_year_calendar=cls.academic_calendar,
            starts_at=datetime.date(2020, 9, 1),
            ends_at=datetime.date(2020, 9, 8))

        cls.school_unit = RegisteredSchoolUnitFactory()
        cls.school_stats = SchoolUnitStatsFactory(school_unit=cls.school_unit)

        cls.teacher = UserProfileFactory(
            user_role=UserProfile.UserRoles.TEACHER,
            school_unit=cls.school_unit)
        cls.study_class = StudyClassFactory(school_unit=cls.school_unit,
                                            class_grade='IX',
                                            class_grade_arabic=9)
        cls.subject = SubjectFactory()
        ProgramSubjectThroughFactory(
            academic_program=cls.study_class.academic_program,
            class_grade='IX',
            subject=cls.subject,
            weekly_hours_count=3)

        cls.student = UserProfileFactory(
            user_role=UserProfile.UserRoles.STUDENT,
            student_in_class=cls.study_class)
        cls.teacher_class_through = TeacherClassThroughFactory(
            study_class=cls.study_class,
            teacher=cls.teacher,
            subject=cls.subject)
        cls.catalog = StudentCatalogPerSubjectFactory(
            subject=cls.subject,
            teacher=cls.teacher,
            student=cls.student,
            study_class=cls.study_class)
        cls.catalog_per_year = StudentCatalogPerYearFactory(
            student=cls.student, study_class=cls.study_class)

        cls.expected_fields = [
            'id', 'student', 'avg_sem1', 'avg_sem2', 'avg_annual',
            'avg_after_2nd_examination', 'avg_limit', 'abs_count_sem1',
            'abs_count_sem2', 'abs_count_annual', 'founded_abs_count_sem1',
            'founded_abs_count_sem2', 'founded_abs_count_annual',
            'unfounded_abs_count_sem1', 'unfounded_abs_count_sem2',
            'unfounded_abs_count_annual', 'grades_sem1', 'grades_sem2',
            'abs_sem1', 'abs_sem2', 'second_examination_grades',
            'difference_grades_sem1', 'difference_grades_sem2', 'wants_thesis',
            'is_exempted', 'third_of_hours_count_sem1',
            'third_of_hours_count_sem2', 'third_of_hours_count_annual',
            'is_coordination_subject'
        ]
        cls.examination_grade_fields = [
            'id', 'examination_type', 'taken_at', 'grade1', 'grade2', 'created'
        ]
    def test_study_classes_at_risk_teacher(self):
        self.client.login(username=self.teacher.username, password='******')

        study_class1 = StudyClassFactory(school_unit=self.school_unit,
                                         students_at_risk_count=1)
        study_class2 = StudyClassFactory(school_unit=self.school_unit,
                                         students_at_risk_count=2,
                                         class_grade='V',
                                         class_grade_arabic=5)
        study_class3 = StudyClassFactory(school_unit=self.school_unit,
                                         students_at_risk_count=2,
                                         class_grade='IX',
                                         class_grade_arabic=9)
        study_class4 = StudyClassFactory(school_unit=self.school_unit,
                                         students_at_risk_count=0)
        StudyClassFactory(school_unit=self.school_unit,
                          students_at_risk_count=2)

        for study_class in [
                study_class1, study_class2, study_class3, study_class4
        ]:
            TeacherClassThroughFactory(teacher=self.teacher,
                                       study_class=study_class)

        response = self.client.get(self.url)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(len(response.data['results']), 3)
        for result in response.data['results']:
            self.assertCountEqual(result.keys(), self.expected_fields)
        self.assertEqual(response.data['results'][0]['id'], study_class2.id)
        self.assertEqual(response.data['results'][1]['id'], study_class3.id)
        self.assertEqual(response.data['results'][2]['id'], study_class1.id)
    def test_delete_user_teacher_has_classes(self):
        teacher = UserProfileFactory(user_role=UserProfile.UserRoles.TEACHER, school_unit=self.school_unit)
        TeacherClassThroughFactory(teacher=teacher)
        self.client.login(username=self.principal.username, password='******')

        response = self.client.delete(self.build_url(teacher.id))
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
        self.assertEqual(response.data['message'], "This user cannot be deleted because it's either active or has data.")
 def setUpTestData(cls):
     cls.school = RegisteredSchoolUnitFactory()
     cls.teacher = UserProfileFactory(user_role=UserProfile.UserRoles.TEACHER, school_unit=cls.school)
     cls.study_class = StudyClassFactory(school_unit=cls.school)
     cls.subject = SubjectFactory()
     cls.teacher_class_through = TeacherClassThroughFactory(study_class=cls.study_class, teacher=cls.teacher, subject=cls.subject)
     cls.catalog = StudentCatalogPerSubjectFactory(study_class=cls.study_class, teacher=cls.teacher, subject=cls.subject, student__full_name='a')
     cls.current_calendar = AcademicYearCalendarFactory()
    def test_deactivate_teacher_invalid_teachers_array(self):
        self.client.login(username=self.principal.username, password='******')

        teacher = UserProfileFactory(user_role=UserProfile.UserRoles.TEACHER, school_unit=self.school_unit)
        study_class = StudyClassFactory(school_unit=self.school_unit, class_letter='B')
        teacher_class_through1 = TeacherClassThroughFactory(study_class=study_class, teacher=teacher, is_class_master=False)
        teacher_class_through2 = TeacherClassThroughFactory(study_class=study_class, teacher=teacher, is_class_master=False)

        new_teacher = UserProfileFactory(user_role=UserProfile.UserRoles.TEACHER, school_unit=self.school_unit)

        request_data = {
            'new_teachers': [
                {
                    'id': teacher_class_through1.id,
                    'teacher': new_teacher.id
                },
                {
                    'id': teacher_class_through2.id,
                    'teacher': new_teacher.id
                },
                {
                    'id': teacher_class_through1.id,
                    'teacher': new_teacher.id
                }
            ]
        }

        response = self.client.post(self.build_url(teacher.id), data=request_data)
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
        self.assertEqual(response.data['new_teachers'], ['No duplicates allowed.'])

        request_data = {
            'new_teachers': [
                {
                    'id': teacher_class_through1.id,
                    'teacher': new_teacher.id
                }
            ]
        }

        response = self.client.post(self.build_url(teacher.id), data=request_data)
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
        self.assertEqual(response.data['new_teachers'], ['There must be provided teachers for all classes and subjects.'])
 def setUpTestData(cls):
     cls.school_unit = RegisteredSchoolUnitFactory()
     cls.teacher = UserProfileFactory(
         user_role=UserProfile.UserRoles.TEACHER,
         school_unit=cls.school_unit)
     cls.study_class = StudyClassFactory(school_unit=cls.school_unit)
     cls.subject = SubjectFactory()
     cls.teacher_class_through = TeacherClassThroughFactory(
         study_class=cls.study_class,
         teacher=cls.teacher,
         subject=cls.subject)
 def setUpTestData(cls):
     cls.principal = UserProfileFactory(
         user_role=UserProfile.UserRoles.PRINCIPAL)
     cls.school_unit = RegisteredSchoolUnitFactory(
         school_principal=cls.principal)
     cls.teacher = UserProfileFactory(
         user_role=UserProfile.UserRoles.TEACHER,
         school_unit=cls.school_unit)
     cls.study_class = StudyClassFactory(school_unit=cls.school_unit)
     TeacherClassThroughFactory(teacher=cls.teacher,
                                study_class=cls.study_class)
    def test_deactivate_teacher_missing_required_data(self):
        self.client.login(username=self.principal.username, password='******')

        teacher = UserProfileFactory(user_role=UserProfile.UserRoles.TEACHER, school_unit=self.school_unit)
        study_class = StudyClassFactory(school_unit=self.school_unit, class_letter='B')
        TeacherClassThroughFactory(study_class=study_class, teacher=teacher, is_class_master=False)

        for req_data in [{}, {'new_teachers': []}]:
            response = self.client.post(self.build_url(teacher.id), data=req_data)
            self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
            self.assertEqual(response.data['new_teachers'], ['This field is required.'])
 def setUpTestData(cls):
     cls.school_unit = RegisteredSchoolUnitFactory()
     cls.teacher = UserProfileFactory(user_role=UserProfile.UserRoles.TEACHER, school_unit=cls.school_unit)
     cls.study_class = StudyClassFactory(school_unit=cls.school_unit, class_master=cls.teacher)
     cls.teacher_class_through = TeacherClassThroughFactory(
         study_class=cls.study_class,
         teacher=cls.teacher,
         is_class_master=True,
     )
     cls.catalog1 = StudentCatalogPerYearFactory(
         student=UserProfileFactory(user_role=UserProfile.UserRoles.STUDENT, full_name='a'),
         study_class=cls.study_class,
         academic_year=2020,
         avg_sem1=1,
         avg_sem2=1,
         avg_final=1,
         abs_count_sem1=1,
         abs_count_sem2=1,
         abs_count_annual=1
     )
     cls.catalog2 = StudentCatalogPerYearFactory(
         student=UserProfileFactory(user_role=UserProfile.UserRoles.STUDENT, full_name='b'),
         study_class=cls.study_class,
         academic_year=2020,
         avg_sem1=2,
         avg_sem2=2,
         avg_final=2,
         abs_count_sem1=2,
         abs_count_sem2=2,
         abs_count_annual=2
     )
     cls.catalog3 = StudentCatalogPerYearFactory(
         student=UserProfileFactory(user_role=UserProfile.UserRoles.STUDENT, full_name='c'),
         study_class=cls.study_class,
         academic_year=2020,
         avg_sem1=3,
         avg_sem2=3,
         avg_final=3,
         abs_count_sem1=3,
         abs_count_sem2=3,
         abs_count_annual=3
     )
     cls.catalog4 = StudentCatalogPerYearFactory(
         student=UserProfileFactory(user_role=UserProfile.UserRoles.STUDENT, full_name='d'),
         study_class=cls.study_class,
         academic_year=2020,
         avg_sem1=4,
         avg_sem2=4,
         avg_final=4,
         abs_count_sem1=4,
         abs_count_sem2=4,
         abs_count_annual=4
     )
Exemple #22
0
    def setUp(self):
        self.teacher_class_through1 = TeacherClassThroughFactory(study_class=self.study_class, teacher=self.teacher1,
                                                                 subject=self.coordination_subject, is_class_master=True)
        self.teacher_class_through2 = TeacherClassThroughFactory(study_class=self.study_class, teacher=self.teacher1, subject=self.subject1,
                                                                 is_class_master=True)
        self.teacher_class_through3 = TeacherClassThroughFactory(study_class=self.study_class, teacher=self.teacher2, subject=self.subject2,
                                                                 is_class_master=False, is_optional_subject=True)

        self.subject_catalog1 = StudentCatalogPerSubjectFactory(student=self.student1, teacher=self.teacher1,
                                                                study_class=self.study_class, subject=self.coordination_subject)
        self.subject_catalog2 = StudentCatalogPerSubjectFactory(student=self.student1, teacher=self.teacher1,
                                                                study_class=self.study_class, subject=self.subject1)
        self.subject_catalog3 = StudentCatalogPerSubjectFactory(student=self.student1, teacher=self.teacher2,
                                                                study_class=self.study_class, subject=self.subject2)
        self.subject_catalog4 = StudentCatalogPerSubjectFactory(student=self.student2, teacher=self.teacher1,
                                                                study_class=self.study_class, subject=self.coordination_subject)
        self.subject_catalog5 = StudentCatalogPerSubjectFactory(student=self.student2, teacher=self.teacher1,
                                                                study_class=self.study_class, subject=self.subject1)
        self.subject_catalog6 = StudentCatalogPerSubjectFactory(student=self.student2, teacher=self.teacher2,
                                                                study_class=self.study_class, subject=self.subject2)

        self.request_data = {
            "class_master": self.teacher2.id,
            "updated_teachers": [
                {
                    "id": self.teacher_class_through2.id,
                    "teacher": self.teacher2.id,
                },
                {
                    "id": self.teacher_class_through3.id,
                    "teacher": self.teacher1.id,
                }
            ],
            "new_students": [
                self.new_student.id
            ],
            "deleted_students": [
                self.student2.id
            ]
        }
Exemple #23
0
    def test_student_list_teacher(self):
        self.client.login(username=self.teacher.username, password='******')

        study_class = StudyClassFactory(school_unit=self.school_unit)
        TeacherClassThroughFactory(study_class=study_class,
                                   teacher=self.teacher)

        student1 = UserProfileFactory(user_role=UserProfile.UserRoles.STUDENT,
                                      full_name='John Doe',
                                      school_unit=self.school_unit,
                                      student_in_class=study_class)
        student2 = UserProfileFactory(user_role=UserProfile.UserRoles.STUDENT,
                                      full_name='Another student',
                                      school_unit=self.school_unit,
                                      student_in_class=study_class)
        student3 = UserProfileFactory(user_role=UserProfile.UserRoles.STUDENT,
                                      full_name='Jane Doe',
                                      school_unit=self.school_unit,
                                      student_in_class=study_class)
        UserProfileFactory(user_role=UserProfile.UserRoles.STUDENT,
                           school_unit=self.school_unit)
        UserProfileFactory(user_role=UserProfile.UserRoles.STUDENT,
                           is_active=False,
                           school_unit=self.school_unit)

        response = self.client.get(self.url)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual([student2.id, student3.id, student1.id],
                         [student['id'] for student in response.data])

        expected_fields = ['id', 'full_name']
        for student in response.data:
            self.assertCountEqual(student.keys(), expected_fields)

        response = self.client.get(self.url, {'search': 'Jane'})
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual([
            student3.id,
        ], [student['id'] for student in response.data])

        response = self.client.get(self.url, {'has_class': 'false'})
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(len(response.data), 0)

        response = self.client.get(self.url, {
            'has_class': 'false',
            'search': 'John'
        })
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(len(response.data), 0)
Exemple #24
0
    def test_bulk_create_grade_coordination_subject(self):
        self.client.login(username=self.teacher.username, password='******')
        subject = SubjectFactory(is_coordination=True)
        TeacherClassThroughFactory(teacher=self.teacher,
                                   study_class=self.study_class,
                                   is_class_master=True,
                                   subject=subject)

        response = self.client.post(self.build_url(self.study_class.id,
                                                   subject.id),
                                    data=self.request_data)
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
        self.assertEqual(response.data['message'],
                         "Can't add grades for coordination subject.")
 def setUpTestData(cls):
     cls.calendar = AcademicYearCalendarFactory()
     cls.school_unit = RegisteredSchoolUnitFactory()
     cls.teacher = UserProfileFactory(user_role=UserProfile.UserRoles.TEACHER, school_unit=cls.school_unit)
     cls.student = UserProfileFactory(user_role=UserProfile.UserRoles.STUDENT, school_unit=cls.school_unit)
     cls.study_class = StudyClassFactory(school_unit=cls.school_unit, class_grade='IX', class_grade_arabic=9)
     cls.subject = SubjectFactory()
     cls.teacher_class_through = TeacherClassThroughFactory(
         study_class=cls.study_class,
         teacher=cls.teacher,
         subject=cls.subject
     )
     ProgramSubjectThroughFactory(academic_program=cls.study_class.academic_program, class_grade='IX',
                                  subject=cls.subject, weekly_hours_count=3)
    def setUpTestData(cls):
        AcademicYearCalendarFactory()
        cls.school_unit = RegisteredSchoolUnitFactory()
        cls.teacher = UserProfileFactory(
            user_role=UserProfile.UserRoles.TEACHER,
            school_unit=cls.school_unit)
        cls.study_class = StudyClassFactory(school_unit=cls.school_unit,
                                            class_grade='IX',
                                            class_grade_arabic=9)
        cls.subject = SubjectFactory()
        ProgramSubjectThroughFactory(
            academic_program=cls.study_class.academic_program,
            subject=cls.subject,
            weekly_hours_count=1)

        cls.teacher_class_through = TeacherClassThroughFactory(
            study_class=cls.study_class,
            teacher=cls.teacher,
            subject=cls.subject)

        cls.student1 = UserProfileFactory(
            user_role=UserProfile.UserRoles.STUDENT,
            student_in_class=cls.study_class)
        cls.catalog1 = StudentCatalogPerSubjectFactory(
            subject=cls.subject,
            teacher=cls.teacher,
            student=cls.student1,
            study_class=cls.study_class,
            avg_sem1=10,
            avg_sem2=10,
            avg_annual=10,
            avg_final=10)
        for semester in [1, 2]:
            for i in range(2):
                SubjectGradeFactory(student=cls.student1,
                                    catalog_per_subject=cls.catalog1,
                                    semester=semester)

        cls.student2 = UserProfileFactory(
            user_role=UserProfile.UserRoles.STUDENT,
            student_in_class=cls.study_class)
        cls.catalog2 = StudentCatalogPerSubjectFactory(
            subject=cls.subject,
            teacher=cls.teacher,
            student=cls.student2,
            study_class=cls.study_class)
 def setUpTestData(cls):
     cls.school_unit = RegisteredSchoolUnitFactory()
     cls.teacher = UserProfileFactory(user_role=UserProfile.UserRoles.TEACHER, school_unit=cls.school_unit)
     cls.student = UserProfileFactory(user_role=UserProfile.UserRoles.STUDENT, school_unit=cls.school_unit)
     cls.study_class = StudyClassFactory(school_unit=cls.school_unit, class_master=cls.teacher)
     cls.subject = SubjectFactory()
     cls.teacher.taught_subjects.add(cls.subject)
     cls.teacher_class_through = TeacherClassThroughFactory(
         study_class=cls.study_class,
         teacher=cls.teacher,
         subject=cls.subject
     )
     cls.catalog = StudentCatalogPerYearFactory(
         student=UserProfileFactory(user_role=UserProfile.UserRoles.STUDENT, full_name='a'),
         study_class=cls.study_class,
         academic_year=2020
     )
Exemple #28
0
 def setUpTestData(cls):
     cls.school = RegisteredSchoolUnitFactory()
     cls.teacher = UserProfileFactory(
         user_role=UserProfile.UserRoles.TEACHER, school_unit=cls.school)
     cls.study_class = StudyClassFactory(school_unit=cls.school,
                                         class_grade='IX',
                                         class_grade_arabic=9,
                                         class_letter='A')
     cls.student = UserProfileFactory(
         user_role=UserProfile.UserRoles.STUDENT,
         school_unit=cls.school,
         student_in_class=cls.study_class)
     cls.subject = SubjectFactory()
     cls.teacher_class_through = TeacherClassThroughFactory(
         study_class=cls.study_class,
         teacher=cls.teacher,
         subject=cls.subject)
     cls.current_calendar = AcademicYearCalendarFactory()
     cls.label = LabelFactory(user_role=UserProfile.UserRoles.STUDENT,
                              text='good')
     cls.label2 = LabelFactory(user_role=UserProfile.UserRoles.STUDENT,
                               text='v good')
     cls.subject_through = ProgramSubjectThroughFactory(
         subject=cls.subject,
         class_grade='IX',
         class_grade_arabic=9,
         is_mandatory=True,
         generic_academic_program=cls.study_class.academic_program.
         generic_academic_program,
         weekly_hours_count=1,
     )
     cls.differences_event = SchoolEventFactory(
         event_type=SchoolEvent.EventTypes.DIFERENTE,
         semester=cls.current_calendar.first_semester,
         academic_year_calendar=cls.current_calendar,
         starts_at=datetime.date(2019, 12, 21),
         ends_at=datetime.date(2019, 12, 23))
     cls.second_examination_event = SchoolEventFactory(
         event_type=SchoolEvent.EventTypes.CORIGENTE,
         academic_year_calendar=cls.current_calendar,
         starts_at=datetime.date(2020, 5, 4),
         ends_at=datetime.date(2020, 5, 7))
     cls.catalog_per_year = StudentCatalogPerYearFactory(
         study_class=cls.study_class, student=cls.student)
     cls.file_name = 'file.csv'
Exemple #29
0
    def setUpTestData(cls):
        cls.principal = UserProfileFactory(user_role=UserProfile.UserRoles.PRINCIPAL)
        cls.school_unit = RegisteredSchoolUnitFactory(school_principal=cls.principal)

        cls.category1 = SchoolUnitCategoryFactory(category_level=SchoolUnitCategory.CategoryLevels.SECONDARY_SCHOOL)
        cls.category2 = SchoolUnitCategoryFactory(category_level=SchoolUnitCategory.CategoryLevels.HIGHSCHOOL)
        cls.school_unit.categories.add(cls.category1, cls.category2)

        cls.calendar = AcademicYearCalendarFactory()

        cls.subject1 = SubjectFactory()
        cls.subject2 = SubjectFactory()
        cls.coordination_subject = SubjectFactory(is_coordination=True)
        cls.academic_program = AcademicProgramFactory(school_unit=cls.school_unit)
        for class_grade, class_grade_arabic in zip(['VI', 'X'], [6, 10]):
            ProgramSubjectThroughFactory(academic_program=cls.academic_program, subject=cls.subject1,
                                         is_mandatory=False, class_grade=class_grade, class_grade_arabic=class_grade_arabic)
            ProgramSubjectThroughFactory(generic_academic_program=cls.academic_program.generic_academic_program,
                                         subject=cls.subject2, class_grade=class_grade, class_grade_arabic=class_grade_arabic)

        cls.teacher1 = UserProfileFactory(user_role=UserProfile.UserRoles.TEACHER, school_unit=cls.school_unit)
        cls.teacher2 = UserProfileFactory(user_role=UserProfile.UserRoles.TEACHER, school_unit=cls.school_unit)
        cls.teacher1.taught_subjects.add(cls.subject1, cls.subject2)
        cls.teacher2.taught_subjects.add(cls.subject1, cls.subject2)

        cls.study_class1 = StudyClassFactory(school_unit=cls.school_unit, class_master=cls.teacher1, academic_program=cls.academic_program,
                                             class_grade='X', class_grade_arabic=10, class_letter='A')
        TeacherClassThroughFactory(study_class=cls.study_class1, teacher=cls.teacher1, subject=cls.coordination_subject, is_class_master=True)
        cls.study_class2 = StudyClassFactory(school_unit=cls.school_unit, class_master=cls.teacher2, academic_program=cls.academic_program)
        TeacherClassThroughFactory(study_class=cls.study_class2, teacher=cls.teacher2, subject=cls.coordination_subject, is_class_master=True)

        TeacherClassThroughFactory(study_class=cls.study_class1, teacher=cls.teacher1, subject=cls.subject1, is_class_master=True)
        TeacherClassThroughFactory(study_class=cls.study_class1, teacher=cls.teacher2, subject=cls.subject2, is_class_master=False)
        TeacherClassThroughFactory(study_class=cls.study_class2, teacher=cls.teacher1, subject=cls.subject1, is_class_master=False)
        TeacherClassThroughFactory(study_class=cls.study_class2, teacher=cls.teacher2, subject=cls.subject2, is_class_master=True)

        cls.student1 = UserProfileFactory(user_role=UserProfile.UserRoles.STUDENT, school_unit=cls.school_unit, student_in_class=cls.study_class1)
        StudentCatalogPerYearFactory(student=cls.student1, study_class=cls.study_class1)
        cls.student2 = UserProfileFactory(user_role=UserProfile.UserRoles.STUDENT, school_unit=cls.school_unit, student_in_class=cls.study_class1)
        StudentCatalogPerYearFactory(student=cls.student2, study_class=cls.study_class1)
        cls.student3 = UserProfileFactory(user_role=UserProfile.UserRoles.STUDENT, school_unit=cls.school_unit, student_in_class=cls.study_class2)
        StudentCatalogPerYearFactory(student=cls.student3, study_class=cls.study_class2)

        cls.academic_program2 = AcademicProgramFactory(school_unit=cls.school_unit)
        for class_grade, class_grade_arabic in zip(['VII', 'XI'], [7, 11]):
            ProgramSubjectThroughFactory(academic_program=cls.academic_program2, subject=cls.subject1,
                                         is_mandatory=False, class_grade=class_grade, class_grade_arabic=class_grade_arabic)
            ProgramSubjectThroughFactory(generic_academic_program=cls.academic_program2.generic_academic_program,
                                         subject=cls.subject2, class_grade=class_grade, class_grade_arabic=class_grade_arabic)

        cls.new_teacher = UserProfileFactory(user_role=UserProfile.UserRoles.TEACHER, school_unit=cls.school_unit)
        cls.new_student = UserProfileFactory(user_role=UserProfile.UserRoles.STUDENT, school_unit=cls.school_unit)
Exemple #30
0
 def setUpTestData(cls):
     cls.principal = UserProfileFactory(
         user_role=UserProfile.UserRoles.PRINCIPAL)
     cls.school_unit = RegisteredSchoolUnitFactory(
         school_principal=cls.principal)
     cls.teacher = UserProfileFactory(
         user_role=UserProfile.UserRoles.TEACHER,
         school_unit=cls.school_unit)
     cls.study_class = StudyClassFactory(school_unit=cls.school_unit)
     TeacherClassThroughFactory(teacher=cls.teacher,
                                study_class=cls.study_class)
     cls.notification = NotificationFactory()
     cls.expected_fields = [
         'id', 'title', 'created', 'send_sms', 'status', 'receiver_type',
         'target_users_role', 'target_study_class', 'target_user_through',
         'body'
     ]
     cls.expected_study_class_fields = ['id', 'class_grade', 'class_letter']