Example #1
0
    def test_ensure_is_eligible_case_permission_denied(
            self, mock_linked_to_management, mock_is_current_in_range):
        perm = CommonEducationGroupStrategyPerms(self.person.user,
                                                 TrainingFactory())

        with self.assertRaises(PermissionDenied):
            perm._is_eligible()
Example #2
0
    def test_is_eligible_case_user_as_superuser_case_lower_than_limit_year(
            self):
        super_user = UserFactory(is_superuser=True)
        training = TrainingFactory(
            academic_year__year=settings.YEAR_LIMIT_EDG_MODIFICATION - 1)

        perm = CommonEducationGroupStrategyPerms(super_user, training)
        with self.assertRaises(PermissionDenied):
            perm._is_eligible()
Example #3
0
    def test_ensure_is_eligible_case_all_submethod_true(
            self, mock_linked_to_management, mock_is_current_in_range):
        perm = CommonEducationGroupStrategyPerms(self.person.user,
                                                 TrainingFactory())

        self.assertTrue(perm._is_eligible())
        self.assertTrue(mock_linked_to_management.called)
        self.assertTrue(mock_is_current_in_range.called)
Example #4
0
    def test_is_eligible_case_user_as_superuser_case_greater_or_equal_limit_year(
            self):
        super_user = UserFactory(is_superuser=True)
        training = TrainingFactory(
            academic_year__year=settings.YEAR_LIMIT_EDG_MODIFICATION)

        perm = CommonEducationGroupStrategyPerms(super_user, training)
        self.assertTrue(perm._is_eligible())
Example #5
0
    def test_is_eligible_case_user_as_superuser(self):
        super_user = UserFactory(is_superuser=True)
        training = TrainingFactory()

        perm = CommonEducationGroupStrategyPerms(super_user, training)
        self.assertTrue(perm._is_eligible())