def test_raise_permission_denied_if_person_is_faculty_manager_and_period_closed( self): CloseAcademicCalendarFactory(reference=EDUCATION_GROUP_EDITION, academic_year=self.current_acy, data_year=self.current_acy) with self.assertRaises(PermissionDenied): can_update_group_element_year(self.faculty_manager.user, self.group_element_year)
def test_true_if_person_has_both_roles(self, mock_permission): mock_permission.return_value = True person_with_both_roles = PersonWithPermissionsFactory( 'change_educationgroupcontent', groups=(PROGRAM_MANAGER_GROUP, FACULTY_MANAGER_GROUP)) self.assertTrue( can_update_group_element_year(person_with_both_roles.user, self.group_element_year))
def test_true_if_person_is_faculty_manager_and_period_open(self): OpenAcademicCalendarFactory(reference=EDUCATION_GROUP_EDITION, academic_year=self.current_acy, data_year=self.current_acy) self.assertTrue( can_update_group_element_year(self.faculty_manager.user, self.group_element_year))
def test_return_true_if_is_central_manager(self): central_manager = CentralManagerFactory( 'change_educationgroup', 'change_educationgroupcontent') 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))
def test_return_true_if_child_is_learning_unit_and_user_is_central_manager( self): central_manager = CentralManagerFactory( 'change_educationgroup', 'change_educationgroupcontent') GroupElementYearChildLeafFactory(parent=self.group_element_year.parent) 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))
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.current_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) ] 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(self.faculty_manager.user, group_element_year)
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)
def test_raise_permission_denied_if_person_is_program_manager(self): program_manager = PersonWithPermissionsFactory( groups=(PROGRAM_MANAGER_GROUP, )) with self.assertRaises(PermissionDenied): can_update_group_element_year(program_manager.user, self.group_element_year)