33from datetime import datetime , timedelta
44import time
55
6+ from cryptography .hazmat .backends import default_backend
7+ from cryptography .hazmat .primitives .asymmetric import rsa
68from django import get_version
79from django .test import TestCase
810from django .test .utils import override_settings
9- from django .conf .urls import patterns
1011from rest_framework import status
1112from rest_framework .test import APIClient
1213
13- from rest_framework_jwt import utils
14+ from rest_framework_jwt import utils , views
1415from rest_framework_jwt .compat import get_user_model
1516from rest_framework_jwt .settings import api_settings , DEFAULTS
1617
17- from cryptography .hazmat .backends import default_backend
18- from cryptography .hazmat .primitives .asymmetric import rsa
19-
2018from . import utils as test_utils
2119
2220User = get_user_model ()
2321
2422NO_CUSTOM_USER_MODEL = 'Custom User Model only supported after Django 1.5'
2523
26- urlpatterns = patterns (
27- '' ,
28- (r'^auth-token/$' , 'rest_framework_jwt.views.obtain_jwt_token' ),
29- (r'^auth-token-refresh/$' , 'rest_framework_jwt.views.refresh_jwt_token' ),
30- (r'^auth-token-verify/$' , 'rest_framework_jwt.views.verify_jwt_token' ),
31-
32- )
33-
3424orig_datetime = datetime
3525
3626
3727class BaseTestCase (TestCase ):
38- urls = 'tests.test_views'
3928
4029 def setUp (self ):
4130 self .email = 'jpueblo@example.com'
@@ -53,7 +42,8 @@ def setUp(self):
5342class TestCustomResponsePayload (BaseTestCase ):
5443
5544 def setUp (self ):
56- api_settings .JWT_RESPONSE_PAYLOAD_HANDLER = test_utils \
45+ self .original_handler = views .jwt_response_payload_handler
46+ views .jwt_response_payload_handler = test_utils \
5747 .jwt_response_payload_handler
5848 return super (TestCustomResponsePayload , self ).setUp ()
5949
@@ -72,8 +62,7 @@ def test_jwt_login_custom_response_json(self):
7262 self .assertEqual (response .data ['user' ], self .username )
7363
7464 def tearDown (self ):
75- api_settings .JWT_RESPONSE_PAYLOAD_HANDLER = \
76- DEFAULTS ['JWT_RESPONSE_PAYLOAD_HANDLER' ]
65+ views .jwt_response_payload_handler = self .original_handler
7766
7867
7968class ObtainJSONWebTokenTests (BaseTestCase ):
@@ -166,7 +155,6 @@ def test_jwt_login_using_zero(self):
166155@override_settings (AUTH_USER_MODEL = 'tests.CustomUser' )
167156class CustomUserObtainJSONWebTokenTests (TestCase ):
168157 """JSON Web Token Authentication"""
169- urls = 'tests.test_views'
170158
171159 def setUp (self ):
172160 from .models import CustomUser
@@ -211,7 +199,6 @@ def test_jwt_login_json_bad_creds(self):
211199@override_settings (AUTH_USER_MODEL = 'tests.CustomUserUUID' )
212200class CustomUserUUIDObtainJSONWebTokenTests (TestCase ):
213201 """JSON Web Token Authentication"""
214- urls = 'tests.test_views'
215202
216203 def setUp (self ):
217204 from .models import CustomUserUUID
0 commit comments