Code

Opened 2 years ago

Closed 18 months ago

#17360 closed Cleanup/optimization (fixed)

Documenting differences between Client.post et Client.put

Reported by: thibaultj Owned by: nobody
Component: Documentation Version: master
Severity: Normal Keywords: rest, put, testing
Cc: thibaultj Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: yes UI/UX: no

Description

The testing documentation asserts that « Client.put() […] Acts just like Client.post() except with the PUT request method. ». However, there's a subtle difference in the manner django handles both methods.

When a requests comes with a PUT method, django won't process the request.POST variable, even if the content is url encoded.

This issue was already reported, but the decision was taken to leave things as this (That was confirmed after this discussion).

However, I think there is a gap in documentation, since a user testing a RESTful web service will meet a WTF!? effect when using a PUT request.

So I tried to make the documentation clearer, by explaining this difference, and explaining the way to overcome the issue.

There is a pull request, but the patch is attached.

Attachments (2)

documenting_restful_testing.diff (1.7 KB) - added by thibaultj 2 years ago.
Same patch as is the pull request
patch_17360.diff (1.7 KB) - added by zsiciarz 2 years ago.
Patch updated to reflect raw_post_data renamed to body.

Download all attachments as: .zip

Change History (8)

Changed 2 years ago by thibaultj

Same patch as is the pull request

comment:1 Changed 2 years ago by thibaultj

  • Cc thibaultj added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Type changed from Uncategorized to Cleanup/optimization

comment:2 Changed 2 years ago by aaugustin

  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 2 years ago by zsiciarz

  • Triage Stage changed from Accepted to Ready for checkin

Looking good, applies cleanly against trunk. Marking as ready for checkin.

comment:4 Changed 2 years ago by zsiciarz

  • Triage Stage changed from Ready for checkin to Accepted

Oh hold on, looks like raw_post_data is deprecated. Gonna fix the patch soon.

Changed 2 years ago by zsiciarz

Patch updated to reflect raw_post_data renamed to body.

comment:5 Changed 2 years ago by lrekucki

  • Patch needs improvement set

IMHO, this is only adds to confusion. Saying that it "Acts just like :meth:Client.post except with the PUT request method" and then showing it doesn't, is not great. Also, the workaround is not really test client specific, so testing docs are probably not the best place for this. We could instead link to proper docs about request.[body/POST/etc.]

Version 0, edited 2 years ago by lrekucki (next)

comment:6 Changed 18 months ago by aaugustin

  • Resolution set to fixed
  • Status changed from new to closed

I fixed that in e73838b6ddcc7b37c03f9eee04fa6e6a283fedb3. This commit also changed the behavior of the test client.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.