Beispiel #1
0
    def test_is_director_fails_if_user_is_not_a_director(self):

        mock_request = HttpRequest()
        mock_request.user = self.user

        permission_class = IsDirector()
        authorization_response = permission_class.has_permission(
            mock_request, None)

        assert authorization_response is False, "Permission should be denied"
Beispiel #2
0
    def test_is_director_passes_if_user_is_director(self):

        mock_request = HttpRequest()
        self.user.add_role("Director")
        mock_request.user = self.user

        permission_class = IsDirector()
        authorization_response = permission_class.has_permission(
            mock_request, None)

        assert authorization_response is True, "Permission should be granted"