diff options
| author | Josh Smeaton <josh.smeaton@gmail.com> | 2015-02-23 11:53:57 +1100 |
|---|---|---|
| committer | Josh Smeaton <josh.smeaton@gmail.com> | 2015-03-05 10:10:32 +1100 |
| commit | 39a7eed1bbf12020a077e4bec3d82e08f171a021 (patch) | |
| tree | 225be14a94d57517d9de646569498eb45d0a4352 /tests/admin_custom_urls | |
| parent | d6969abf239d52f6dfed7384c6ceb7df7e618342 (diff) | |
Converted test fixtures to setUpTestData methods
Diffstat (limited to 'tests/admin_custom_urls')
| -rw-r--r-- | tests/admin_custom_urls/fixtures/actions.json | 44 | ||||
| -rw-r--r-- | tests/admin_custom_urls/fixtures/users.json | 20 | ||||
| -rw-r--r-- | tests/admin_custom_urls/tests.py | 35 |
3 files changed, 25 insertions, 74 deletions
diff --git a/tests/admin_custom_urls/fixtures/actions.json b/tests/admin_custom_urls/fixtures/actions.json deleted file mode 100644 index 7eda3a3ab0..0000000000 --- a/tests/admin_custom_urls/fixtures/actions.json +++ /dev/null @@ -1,44 +0,0 @@ -[ - { - "pk": "delete", - "model": "admin_custom_urls.action", - "fields": { - "description": "Remove things." - } - }, - { - "pk": "rename", - "model": "admin_custom_urls.action", - "fields": { - "description": "Gives things other names." - } - }, - { - "pk": "add", - "model": "admin_custom_urls.action", - "fields": { - "description": "Add things." - } - }, - { - "pk": "path/to/file/", - "model": "admin_custom_urls.action", - "fields": { - "description": "An action with '/' in its name." - } - }, - { - "pk": "path/to/html/document.html", - "model": "admin_custom_urls.action", - "fields": { - "description": "An action with a name similar to a HTML doc path." - } - }, - { - "pk": "javascript:alert('Hello world');\">Click here</a>", - "model": "admin_custom_urls.action", - "fields": { - "description": "An action with a name suspected of being a XSS attempt" - } - } -] diff --git a/tests/admin_custom_urls/fixtures/users.json b/tests/admin_custom_urls/fixtures/users.json deleted file mode 100644 index 72d86d70ad..0000000000 --- a/tests/admin_custom_urls/fixtures/users.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - { - "pk": 100, - "model": "auth.user", - "fields": { - "username": "super", - "first_name": "Super", - "last_name": "User", - "is_active": true, - "is_superuser": true, - "is_staff": true, - "last_login": "2007-05-30 13:20:10", - "groups": [], - "user_permissions": [], - "password": "sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158", - "email": "super@example.com", - "date_joined": "2007-05-30 13:20:10" - } - } -] diff --git a/tests/admin_custom_urls/tests.py b/tests/admin_custom_urls/tests.py index 5ef9f61f67..8177a144bb 100644 --- a/tests/admin_custom_urls/tests.py +++ b/tests/admin_custom_urls/tests.py @@ -1,6 +1,9 @@ from __future__ import unicode_literals +import datetime + from django.contrib.admin.utils import quote +from django.contrib.auth.models import User from django.core.urlresolvers import reverse from django.template.response import TemplateResponse from django.test import TestCase, override_settings @@ -17,7 +20,28 @@ class AdminCustomUrlsTest(TestCase): * The ModelAdmin for Action customizes the add_view URL, it's '<app name>/<model name>/!add/' """ - fixtures = ['users.json', 'actions.json'] + + @classmethod + def setUpTestData(cls): + # password = "secret" + User.objects.create( + pk=100, username='super', first_name='Super', last_name='User', email='super@example.com', + password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', is_active=True, is_superuser=True, + is_staff=True, last_login=datetime.datetime(2007, 5, 30, 13, 20, 10), + date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10) + ) + Action.objects.create(name='delete', description='Remove things.') + Action.objects.create(name='rename', description='Gives things other names.') + Action.objects.create(name='add', description='Add things.') + Action.objects.create(name='path/to/file/', description="An action with '/' in its name.") + Action.objects.create( + name='path/to/html/document.html', + description='An action with a name similar to a HTML doc path.' + ) + Action.objects.create( + name='javascript:alert(\'Hello world\');">Click here</a>', + description='An action with a name suspected of being a XSS attempt' + ) def setUp(self): self.client.login(username='super', password='secret') @@ -76,15 +100,6 @@ class AdminCustomUrlsTest(TestCase): self.assertContains(response, 'Change action') self.assertContains(response, 'value="path/to/html/document.html"') - -@override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'], - ROOT_URLCONF='admin_custom_urls.urls',) -class CustomRedirects(TestCase): - fixtures = ['users.json', 'actions.json'] - - def setUp(self): - self.client.login(username='super', password='secret') - def test_post_save_add_redirect(self): """ Ensures that ModelAdmin.response_post_save_add() controls the |
