dkanavis

Untitled

Feb 4th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. import json
  2. from ... import application
  3.  
  4. class FakeInput(object):
  5.     def __init__(self, fakedata):
  6.         self.fakedata = fakedata
  7.     def read():
  8.         return self.fakedata
  9.  
  10. environ = json.loads(....) # Here we load bait json. If it's POST, it should contain POST body as ["postdata"]
  11.  
  12. if environ["REQUEST_METHOD"] == "POST":
  13.     environ["wsgi.input"] = FakeInput(environ["postdata"])
  14.  
  15.  
  16. result_status = None
  17. def start_response(status, *shitargs):
  18.     global result_status
  19.     result_status = status
  20.    
  21. result = application(environ, start_response)
  22.  
  23. # Check expected values of result_status, maybe also result
Advertisement
Add Comment
Please, Sign In to add comment