From 8c03c4940067e0d1fdcd2a002fbbcc27e8e28a55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=87a=C4=9F=C4=B1l?= Date: Thu, 26 Apr 2018 12:47:38 +0100 Subject: [PATCH] update testing.md - fixes related to RequestsClient (#5959) * Include import for RequestsClient in the docs. * Use fully qualified URLs for `RequestsClient` in the docs. --- docs/api-guide/testing.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/api-guide/testing.md b/docs/api-guide/testing.md index b31d2c972..a6ecc7557 100644 --- a/docs/api-guide/testing.md +++ b/docs/api-guide/testing.md @@ -201,6 +201,8 @@ live environment. (See "Live tests" below.) This exposes exactly the same interface as if you were using a requests session directly. + from rest_framework.test import RequestsClient + client = RequestsClient() response = client.get('http://testserver/users/') assert response.status_code == 200 @@ -237,12 +239,12 @@ For example... client = RequestsClient() # Obtain a CSRF token. - response = client.get('/homepage/') + response = client.get('http://testserver/homepage/') assert response.status_code == 200 csrftoken = response.cookies['csrftoken'] # Interact with the API. - response = client.post('/organisations/', json={ + response = client.post('http://testserver/organisations/', json={ 'name': 'MegaCorp', 'status': 'active' }, headers={'X-CSRFToken': csrftoken})