def test_is_sic_eligible(self): sic_manager = SICFactory() for education_group_year in [self.common_bachelor, self.training]: perm = GeneralInformationPerms(sic_manager.user, education_group_year) self.assertTrue(perm._is_sic_eligible())
def test_is_faculty_manager_eligible(self): faculty_manager = FacultyManagerFactory() for education_group_year in [self.training, self.common_bachelor]: perm = GeneralInformationPerms(faculty_manager.user, education_group_year) self.assertTrue(perm._is_faculty_manager_eligible())
def test_is_eligible_case_user_is_sic(self, mock_is_sic_eligible, mock_user_have_perm, mock_super_is_eligible): sic = SICFactory() perm = GeneralInformationPerms(sic.user, self.common_bachelor) perm._is_eligible() self.assertTrue(mock_super_is_eligible.called) self.assertTrue(mock_is_sic_eligible.called)
def test_is_not_eligible_case_user_is_faculty_manager_for_ue( self, mock_super_is_eligible): faculty_manager = UEFacultyManagerFactory() perm = GeneralInformationPerms(faculty_manager.user, self.common_bachelor) with self.assertRaises(PermissionDenied): perm._is_eligible() self.assertTrue(mock_super_is_eligible.called)
def test_is_eligible_case_user_is_faculty_manager(self, mock_is_faculty_eligible, mock_user_have_perm, mock_super_is_eligible): faculty_manager = FacultyManagerFactory() perm = GeneralInformationPerms(faculty_manager.user, self.common_bachelor) perm._is_eligible() self.assertTrue(mock_super_is_eligible.called) self.assertTrue(mock_is_faculty_eligible.called)
def test_is_faculty_manager_case_cannot_modify_data_in_past(self): previous_year = self.current_academic_year.year - 1 training_in_past = TrainingFactory(academic_year__year=previous_year) common_in_past = EducationGroupYearCommonBachelorFactory(academic_year__year=previous_year) faculty_manager = FacultyManagerFactory() for education_group_year in [training_in_past, common_in_past]: perm = GeneralInformationPerms(faculty_manager.user, education_group_year) with self.assertRaises(PermissionDenied): perm._is_faculty_manager_eligible()
def test_is_user_have_perm_for_non_common_case_user_with_perm(self): person = PersonWithPermissionsFactory("change_pedagogyinformation") perm = GeneralInformationPerms(person.user, self.training) self.assertTrue(perm._is_user_have_perm())
def test_is_user_have_perm_for_non_common_case_user_without_perm(self): person = PersonWithPermissionsFactory() perm = GeneralInformationPerms(person.user, self.training) self.assertFalse(perm._is_user_have_perm())
def test_is_not_eligible_case_user_is_administrative_manager(self, ): administrative_manager = AdministrativeManagerFactory() perm = GeneralInformationPerms(administrative_manager.user, self.common_bachelor) self.assertFalse(perm.is_eligible())