Ticket #5982: 5982-r7023.diff
File 5982-r7023.diff, 2.8 KB (added by , 17 years ago) |
---|
-
tests/regressiontests/test_client_regress/views.py
24 24 return HttpResponse("Hello world") 25 25 get_view = login_required(get_view) 26 26 27 def view_with_argument(request, name): 28 """A view that takes a string argument 29 30 The purpose of this view is to check that if a space is provided in 31 the argument, the test framework unescapes the %20 before passing 32 the value to the view. 33 """ 34 if name == 'Arthur Dent': 35 return HttpResponse('Hi, Arthur') 36 else: 37 return HttpResponse('Howdy, %s' % name) 38 27 39 def login_protected_redirect_view(request): 28 40 "A view that redirects all requests to the GET view" 29 41 return HttpResponseRedirect('/test_client_regress/get_view/') -
tests/regressiontests/test_client_regress/models.py
4 4 """ 5 5 from django.test import Client, TestCase 6 6 from django.core import mail 7 from django.core.urlresolvers import reverse 7 8 import os 8 9 9 10 class AssertContainsTests(TestCase): … … 261 262 # Check that assertRedirects uses the original client, not the 262 263 # default client. 263 264 self.assertRedirects(response, "http://testserver/test_client_regress/get_view/") 265 266 267 class URLEscapingTests(TestCase): 268 def test_simple_argument(self): 269 "Get a view that has a simple string argument" 270 response = self.client.get(reverse('arg_view', args=['Slartibartfast'])) 271 self.assertEqual(response.status_code, 200) 272 self.assertEqual(response.content, 'Howdy, Slartibartfast') 273 274 def test_argument_with_space(self): 275 "Get a view that has a string argument that requires escaping" 276 response = self.client.get(reverse('arg_view', args=['Arthur Dent'])) 277 self.assertEqual(response.status_code, 200) 278 self.assertEqual(response.content, 'Hi, Arthur') 279 280 No newline at end of file -
tests/regressiontests/test_client_regress/urls.py
5 5 (r'^no_template_view/$', views.no_template_view), 6 6 (r'^file_upload/$', views.file_upload_view), 7 7 (r'^get_view/$', views.get_view), 8 url(r'^arg_view/(?P<name>.+)/$', views.view_with_argument, name='arg_view'), 8 9 (r'^login_protected_redirect_view/$', views.login_protected_redirect_view) 9 10 )