diff options
| author | Unai Zalakain <unai@gisa-elkartea.org> | 2013-10-28 15:00:54 +0100 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2013-11-02 19:03:13 +0100 |
| commit | 99b681e227b5b7880d6edd0d8dd670034d431859 (patch) | |
| tree | 37327626b22a26b1db2d0de63cbc206ba7add7c2 /docs | |
| parent | 19256f300e44b0a682f76fc1dda673862bae49d1 (diff) | |
Fixed #21341 -- Eased https requests with the test client
All request methods of ``django.test.client.Client`` receive a ``secure``
argument that defaults to ``False`` indicating whether or not to make the
request through https.
Thanks Aymeric Augustin for the review.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/releases/1.7.txt | 4 | ||||
| -rw-r--r-- | docs/topics/testing/overview.txt | 35 |
2 files changed, 26 insertions, 13 deletions
diff --git a/docs/releases/1.7.txt b/docs/releases/1.7.txt index 7218bcec22..2e596b3dc8 100644 --- a/docs/releases/1.7.txt +++ b/docs/releases/1.7.txt @@ -444,6 +444,10 @@ Tests client can't fetch externals URLs, this allows you to use ``assertRedirects`` with redirects that aren't part of your Django app. +* The ``secure`` argument was added to all the request methods of + :class:`~django.test.Client`. If ``True``, the request will be made + through HTTPS. + Backwards incompatible changes in 1.7 ===================================== diff --git a/docs/topics/testing/overview.txt b/docs/topics/testing/overview.txt index 7735e2ab71..7093138188 100644 --- a/docs/topics/testing/overview.txt +++ b/docs/topics/testing/overview.txt @@ -431,8 +431,11 @@ Use the ``django.test.Client`` class to make requests. Once you have a ``Client`` instance, you can call any of the following methods: - .. method:: Client.get(path, data={}, follow=False, **extra) + .. method:: Client.get(path, data={}, follow=False, secure=False, **extra) + .. versionadded:: 1.7 + + The ``secure`` argument was added. Makes a GET request on the provided ``path`` and returns a ``Response`` object, which is documented below. @@ -488,7 +491,10 @@ Use the ``django.test.Client`` class to make requests. >>> response.redirect_chain [(u'http://testserver/next/', 302), (u'http://testserver/final/', 302)] - .. method:: Client.post(path, data={}, content_type=MULTIPART_CONTENT, follow=False, **extra) + If you set ``secure`` to ``True`` the client will emulate an HTTPS + request. + + .. method:: Client.post(path, data={}, content_type=MULTIPART_CONTENT, follow=False, secure=False, **extra) Makes a POST request on the provided ``path`` and returns a ``Response`` object, which is documented below. @@ -562,14 +568,17 @@ Use the ``django.test.Client`` class to make requests. and a ``redirect_chain`` attribute will be set in the response object containing tuples of the intermediate urls and status codes. - .. method:: Client.head(path, data={}, follow=False, **extra) + If you set ``secure`` to ``True`` the client will emulate an HTTPS + request. + + .. method:: Client.head(path, data={}, follow=False, secure=False, **extra) Makes a HEAD request on the provided ``path`` and returns a ``Response`` object. This method works just like :meth:`Client.get`, - including the ``follow`` and ``extra`` arguments, except it does not - return a message body. + including the ``follow``, ``secure`` and ``extra`` arguments, except + it does not return a message body. - .. method:: Client.options(path, data='', content_type='application/octet-stream', follow=False, **extra) + .. method:: Client.options(path, data='', content_type='application/octet-stream', follow=False, secure=False, **extra) Makes an OPTIONS request on the provided ``path`` and returns a ``Response`` object. Useful for testing RESTful interfaces. @@ -577,10 +586,10 @@ Use the ``django.test.Client`` class to make requests. When ``data`` is provided, it is used as the request body, and a ``Content-Type`` header is set to ``content_type``. - The ``follow`` and ``extra`` arguments act the same as for + The ``follow``, ``secure`` and ``extra`` arguments act the same as for :meth:`Client.get`. - .. method:: Client.put(path, data='', content_type='application/octet-stream', follow=False, **extra) + .. method:: Client.put(path, data='', content_type='application/octet-stream', follow=False, secure=False, **extra) Makes a PUT request on the provided ``path`` and returns a ``Response`` object. Useful for testing RESTful interfaces. @@ -588,18 +597,18 @@ Use the ``django.test.Client`` class to make requests. When ``data`` is provided, it is used as the request body, and a ``Content-Type`` header is set to ``content_type``. - The ``follow`` and ``extra`` arguments act the same as for + The ``follow``, ``secure`` and ``extra`` arguments act the same as for :meth:`Client.get`. - .. method:: Client.patch(path, data='', content_type='application/octet-stream', follow=False, **extra) + .. method:: Client.patch(path, data='', content_type='application/octet-stream', follow=False, secure=False, **extra) Makes a PATCH request on the provided ``path`` and returns a ``Response`` object. Useful for testing RESTful interfaces. - The ``follow`` and ``extra`` arguments act the same as for + The ``follow``, ``secure`` and ``extra`` arguments act the same as for :meth:`Client.get`. - .. method:: Client.delete(path, data='', content_type='application/octet-stream', follow=False, **extra) + .. method:: Client.delete(path, data='', content_type='application/octet-stream', follow=False, secure=False, **extra) Makes an DELETE request on the provided ``path`` and returns a ``Response`` object. Useful for testing RESTful interfaces. @@ -607,7 +616,7 @@ Use the ``django.test.Client`` class to make requests. When ``data`` is provided, it is used as the request body, and a ``Content-Type`` header is set to ``content_type``. - The ``follow`` and ``extra`` arguments act the same as for + The ``follow``, ``secure`` and ``extra`` arguments act the same as for :meth:`Client.get`. .. method:: Client.login(**credentials) |
