# Path: django_core/views/mixins/auth.py
# class StaffRequiredViewMixin(LoginRequiredViewMixin):
#     """Require a logged in Staff member."""
# 
#     def dispatch(self, request, *args, **kwargs):
#         if not request.user.is_staff:
#             raise PermissionDenied
# 
#         return super(StaffRequiredViewMixin, self).dispatch(request,
#                                                             *args,
#                                                             **kwargs)
# 
# Path: django_core/views/mixins/auth.py
# class SuperuserRequiredViewMixin(LoginRequiredViewMixin):
#     """Require a logged in user to be a superuser."""
# 
#     def dispatch(self, request, *args, **kwargs):
#         if not request.user.is_superuser:
#             raise PermissionDenied
# 
#         return super(SuperuserRequiredViewMixin, self).dispatch(request,
#                                                                 *args,
#                                                                 **kwargs)


import uuid
from django.contrib.auth import get_user_model
from django.core.exceptions import PermissionDenied
from django.core.handlers.wsgi import WSGIHandler
from django.test import Client
from django.test import TestCase
from django_core.views import StaffRequiredViewMixin
from django_core.views import SuperuserRequiredViewMixin
from mock import patch
        request = WSGIHandler()
        request.user = self.user

        mixin = StaffRequiredViewMixin()
        actual_return = mixin.dispatch(request)

        self.assertEqual(actual_return, dispatch.return_value)

    def test_superuser_required_mixin_not_supersuer(self):
        """Test for mixin requiring a superuser when user isn't a superuser."""
        self.client.login(username=self.username, password=self.password)

        with self.assertRaises(PermissionDenied):
            request = WSGIHandler()
            request.user = self.user

            mixin = SuperuserRequiredViewMixin()
            mixin.dispatch(request)

    @patch('django_core.views.mixins.auth.LoginRequiredViewMixin.dispatch')
    def test_superuser_required_mixin_is_supersuer(self, dispatch):
        """Test for mixin requiring a superuser when user is a superuser."""
        dispatch.return_value = 'worked'

        self.client.login(username=self.username, password=self.password)
        self.user.is_superuser = True

        request = WSGIHandler()
        request.user = self.user


# Path: django_core/views/mixins/auth.py
# class StaffRequiredViewMixin(LoginRequiredViewMixin):
#     """Require a logged in Staff member."""
# 
#     def dispatch(self, request, *args, **kwargs):
#         if not request.user.is_staff:
#             raise PermissionDenied
# 
#         return super(StaffRequiredViewMixin, self).dispatch(request,
#                                                             *args,
#                                                             **kwargs)
# 
# Path: django_core/views/mixins/auth.py
# class SuperuserRequiredViewMixin(LoginRequiredViewMixin):
#     """Require a logged in user to be a superuser."""
# 
#     def dispatch(self, request, *args, **kwargs):
#         if not request.user.is_superuser:
#             raise PermissionDenied
# 
#         return super(SuperuserRequiredViewMixin, self).dispatch(request,
#                                                                 *args,
#                                                                 **kwargs)


# Path: tests/test_auth_mixins.py
import uuid
from django.contrib.auth import get_user_model
from django.core.exceptions import PermissionDenied
from django.core.handlers.wsgi import WSGIHandler
from django.test import Client
from django.test import TestCase
from django_core.views import StaffRequiredViewMixin
from django_core.views import SuperuserRequiredViewMixin
from mock import patch

        request = WSGIHandler()
        request.user = self.user

        mixin = StaffRequiredViewMixin()
        actual_return = mixin.dispatch(request)

        self.assertEqual(actual_return, dispatch.return_value)

    def test_superuser_required_mixin_not_supersuer(self):
        """Test for mixin requiring a superuser when user isn't a superuser."""
        self.client.login(username=self.username, password=self.password)

        with self.assertRaises(PermissionDenied):
            request = WSGIHandler()
            request.user = self.user

            mixin = SuperuserRequiredViewMixin()
            mixin.dispatch(request)

    @patch('django_core.views.mixins.auth.LoginRequiredViewMixin.dispatch')
    def test_superuser_required_mixin_is_supersuer(self, dispatch):
        """Test for mixin requiring a superuser when user is a superuser."""
        dispatch.return_value = 'worked'

        self.client.login(username=self.username, password=self.password)
        self.user.is_superuser = True

        request = WSGIHandler()
        request.user = self.user


        mixin = SuperuserRequiredViewMixin()