I'm using django-rest-framework (latest) for REST API, and implemented few test cases in django using built in test client.
following django test case was working fine with django version < 1.5
self.client.put('/core/accounts/%s/'% self.account.id,
data = prepare_dict(self.account),
HTTP_AUTHORIZATION=self.token)
upgraded to django 1.5, all tests are passing except tests related to HTTP PUT
while looking into the issue found this @ https://docs.djangoproject.com/en/dev/releases/1.5/#options-put-and-delete-requests-in-the-test-client
If you were using the data parameter in a PUT request without a
content_type, you must encode your data before passing it to the test
client and set the content_type argument.
So, updated my test to reflect this change and tried following, but still getting http 415 instead of http 200
from django.test.client import MULTIPART_CONTENT, BOUNDARY, encode_multipart
self.client.put('/core/accounts/%s/'% self.account.id,
data = encode_multipart(BOUNDARY, prepare_dict(self.account)),
content_type=MULTIPART_CONTENT,
HTTP_AUTHORIZATION=self.token)
Any idea what I'm missing?
P.S: All functionality is working fine from django-rest-framework built-in web UI
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…