Skip to content

Commit

Permalink
Add test view
Browse files Browse the repository at this point in the history
  • Loading branch information
James Ritchie committed Mar 30, 2015
1 parent 0036618 commit 014e3db
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
"""URL conf for testing Expiring Tokens."""
from django.conf.urls import patterns

from tests.views import MockView

urlpatterns = patterns(
''
'',
(r'^view/$', MockView.as_view()),
)
32 changes: 32 additions & 0 deletions tests/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""
Views used for testing Expiring Tokens.
Classes:
MockView: Test view.
"""
from django.http import HttpResponse

from rest_framework.permissions import IsAuthenticated
from rest_framework.views import APIView

from rest_framework_expiring_authtoken import ExpiringTokenAuth


class MockView(APIView):

"""Mock APIView for testing."""

authentication_classes = (ExpiringTokenAuth,)
permission_classes = (IsAuthenticated,)

def get(self, request):
"""Return JSON string to GET request."""
return HttpResponse({'a': 1, 'b': 2, 'c': 3})

def post(self, request):
"""Return JSON string to POST request."""
return HttpResponse({'a': 1, 'b': 2, 'c': 3})

def put(self, request):
"""Return JSON string to PUT request."""
return HttpResponse({'a': 1, 'b': 2, 'c': 3})

0 comments on commit 014e3db

Please sign in to comment.