Skip to content

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

Merged
merged 3 commits into from
Apr 26, 2018

Conversation

cgl
Copy link
Contributor

@cgl cgl commented Apr 25, 2018

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.

cgl added 2 commits April 25, 2018 19:02
import for RequestsClient is missing in the docs
Note that the requests client requires you to pass fully qualified URLs.
@cgl cgl changed the title update testing.md - missing import update testing.md - fixes related to RequestsClient Apr 25, 2018
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={
Copy link
Member

@tomchristie tomchristie Apr 26, 2018

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.

Copy link
Contributor Author

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.

Copy link
Member

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
Copy link
Member

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.

Copy link
Contributor Author

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
@tomchristie tomchristie merged commit 8c03c49 into encode:master Apr 26, 2018
@cgl cgl deleted the patch-1 branch April 30, 2018 08:53
pchiquet pushed a commit to pchiquet/django-rest-framework that referenced this pull request Nov 17, 2020
* Include import for RequestsClient in the docs.
* Use fully qualified URLs for `RequestsClient` in the docs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants