lundi 26 janvier 2015

How to test the payload of a POST request?

Suppose I have a method that sends a POST request with JSON data. What would be a good way to test the JSON payload? I know how to mock requests and monkey patch the response in general (I'm using HTTPretty for mocking responses), but how could the payload of a POST (or PUT and others for that matter) be tested?



def update_progress(self):
# fetch all interesting stuff
interesting = ...
payload = list()
for i in interesting:
# do something
payload += ...

self.api.post('v1/update', params=payload)


where self.api.post is a custom method for sending a POST by calling requests.request.


Thanks


Aucun commentaire:

Enregistrer un commentaire