-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
James Ritchie
committed
Mar 30, 2015
1 parent
0036618
commit 014e3db
Showing
2 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}) |