Esempio n. 1
0
    def test_raise_permission_denied_if_person_is_faculty_manager_and_period_closed(self):
        CloseAcademicCalendarFactory(reference=EDUCATION_GROUP_EDITION, academic_year=self.previous_acy)
        person_entity = PersonEntityFactory(entity=self.group_element_year.parent.management_entity,
                                            person=FacultyManagerFactory())

        with self.assertRaises(PermissionDenied):
            can_update_group_element_year(person_entity.person.user, self.group_element_year)
Esempio n. 2
0
    def test_raise_permission_denied_if_person_is_faculty_manager_and_period_closed(
            self):
        CloseAcademicCalendarFactory(reference=EDUCATION_GROUP_EDITION,
                                     academic_year=self.current_acy)

        with self.assertRaises(PermissionDenied):
            can_update_group_element_year(self.faculty_manager.user,
                                          self.group_element_year)
Esempio n. 3
0
    def test_raise_permission_denied_when_minor_or_major_list_choice_and_person_is_faculty_manager(self):
        OpenAcademicCalendarFactory(reference=EDUCATION_GROUP_EDITION, academic_year=self.previous_acy)
        egys = [
            GroupFactory(education_group_type__name=GroupType.MINOR_LIST_CHOICE.name, academic_year=self.current_acy),
            GroupFactory(education_group_type__name=GroupType.MAJOR_LIST_CHOICE.name, academic_year=self.current_acy)
        ]
        person_entity = PersonEntityFactory(entity=self.group_element_year.parent.management_entity,
                                            person=FacultyManagerFactory())

        for egy in egys:
            with self.subTest(type=egy.education_group_type):
                with self.assertRaises(PermissionDenied):
                    group_element_year = GroupElementYearFactory(parent=self.group_element_year.parent,
                                                                 child_branch=egy)
                    can_update_group_element_year(person_entity.person.user, group_element_year)
Esempio n. 4
0
    def test_true_if_person_is_faculty_manager_and_period_open(self):
        OpenAcademicCalendarFactory(reference=EDUCATION_GROUP_EDITION,
                                    academic_year=self.current_acy)

        self.assertTrue(
            can_update_group_element_year(self.faculty_manager.user,
                                          self.group_element_year))
Esempio n. 5
0
    def test_return_true_if_is_central_manager(self):
        person_entity = PersonEntityFactory(
            entity=self.group_element_year.parent.management_entity,
            person=CentralManagerFactory())

        self.assertTrue(
            can_update_group_element_year(person_entity.person.user,
                                          self.group_element_year))
Esempio n. 6
0
    def test_return_true_if_child_is_learning_unit_and_user_is_central_manager(
            self):
        GroupElementYearChildLeafFactory(parent=self.group_element_year.parent)
        person_entity = PersonEntityFactory(
            entity=self.group_element_year.parent.management_entity,
            person=CentralManagerFactory())

        self.assertTrue(
            can_update_group_element_year(person_entity.person.user,
                                          self.group_element_year))
Esempio n. 7
0
    def test_return_true_if_is_central_manager(self):
        central_manager = create_person_with_permission_and_group(
            CENTRAL_MANAGER_GROUP, 'change_educationgroup')
        person_entity = PersonEntityFactory(
            entity=self.group_element_year.parent.management_entity,
            person=central_manager)

        self.assertTrue(
            can_update_group_element_year(person_entity.person.user,
                                          self.group_element_year))
Esempio n. 8
0
 def test_raise_permission_denied_when_user_not_linked_to_entity(self):
     person = PersonFactory()
     with self.assertRaises(PermissionDenied):
         can_update_group_element_year(person.user, self.group_element_year)