-
-
Notifications
You must be signed in to change notification settings - Fork 7k
update testing.md - fixes related to RequestsClient #5959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
import for RequestsClient is missing in the docs
Note that the requests client requires you to pass fully qualified URLs.
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={ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to fully qualify the request. Let's leave these lines as they are.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes with APIClient we don't need to fully qualify the request. But with RequestClient we need to. See the documentation for RequestClient:
http://www.django-rest-framework.org/api-guide/testing/#requestsclient
Note that the requests client requires you to pass fully qualified URLs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, thanks! 😀
@@ -201,6 +201,7 @@ 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough, yup, tho let's have a newline after this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
let's have a newline after RequestsClient import
* Include import for RequestsClient in the docs. * Use fully qualified URLs for `RequestsClient` in the docs.
import for RequestsClient is missing in the docs
Note: Before submitting this pull request, please review our contributing guidelines.
Description
Please describe your pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue. When linking to an issue, please use
refs #...
in the description of the pull request.