Beispiel #1
0
    def test__unit__ProfileChecker__ok__nominal_case(self):
        class FakeTracimContext(TracimContext):
            current_user = User(user_id=2)
            current_user.groups.append(Group(group_id=2))

        assert ProfileChecker(1).check(FakeTracimContext())
        assert ProfileChecker(2).check(FakeTracimContext())
Beispiel #2
0
    def test__unit__ProfileChecker__err__profile_insufficient(self):
        class FakeBaseFakeTracimContext(BaseFakeTracimContext):
            current_user = User(user_id=2)
            current_user.profile = Profile.TRUSTED_USER

        assert ProfileChecker(Profile.USER).check(FakeBaseFakeTracimContext())
        with pytest.raises(InsufficientUserProfile):
            ProfileChecker(Profile.ADMIN).check(FakeBaseFakeTracimContext())
Beispiel #3
0
    def test__unit__ProfileChecker__ok__nominal_case(self):
        class FakeBaseFakeTracimContext(BaseFakeTracimContext):
            current_user = User(user_id=2)
            current_user.profile = Profile.TRUSTED_USER

        assert ProfileChecker(Profile.USER).check(FakeBaseFakeTracimContext())
        assert ProfileChecker(Profile.TRUSTED_USER).check(
            FakeBaseFakeTracimContext())
Beispiel #4
0
    def test__unit__ProfileChecker__err__profile_insufficient(self):
        class FakeTracimContext(TracimContext):
            current_user = User(user_id=2)
            current_user.groups.append(Group(group_id=2))

        assert ProfileChecker(2).check(FakeTracimContext())
        with pytest.raises(InsufficientUserProfile):
            ProfileChecker(3).check(FakeTracimContext())
        with pytest.raises(InsufficientUserProfile):
            ProfileChecker(4).check(FakeTracimContext())