summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorLuke Plant <L.Plant.98@cantab.net>2011-05-31 15:19:19 +0000
committerLuke Plant <L.Plant.98@cantab.net>2011-05-31 15:19:19 +0000
commit45317677008a71c261b8c00388e8c2555a96598c (patch)
treed572af5bb7f7d57f127b9297a3fdd3ec52561d5d /django
parent93e9d91501914e37ef8dfe7a9e355be9d2e9c538 (diff)
downloaddjango-45317677008a71c261b8c00388e8c2555a96598c.tar.gz
Fixed auth context processor tests, which were not running at all previously.
It seems they were accidentally disabled following being moved from regressiontests in [15990] git-svn-id: http://code.djangoproject.com/svn/django/trunk@16304 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/contrib/auth/tests/__init__.py1
-rw-r--r--django/contrib/auth/tests/context_processors.py19
-rw-r--r--django/contrib/auth/tests/templates/context_processors/auth_attrs_access.html1
-rw-r--r--django/contrib/auth/tests/templates/context_processors/auth_attrs_messages.html1
-rw-r--r--django/contrib/auth/tests/templates/context_processors/auth_attrs_no_access.html1
-rw-r--r--django/contrib/auth/tests/templates/context_processors/auth_attrs_perms.html1
-rw-r--r--django/contrib/auth/tests/templates/context_processors/auth_attrs_test_access.html1
-rw-r--r--django/contrib/auth/tests/templates/context_processors/auth_attrs_user.html4
-rw-r--r--django/contrib/auth/tests/urls.py5
9 files changed, 29 insertions, 5 deletions
diff --git a/django/contrib/auth/tests/__init__.py b/django/contrib/auth/tests/__init__.py
index 2d7d0fa1a1..a7cc004507 100644
--- a/django/contrib/auth/tests/__init__.py
+++ b/django/contrib/auth/tests/__init__.py
@@ -2,6 +2,7 @@ from django.contrib.auth.tests.auth_backends import (BackendTest,
RowlevelBackendTest, AnonymousUserBackendTest, NoAnonymousUserBackendTest,
NoBackendsTest, InActiveUserBackendTest, NoInActiveUserBackendTest)
from django.contrib.auth.tests.basic import BasicTestCase
+from django.contrib.auth.tests.context_processors import AuthContextProcessorTests
from django.contrib.auth.tests.decorators import LoginRequiredTestCase
from django.contrib.auth.tests.forms import (UserCreationFormTest,
AuthenticationFormTest, SetPasswordFormTest, PasswordChangeFormTest,
diff --git a/django/contrib/auth/tests/context_processors.py b/django/contrib/auth/tests/context_processors.py
index c008e7098c..49172c60e0 100644
--- a/django/contrib/auth/tests/context_processors.py
+++ b/django/contrib/auth/tests/context_processors.py
@@ -1,16 +1,27 @@
-# from django.conf import settings
+import os
+
+from django.conf import settings
from django.contrib.auth import authenticate
from django.db.models import Q
from django.test import TestCase
-# from django.template import Template
+
class AuthContextProcessorTests(TestCase):
"""
Tests for the ``django.contrib.auth.context_processors.auth`` processor
"""
- urls = 'regressiontests.context_processors.urls'
+ urls = 'django.contrib.auth.tests.urls'
fixtures = ['context-processors-users.xml']
+ def setUp(self):
+ self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS
+ settings.TEMPLATE_DIRS = (
+ os.path.join(os.path.dirname(__file__), 'templates'),
+ )
+
+ def tearDown(self):
+ settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS
+
def test_session_not_accessed(self):
"""
Tests that the session is not accessed simply by including
@@ -74,4 +85,4 @@ class AuthContextProcessorTests(TestCase):
# equality in a non-duck-typing way
# See bug #12060
self.assertEqual(response.context['user'], user)
- self.assertEqual(user, response.context['user']) \ No newline at end of file
+ self.assertEqual(user, response.context['user'])
diff --git a/django/contrib/auth/tests/templates/context_processors/auth_attrs_access.html b/django/contrib/auth/tests/templates/context_processors/auth_attrs_access.html
new file mode 100644
index 0000000000..b5c65db28d
--- /dev/null
+++ b/django/contrib/auth/tests/templates/context_processors/auth_attrs_access.html
@@ -0,0 +1 @@
+{{ user }}
diff --git a/django/contrib/auth/tests/templates/context_processors/auth_attrs_messages.html b/django/contrib/auth/tests/templates/context_processors/auth_attrs_messages.html
new file mode 100644
index 0000000000..7b7e448ad2
--- /dev/null
+++ b/django/contrib/auth/tests/templates/context_processors/auth_attrs_messages.html
@@ -0,0 +1 @@
+{% for m in messages %}{{ m }}{% endfor %}
diff --git a/django/contrib/auth/tests/templates/context_processors/auth_attrs_no_access.html b/django/contrib/auth/tests/templates/context_processors/auth_attrs_no_access.html
new file mode 100644
index 0000000000..8d1c8b69c3
--- /dev/null
+++ b/django/contrib/auth/tests/templates/context_processors/auth_attrs_no_access.html
@@ -0,0 +1 @@
+
diff --git a/django/contrib/auth/tests/templates/context_processors/auth_attrs_perms.html b/django/contrib/auth/tests/templates/context_processors/auth_attrs_perms.html
new file mode 100644
index 0000000000..a5db868e9e
--- /dev/null
+++ b/django/contrib/auth/tests/templates/context_processors/auth_attrs_perms.html
@@ -0,0 +1 @@
+{% if perms.auth %}Has auth permissions{% endif %}
diff --git a/django/contrib/auth/tests/templates/context_processors/auth_attrs_test_access.html b/django/contrib/auth/tests/templates/context_processors/auth_attrs_test_access.html
new file mode 100644
index 0000000000..a28ff937f8
--- /dev/null
+++ b/django/contrib/auth/tests/templates/context_processors/auth_attrs_test_access.html
@@ -0,0 +1 @@
+{% if session_accessed %}Session accessed{% else %}Session not accessed{% endif %}
diff --git a/django/contrib/auth/tests/templates/context_processors/auth_attrs_user.html b/django/contrib/auth/tests/templates/context_processors/auth_attrs_user.html
new file mode 100644
index 0000000000..5df2a344cc
--- /dev/null
+++ b/django/contrib/auth/tests/templates/context_processors/auth_attrs_user.html
@@ -0,0 +1,4 @@
+{% load url from future %}unicode: {{ user }}
+id: {{ user.id }}
+username: {{ user.username }}
+url: {% url 'userpage' user %}
diff --git a/django/contrib/auth/tests/urls.py b/django/contrib/auth/tests/urls.py
index 1407cda895..4445a9c014 100644
--- a/django/contrib/auth/tests/urls.py
+++ b/django/contrib/auth/tests/urls.py
@@ -1,8 +1,11 @@
from django.conf.urls.defaults import patterns, url
+from django.contrib.auth import context_processors
from django.contrib.auth.urls import urlpatterns
from django.contrib.auth.views import password_reset
from django.contrib.auth.decorators import login_required
+from django.contrib.messages.api import info
from django.http import HttpResponse
+from django.shortcuts import render_to_response
from django.template import Template, RequestContext
from django.views.decorators.cache import never_cache
@@ -35,7 +38,7 @@ def auth_processor_perms(request):
RequestContext(request, {}, processors=[context_processors.auth]))
def auth_processor_messages(request):
- request.user.message_set.create(message="Message 1")
+ info(request, "Message 1")
return render_to_response('context_processors/auth_attrs_messages.html',
RequestContext(request, {}, processors=[context_processors.auth]))