Django

Code

Changeset 7900

Show
Ignore:
Timestamp:
07/12/08 01:16:42 (6 months ago)
Author:
russellm
Message:

Fixed #7583 -- Corrected the testing docs that referred to the defunct headers attribute of the response. Added a test case to validate (and document) the new behavior. Thanks to Malcolm for the report.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/testing.txt

    r7805 r7900  
    601601                     objects, in the order in which they were rendered. 
    602602 
    603     ``headers``      The HTTP headers of the response. This is a dictionary. 
    604  
    605603    ``request``      The request data that stimulated the response. 
    606604 
     
    619617                     which they were rendered. 
    620618    ===============  ========================================================== 
     619 
     620You can also use dictionary syntax on the response object to query the value 
     621of any settings in the HTTP headers. For example, you could determine the 
     622content type of a response using ``response['Content-Type']``. 
    621623 
    622624.. _RFC2616: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html 
  • django/trunk/tests/modeltests/test_client/models.py

    r6813 r7900  
    7171        self.assertEqual(response.template.name, 'POST Template') 
    7272        self.failUnless('Data received' in response.content) 
    73  
     73     
     74    def test_response_headers(self): 
     75        "Check the value of HTTP headers returned in a response" 
     76        response = self.client.get("/test_client/header_view/") 
     77         
     78        self.assertEquals(response['X-DJANGO-TEST'], 'Slartibartfast') 
     79         
    7480    def test_raw_post(self): 
    7581        "POST raw data (with a content type) to a view" 
  • django/trunk/tests/modeltests/test_client/urls.py

    r6658 r7900  
    66    (r'^get_view/$', views.get_view), 
    77    (r'^post_view/$', views.post_view), 
     8    (r'^header_view/$', views.view_with_header), 
    89    (r'^raw_post_view/$', views.raw_post_view), 
    910    (r'^redirect_view/$', views.redirect_view), 
  • django/trunk/tests/modeltests/test_client/views.py

    r6658 r7900  
    3333    return HttpResponse(t.render(c)) 
    3434 
     35def view_with_header(request): 
     36    "A view that has a custom header" 
     37    response = HttpResponse() 
     38    response['X-DJANGO-TEST'] = 'Slartibartfast' 
     39    return response 
     40         
    3541def raw_post_view(request): 
    3642    """A view which expects raw XML to be posted and returns content extracted