Payload

I want the website to trigger a multipage post with Mock. The problem I have is the lack of a request payload.

Here's my request using webtest:

res = app.post(
        my_url,
        upload_files=files
    )

      

DummyRequest pyramid

boundary = "my random string"
content_type = "multipart/form-data; boundary=" + boundary
headers = {"Content-Type":content_type}
from base64 import standard_b64encode
body = standard_b64encode(boundary)
body += standard_b64encode("Content-Disposition: form-data; name=\"file\"; filename=\"" + filename + "\"")
body += standard_b64encode("Content-Type: */*")                           
body += actual_file
from pyramid.testing import DummyRequest
request = testing.DummyRequest(path=my_path, headers=headers, body=body, post="lmnop")
request.context = testing.DummyResource()
from somewhere import MyClass
imitate = MyClass(request)
response = imitate.formMethod()
self.assertEqual('200 Success', response.status)

      

Has anyone had any luck setting up a query payload for a dummy multi-page query request?

I couldn't find how to get webtest.forms.Upload

to play well since I can create my object there. Any suggestions would be appreciated, thanks.

+3


source to share





All Articles