Esempio n. 1
0
    def test__unit__CandidateUserProfileChecker__ok__nominal_case(self):
        class FakeTracimContext(TracimContext):
            candidate_user = User(user_id=2)
            candidate_user.groups.append(Group(group_id=2))

        assert CandidateUserProfileChecker(1).check(FakeTracimContext())
        assert CandidateUserProfileChecker(2).check(FakeTracimContext())
Esempio n. 2
0
    def test__unit__CandidateUserProfileChecker__ok__nominal_case(self):
        class FakeBaseFakeTracimContext(BaseFakeTracimContext):
            candidate_user = User(user_id=2)
            candidate_user.profile = Profile.TRUSTED_USER

        assert CandidateUserProfileChecker(Profile.USER).check(
            FakeBaseFakeTracimContext())
        assert CandidateUserProfileChecker(Profile.TRUSTED_USER).check(
            FakeBaseFakeTracimContext())
Esempio n. 3
0
    def test__unit__CandidateUserProfileChecker__err__profile_insufficient(
            self):
        class FakeTracimContext(TracimContext):
            candidate_user = User(user_id=2)
            candidate_user.groups.append(Group(group_id=2))

        assert CandidateUserProfileChecker(2).check(FakeTracimContext())
        with pytest.raises(InsufficientUserProfile):
            CandidateUserProfileChecker(3).check(FakeTracimContext())
        with pytest.raises(InsufficientUserProfile):
            CandidateUserProfileChecker(4).check(FakeTracimContext())
Esempio n. 4
0
    def test__unit__CandidateUserProfileChecker__err__profile_insufficient(
            self):
        class FakeBaseFakeTracimContext(BaseFakeTracimContext):
            candidate_user = User(user_id=2)
            candidate_user.profile = Profile.TRUSTED_USER

        assert CandidateUserProfileChecker(Profile.TRUSTED_USER).check(
            FakeBaseFakeTracimContext())
        with pytest.raises(InsufficientUserProfile):
            CandidateUserProfileChecker(Profile.ADMIN).check(
                FakeBaseFakeTracimContext())