Django

Code

Changeset 9187

Show
Ignore:
Timestamp:
10/07/08 04:04:55 (3 months ago)
Author:
mtredinnick
Message:

Reverted r9186 -- Committed to the wrong branch (it's a feature addition).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/releases/1.0.X/AUTHORS

    r9186 r9187  
    4848    Morten Bagai <m@bagai.com> 
    4949    MikaĆ«l Barbero <mikael.barbero nospam at nospam free.fr> 
    50     Scott Barr <scott@divisionbyzero.com.au> 
    5150    Jiri Barton 
    5251    Ned Batchelder <http://www.nedbatchelder.com/> 
  • django/branches/releases/1.0.X/django/test/client.py

    r9186 r9187  
    285285        return self.request(**r) 
    286286 
    287     def head(self, path, data={}, **extra): 
    288         """ 
    289         Request a response from the server using HEAD. 
    290         """ 
    291         r = { 
    292             'CONTENT_LENGTH':  None, 
    293             'CONTENT_TYPE':    'text/html; charset=utf-8', 
    294             'PATH_INFO':       urllib.unquote(path), 
    295             'QUERY_STRING':    urlencode(data, doseq=True), 
    296             'REQUEST_METHOD': 'HEAD', 
    297         } 
    298         r.update(extra) 
    299  
    300         return self.request(**r) 
    301  
    302     def options(self, path, data={}, **extra): 
    303         """ 
    304         Request a response from the server using OPTIONS. 
    305         """ 
    306         r = { 
    307             'CONTENT_LENGTH':  None, 
    308             'CONTENT_TYPE':    None, 
    309             'PATH_INFO':       urllib.unquote(path), 
    310             'QUERY_STRING':    urlencode(data, doseq=True), 
    311             'REQUEST_METHOD': 'OPTIONS', 
    312         } 
    313         r.update(extra) 
    314  
    315         return self.request(**r) 
    316  
    317     def put(self, path, data={}, content_type=MULTIPART_CONTENT, **extra): 
    318         """ 
    319         Send a resource to the server using PUT. 
    320         """ 
    321         if content_type is MULTIPART_CONTENT: 
    322             post_data = encode_multipart(BOUNDARY, data) 
    323         else: 
    324             post_data = data 
    325         r = { 
    326             'CONTENT_LENGTH': len(post_data), 
    327             'CONTENT_TYPE':   content_type, 
    328             'PATH_INFO':      urllib.unquote(path), 
    329             'REQUEST_METHOD': 'PUT', 
    330             'wsgi.input':     FakePayload(post_data), 
    331         } 
    332         r.update(extra) 
    333  
    334         return self.request(**r) 
    335  
    336     def delete(self, path, data={}, **extra): 
    337         """ 
    338         Send a DELETE request to the server. 
    339         """ 
    340         r = { 
    341             'CONTENT_LENGTH':  None, 
    342             'CONTENT_TYPE':    None, 
    343             'PATH_INFO':       urllib.unquote(path), 
    344             'REQUEST_METHOD': 'DELETE', 
    345             } 
    346         r.update(extra) 
    347  
    348         return self.request(**r) 
    349  
    350287    def login(self, **credentials): 
    351288        """ 
  • django/branches/releases/1.0.X/docs/topics/testing.txt

    r9186 r9187  
    545545        to ``post()``. 
    546546 
    547     .. method:: Client.head(path, data={}) 
    548  
    549         Makes a HEAD request on the provided ``path`` and returns a ``Response`` 
    550         object. Useful for testing RESTful interfaces. Acts just like 
    551         :meth:`Client.get` except it does not return a message body. 
    552  
    553     .. method:: Client.options(path, data={}) 
    554  
    555         Makes an OPTIONS request on the provided ``path`` and returns a 
    556         ``Response`` object. Useful for testing RESTful interfaces. 
    557  
    558     .. method:: Client.put(path, data={}, content_type=MULTIPART_CONTENT) 
    559  
    560         Makes an PUT request on the provided ``path`` and returns a 
    561         ``Response`` object. Useful for testing RESTful interfaces. Acts just 
    562         like :meth:`Client.put` except with the PUT request method. 
    563  
    564     .. method:: Client.delete(path) 
    565  
    566         Makes an DELETE request on the provided ``path`` and returns a 
    567         ``Response`` object. Useful for testing RESTful interfaces. 
    568  
    569547    .. method:: Client.login(**credentials) 
    570548 
  • django/branches/releases/1.0.X/tests/regressiontests/test_client_regress/models.py

    r9186 r9187  
    383383        self.assertEqual(response.status_code, 200) 
    384384        self.assertEqual(response.content, 'YES') 
    385  
    386 class RequestMethodTests(TestCase): 
    387     def test_get(self): 
    388         "Request a view via request method GET" 
    389         response = self.client.get('/test_client_regress/request_methods/') 
    390         self.assertEqual(response.status_code, 200) 
    391         self.assertEqual(response.content, 'request method: GET') 
    392  
    393     def test_post(self): 
    394         "Request a view via request method POST" 
    395         response = self.client.post('/test_client_regress/request_methods/') 
    396         self.assertEqual(response.status_code, 200) 
    397         self.assertEqual(response.content, 'request method: POST') 
    398  
    399     def test_head(self): 
    400         "Request a view via request method HEAD" 
    401         response = self.client.head('/test_client_regress/request_methods/') 
    402         self.assertEqual(response.status_code, 200) 
    403         # A HEAD request doesn't return any content. 
    404         self.assertNotEqual(response.content, 'request method: HEAD') 
    405         self.assertEqual(response.content, '') 
    406  
    407     def test_options(self): 
    408         "Request a view via request method OPTIONS" 
    409         response = self.client.options('/test_client_regress/request_methods/') 
    410         self.assertEqual(response.status_code, 200) 
    411         self.assertEqual(response.content, 'request method: OPTIONS') 
    412  
    413     def test_put(self): 
    414         "Request a view via request method PUT" 
    415         response = self.client.put('/test_client_regress/request_methods/') 
    416         self.assertEqual(response.status_code, 200) 
    417         self.assertEqual(response.content, 'request method: PUT') 
    418  
    419     def test_delete(self): 
    420         "Request a view via request method DELETE" 
    421         response = self.client.delete('/test_client_regress/request_methods/') 
    422         self.assertEqual(response.status_code, 200) 
    423         self.assertEqual(response.content, 'request method: DELETE') 
     385         
  • django/branches/releases/1.0.X/tests/regressiontests/test_client_regress/urls.py

    r9186 r9187  
    1010    (r'^set_session/$', views.set_session_view), 
    1111    (r'^check_session/$', views.check_session_view), 
    12     (r'^request_methods/$', views.request_methods_view), 
    1312) 
  • django/branches/releases/1.0.X/tests/regressiontests/test_client_regress/views.py

    r9186 r9187  
    4444    "A view that reads a session variable" 
    4545    return HttpResponse(request.session.get('session_var', 'NO')) 
    46  
    47 def request_methods_view(request): 
    48     "A view that responds with the request method" 
    49     return HttpResponse('request method: %s' % request.method)