Skip to content

Commit 7a34535

Browse files
committed
Use contrib.auth user model in tests
1 parent 3caa750 commit 7a34535

File tree

9 files changed

+28
-26
lines changed

9 files changed

+28
-26
lines changed

oauth2_provider/tests/test_application_views.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from __future__ import unicode_literals
22

3+
from django.contrib.auth.models import User
34
from django.core.urlresolvers import reverse
45
from django.test import TestCase
56

6-
from ..compat import get_user_model
77
from ..models import get_application_model
88

99

@@ -12,8 +12,8 @@
1212

1313
class BaseTest(TestCase):
1414
def setUp(self):
15-
self.foo_user = get_user_model().objects.create_user("foo_user", "test@user.com", "123456")
16-
self.bar_user = get_user_model().objects.create_user("bar_user", "dev@user.com", "123456")
15+
self.foo_user = User.objects.create_user("foo_user", "test@user.com", "123456")
16+
self.bar_user = User.objects.create_user("bar_user", "dev@user.com", "123456")
1717

1818
def tearDown(self):
1919
self.foo_user.delete()

oauth2_provider/tests/test_authorization_code.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
import json
44

55
from django.test import TestCase, RequestFactory
6+
from django.contrib.auth.models import User
67
from django.core.urlresolvers import reverse
78
from django.utils import timezone
89

9-
from ..compat import urlparse, parse_qs, urlencode, get_user_model
10+
from ..compat import urlparse, parse_qs, urlencode
1011
from ..models import get_application_model, Grant
1112
from ..settings import oauth2_settings
1213
from ..views import ProtectedResourceView
@@ -26,8 +27,8 @@ def get(self, request, *args, **kwargs):
2627
class BaseTest(TestCaseUtils, TestCase):
2728
def setUp(self):
2829
self.factory = RequestFactory()
29-
self.test_user = get_user_model().objects.create_user("test_user", "test@user.com", "123456")
30-
self.dev_user = get_user_model().objects.create_user("dev_user", "dev@user.com", "123456")
30+
self.test_user = User.objects.create_user("test_user", "test@user.com", "123456")
31+
self.dev_user = User.objects.create_user("dev_user", "dev@user.com", "123456")
3132

