Handling PUT & PATCH request in Class based Testing #9125
Replies: 5 comments 1 reply
-
I have been facing problems recently , Provide a solution if possible |
Beta Was this translation helpful? Give feedback.
-
Hello there! |
Beta Was this translation helpful? Give feedback.
-
I am trying to say that for function based testing there is a way of put and patch request testing but for class based views I can't see any put patch request handling code |
Beta Was this translation helpful? Give feedback.
-
I think I get it! You can just use # for put
response = self.client.put(url, data, format='json')
# for patch
response = self.client.patch(url, data, format='json') |
Beta Was this translation helpful? Give feedback.
-
payload_patch_data = {
"cname":"Best Python Tutorial",
}
# Testing PATCH request
url_patch=reverse('course',args={"pk":f"{payload['cid']}"})
response_patch=self.client.patch(url_patch,payload_patch_data,format='json')
self.assertEqual(response_patch.status_code,status.HTTP_200_OK)
print("\t\tPATCH REQUEST SUCCESSFUL") Actual Its saying 400 != 200 plus I want to recheck the patch data by again from gaining data from get request |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
How to manage PUT and PATCH request via APItestcase / class based testing using DRF
-[ ] Testing By APItestcase
Beta Was this translation helpful? Give feedback.
All reactions