Code

Ticket #10521: 10112-remote_users_test.diff

File 10112-remote_users_test.diff, 1.1 KB (added by kegan, 5 years ago)

Propose new patch. Include mock urls and views into test file.

Line 
1diff --git a/django/contrib/auth/tests/remote_user.py b/django/contrib/auth/tests/remote_user.py
2index 449216d..fcba24a 100644
3--- a/django/contrib/auth/tests/remote_user.py
4+++ b/django/contrib/auth/tests/remote_user.py
5@@ -1,13 +1,27 @@
6 from datetime import datetime
7 
8 from django.conf import settings
9+from django.conf.urls.defaults import patterns
10 from django.contrib.auth.backends import RemoteUserBackend
11 from django.contrib.auth.models import AnonymousUser, User
12+from django.http import HttpResponse
13+from django.shortcuts import render_to_response
14+from django.template import Template, RequestContext
15 from django.test import TestCase
16 
17 
18+def remote_user_auth_view(request):
19+    t = Template("Username is {{ user }}.")
20+    c = RequestContext(request, {})
21+    return HttpResponse(t.render(c))
22+
23+urlpatterns = patterns('',
24+    (r'^$', remote_user_auth_view),
25+)
26+
27 class RemoteUserTest(TestCase):
28 
29+    urls = 'django.contrib.auth.tests.remote_user'
30     middleware = 'django.contrib.auth.middleware.RemoteUserMiddleware'
31     backend = 'django.contrib.auth.backends.RemoteUserBackend'
32