예제 #1
0
 def test_create(self):
     simple_field = RequestField("somename", "data")
     assert simple_field.render_headers() == "\r\n"
     filename_field = RequestField("somename", "data", filename="somefile.txt")
     assert filename_field.render_headers() == "\r\n"
     headers_field = RequestField("somename", "data", headers={"Content-Length": 4})
     assert headers_field.render_headers() == "Content-Length: 4\r\n\r\n"
예제 #2
0
 def test_make_multipart_empty_filename(self):
     field = RequestField("somename", "data", "")
     field.make_multipart(content_type="application/octet-stream")
     assert (
         field.render_headers()
         == 'Content-Disposition: form-data; name="somename"; filename=""\r\n'
         "Content-Type: application/octet-stream\r\n"
         "\r\n"
     )
예제 #3
0
 def test_make_multipart(self):
     field = RequestField("somename", "data")
     field.make_multipart(content_type="image/jpg", content_location="/test")
     assert (
         field.render_headers()
         == 'Content-Disposition: form-data; name="somename"\r\n'
         "Content-Type: image/jpg\r\n"
         "Content-Location: /test\r\n"
         "\r\n"
     )