summaryrefslogtreecommitdiff
path: root/tests/test_client
diff options
context:
space:
mode:
authorJosh Smeaton <josh.smeaton@gmail.com>2015-02-23 11:53:57 +1100
committerJosh Smeaton <josh.smeaton@gmail.com>2015-03-05 10:10:32 +1100
commit39a7eed1bbf12020a077e4bec3d82e08f171a021 (patch)
tree225be14a94d57517d9de646569498eb45d0a4352 /tests/test_client
parentd6969abf239d52f6dfed7384c6ceb7df7e618342 (diff)
Converted test fixtures to setUpTestData methods
Diffstat (limited to 'tests/test_client')
-rw-r--r--tests/test_client/fixtures/testdata.json56
-rw-r--r--tests/test_client/tests.py25
2 files changed, 24 insertions, 57 deletions
diff --git a/tests/test_client/fixtures/testdata.json b/tests/test_client/fixtures/testdata.json
deleted file mode 100644
index b844809a18..0000000000
--- a/tests/test_client/fixtures/testdata.json
+++ /dev/null
@@ -1,56 +0,0 @@
-[
- {
- "pk": "1",
- "model": "auth.user",
- "fields": {
- "username": "testclient",
- "first_name": "Test",
- "last_name": "Client",
- "is_active": true,
- "is_superuser": false,
- "is_staff": false,
- "last_login": "2006-12-17 07:03:31",
- "groups": [],
- "user_permissions": [],
- "password": "sha1$6efc0$f93efe9fd7542f25a7be94871ea45aa95de57161",
- "email": "testclient@example.com",
- "date_joined": "2006-12-17 07:03:31"
- }
- },
- {
- "pk": "2",
- "model": "auth.user",
- "fields": {
- "username": "inactive",
- "first_name": "Inactive",
- "last_name": "User",
- "is_active": false,
- "is_superuser": false,
- "is_staff": false,
- "last_login": "2006-12-17 07:03:31",
- "groups": [],
- "user_permissions": [],
- "password": "sha1$6efc0$f93efe9fd7542f25a7be94871ea45aa95de57161",
- "email": "testclient@example.com",
- "date_joined": "2006-12-17 07:03:31"
- }
- },
- {
- "pk": "3",
- "model": "auth.user",
- "fields": {
- "username": "staff",
- "first_name": "Staff",
- "last_name": "Member",
- "is_active": true,
- "is_superuser": false,
- "is_staff": true,
- "last_login": "2006-12-17 07:03:31",
- "groups": [],
- "user_permissions": [],
- "password": "sha1$6efc0$f93efe9fd7542f25a7be94871ea45aa95de57161",
- "email": "testclient@example.com",
- "date_joined": "2006-12-17 07:03:31"
- }
- }
-] \ No newline at end of file
diff --git a/tests/test_client/tests.py b/tests/test_client/tests.py
index 05de326bef..7190ea64b0 100644
--- a/tests/test_client/tests.py
+++ b/tests/test_client/tests.py
@@ -22,6 +22,9 @@ rather than the HTML rendered to the end-user.
"""
from __future__ import unicode_literals
+import datetime
+
+from django.contrib.auth.models import User
from django.core import mail
from django.http import HttpResponse
from django.test import Client, RequestFactory, TestCase, override_settings
@@ -32,7 +35,27 @@ from .views import get_view, post_view, trace_view
@override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'],
ROOT_URLCONF='test_client.urls',)
class ClientTest(TestCase):
- fixtures = ['testdata.json']
+
+ @classmethod
+ def setUpTestData(cls):
+ cls.u1 = User.objects.create(
+ password='sha1$6efc0$f93efe9fd7542f25a7be94871ea45aa95de57161',
+ last_login=datetime.datetime(2006, 12, 17, 7, 3, 31), is_superuser=False, username='testclient',
+ first_name='Test', last_name='Client', email='testclient@example.com', is_staff=False, is_active=True,
+ date_joined=datetime.datetime(2006, 12, 17, 7, 3, 31)
+ )
+ cls.u2 = User.objects.create(
+ password='sha1$6efc0$f93efe9fd7542f25a7be94871ea45aa95de57161',
+ last_login=datetime.datetime(2006, 12, 17, 7, 3, 31), is_superuser=False, username='inactive',
+ first_name='Inactive', last_name='User', email='testclient@example.com', is_staff=False, is_active=False,
+ date_joined=datetime.datetime(2006, 12, 17, 7, 3, 31)
+ )
+ cls.u3 = User.objects.create(
+ password='sha1$6efc0$f93efe9fd7542f25a7be94871ea45aa95de57161',
+ last_login=datetime.datetime(2006, 12, 17, 7, 3, 31), is_superuser=False, username='staff',
+ first_name='Staff', last_name='Member', email='testclient@example.com', is_staff=True, is_active=True,
+ date_joined=datetime.datetime(2006, 12, 17, 7, 3, 31)
+ )
def test_get_view(self):
"GET a view"