Opened 4 years ago

Closed 4 years ago

#31501 closed Cleanup/optimization (wontfix)

Update Documentation for "Testing Responses" section on Django Documentation

Reported by: AvuGradConnection Owned by: nobody
Component: Documentation Version: 2.2
Severity: Normal Keywords: Documentation, Testing, Responses, Testing Client, TestClient, Django Rest Framework, DRF, API's, Custom Views
Cc: AvuGradConnection Triage Stage: Unreviewed
Has patch: no Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

https://docs.djangoproject.com/en/2.2/topics/testing/tools/#testing-responses

Under the Testing Responses section of this page, it is detailed to the user how to interact with the "Response" object returned from the client request. There is an assumption made that the response will be a 'django.http.response.HttpResponse' (HttpResponse) whereas the endpoint responsible for returning the response may/may not return a response object that is an HttpResponse, or even a response like object at all.

Users should be made aware of this and the fact that the interface described for communicating with the response might be significantly different depending on what type of response the view handling the response returns. This may or may not be a response like object. The user should be made aware that if they are using any other mechanism besides Django default views to return response objects then the response may differ significantly from the the documentation interface explained.

Example: Django Rest Framework, manipulates(sub classes) the HttpResponse in providing their "ApiViews" and this response object works slightly differently from the class HttpResponse object described in the documentation.

Change History (2)

comment:1 by AvuGradConnection, 4 years ago

Cc: AvuGradConnection added
Needs documentation: set

comment:2 by Carlton Gibson, 4 years ago

Resolution: wontfix
Status: newclosed

Hi, thanks for the report.

The section in question is explicitly discussing responses returned by the Django test Client. Even if you're using DRF, it's still an HttpResponse.
I think that assumption is reasonable.

DRF has its own testing docs that explain the additions made there.
That's the right place for that addition.

Note: See TracTickets for help on using tickets.
Back to Top