3233
self.application = Application(
3334
name="Test Application",

oauth2_provider/tests/test_client_credential.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
import json
44

5+
from django.contrib.auth.models import User
56
from django.core.urlresolvers import reverse
67
from django.test import TestCase, RequestFactory
78
from django.views.generic import View
89

910
from oauthlib.oauth2 import BackendApplicationServer
1011

11-
from ..compat import get_user_model
1212
from ..models import get_application_model
1313
from ..oauth2_validators import OAuth2Validator
1414
from ..settings import oauth2_settings
@@ -29,8 +29,8 @@ def get(self, request, *args, **kwargs):
2929
class BaseTest(TestCaseUtils, TestCase):
3030
def setUp(self):
3131
self.factory = RequestFactory()
32-
self.test_user = get_user_model().objects.create_user("test_user", "test@user.com", "123456")
33-
self.dev_user = get_user_model().objects.create_user("dev_user", "dev@user.com", "123456")
32+
self.test_user = User.objects.create_user("test_user", "test@user.com", "123456")
33+
self.dev_user = User.objects.create_user("dev_user", "dev@user.com", "123456")
3434

3535
self.application = Application(
3636
name="test_client_credentials_app",

oauth2_provider/tests/test_decorators.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
from datetime import timedelta
33

44
from django.test import TestCase, RequestFactory
5-
from django.core.urlresolvers import reverse
5+
from django.contrib.auth.models import User
66
from django.utils import timezone
77

88
from ..decorators import protected_resource, rw_protected_resource
9-
from ..compat import get_user_model
109
from ..settings import oauth2_settings
1110
from ..models import get_application_model, AccessToken
1211
from .test_utils import TestCaseUtils
@@ -21,7 +20,7 @@ def setUpClass(cls):
2120
cls.request_factory = RequestFactory()
2221

2322
def setUp(self):
24-
self.user = get_user_model().objects.create_user("test_user", "test@user.com", "123456")
23+
self.user = User.objects.create_user("test_user", "test@user.com", "123456")
2524
self.application = Application.objects.create(
2625
name="test_client_credentials_app",
2726
user=self.user,

oauth2_provider/tests/test_implicit.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
from __future__ import unicode_literals
22

33
from django.test import TestCase, RequestFactory
4+
from django.contrib.auth.models import User
45
from django.core.urlresolvers import reverse
56

6-
from ..compat import urlparse, parse_qs, urlencode, get_user_model
7+
from ..compat import urlparse, parse_qs, urlencode
78
from ..models import get_application_model
89
from ..settings import oauth2_settings
910
from ..views import ProtectedResourceView
@@ -21,8 +22,8 @@ def get(self, request, *args, **kwargs):
2122
class BaseTest(TestCase):
2223
def setUp(self):
2324
self.factory = RequestFactory()
24-
self.test_user = get_user_model().objects.create_user("test_user", "test@user.com", "123456")
25-
self.dev_user = get_user_model().objects.create_user("dev_user", "dev@user.com", "123456")
25+
self.test_user = User.objects.create_user("test_user", "test@user.com", "123456")
26+
self.dev_user = User.objects.create_user("dev_user", "dev@user.com", "123456")
2627

2728
self.application = Application(
2829
name="Test Implicit Application",

oauth2_provider/tests/test_models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from __future__ import unicode_literals
22

33
from django.test import TestCase
4+
from django.contrib.auth.models import User
45
from django.core.exceptions import ValidationError
56

6-
from ..compat import get_user_model
77
from ..models import AccessToken, get_application_model
88

99

@@ -12,7 +12,7 @@
1212

1313
class TestModels(TestCase):
1414
def setUp(self):
15-
self.user = get_user_model().objects.create_user("test_user", "test@user.com", "123456")
15+
self.user = User.objects.create_user("test_user", "test@user.com", "123456")
1616

1717
def test_allow_scopes(self):
1818
self.client.login(username="test_user", password="123456")

oauth2_provider/tests/test_password.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import json
44

55
from django.test import TestCase, RequestFactory
6+
from django.contrib.auth.models import User
67
from django.core.urlresolvers import reverse
78

8-
from ..compat import get_user_model
99
from ..models import get_application_model
1010
from ..settings import oauth2_settings
1111
from ..views import ProtectedResourceView
@@ -25,8 +25,8 @@ def get(self, request, *args, **kwargs):
2525
class BaseTest(TestCaseUtils, TestCase):
2626
def setUp(self):
2727
self.factory = RequestFactory()
28-
self.test_user = get_user_model().objects.create_user("test_user", "test@user.com", "123456")
29-
self.dev_user = get_user_model().objects.create_user("dev_user", "dev@user.com", "123456")
28+
self.test_user = User.objects.create_user("test_user", "test@user.com", "123456")
29+
self.dev_user = User.objects.create_user("dev_user", "dev@user.com", "123456")
3030

3131
self.application = Application(
3232
name="Test Password Application",

oauth2_provider/tests/test_rest_framework.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
from datetime import timedelta
22

3+
from django.contrib.auth.models import User
34
from django.conf.urls import patterns, url, include
45
from django.http import HttpResponse
56
from django.test import TestCase
67
from django.utils import timezone, unittest
78

89

910
from .test_utils import TestCaseUtils
10-
from ..compat import get_user_model
1111
from ..models import AccessToken, get_application_model
1212
from ..settings import oauth2_settings
1313

@@ -65,8 +65,8 @@ class TestOAuth2Authentication(BaseTest):
6565
def setUp(self):
6666
oauth2_settings._SCOPES = ['read', 'write', 'scope1', 'scope2']
6767

68-
self.test_user = get_user_model().objects.create_user("test_user", "test@user.com", "123456")
69-
self.dev_user = get_user_model().objects.create_user("dev_user", "dev@user.com", "123456")
68+
self.test_user = User.objects.create_user("test_user", "test@user.com", "123456")
69+
self.dev_user = User.objects.create_user("dev_user", "dev@user.com", "123456")
7070

7171
self.application = Application.objects.create(
7272
name="Test Application",

oauth2_provider/tests/test_scopes.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
import json
44

55
from django.test import TestCase, RequestFactory
6+
from django.contrib.auth.models import User
67
from django.core.exceptions import ImproperlyConfigured
78
from django.core.urlresolvers import reverse
89

9-
from ..compat import urlparse, parse_qs, get_user_model
10+
from ..compat import urlparse, parse_qs
1011
from ..models import get_application_model, Grant, AccessToken
1112
from ..settings import oauth2_settings
1213
from ..views import ScopedProtectedResourceView, ReadWriteScopedResourceView
@@ -43,8 +44,8 @@ def post(self, request, *args, **kwargs):
4344
class BaseTest(TestCaseUtils, TestCase):
4445
def setUp(self):
4546
self.factory = RequestFactory()
46-
self.test_user = get_user_model().objects.create_user("test_user", "test@user.com", "123456")
47-
self.dev_user = get_user_model().objects.create_user("dev_user", "dev@user.com", "123456")
47+
self.test_user = User.objects.create_user("test_user", "test@user.com", "123456")
48+
self.dev_user = User.objects.create_user("dev_user", "dev@user.com", "123456")
4849

4950
self.application = Application(
5051
name="Test Application",

0 commit comments

Comments
 (0)