test_web.web.Web.POST: split out build_form() helper function

This commit is contained in:
Brian Warner 2017-07-24 16:24:14 -05:00
parent 202a9714c4
commit 73d09082d7

View File

@ -536,7 +536,7 @@ class WebMixin(testutil.TimezoneMixin):
url = self.webish_url + urlpath
return do_http("delete", url)
def POST(self, urlpath, followRedirect=False, **fields):
def build_form(self, **fields):
sepbase = "boogabooga"
sep = "--" + sepbase
form = []
@ -566,6 +566,10 @@ class WebMixin(testutil.TimezoneMixin):
if fields:
body = "\r\n".join(form) + "\r\n"
headers["content-type"] = "multipart/form-data; boundary=%s" % sepbase
return (body, headers)
def POST(self, urlpath, followRedirect=False, **fields):
body, headers = self.build_form(**fields)
return self.POST2(urlpath, body, headers, followRedirect)
def POST2(self, urlpath, body="", headers={}, followRedirect=False):