52
52
self.assertEqual(encoded,
53
53
b'--' + b(BOUNDARY) + b'\r\n'
54
54
b'Content-Disposition: form-data; name="k"\r\n'
55
b'Content-Type: text/plain\r\n'
58
57
b'--' + b(BOUNDARY) + b'\r\n'
59
58
b'Content-Disposition: form-data; name="k2"\r\n'
60
b'Content-Type: text/plain\r\n'
63
61
b'--' + b(BOUNDARY) + b'--\r\n'
66
64
self.assertEqual(content_type,
67
b'multipart/form-data; boundary=' + b(BOUNDARY))
65
'multipart/form-data; boundary=' + str(BOUNDARY))
70
68
def test_filename(self):
84
82
self.assertEqual(content_type,
85
b'multipart/form-data; boundary=' + b(BOUNDARY))
83
'multipart/form-data; boundary=' + str(BOUNDARY))
86
def test_textplain(self):
87
fields = [('k', ('somefile.txt', b'v'))]
89
encoded, content_type = encode_multipart_formdata(fields, boundary=BOUNDARY)
91
self.assertEqual(encoded,
92
b'--' + b(BOUNDARY) + b'\r\n'
93
b'Content-Disposition: form-data; name="k"; filename="somefile.txt"\r\n'
94
b'Content-Type: text/plain\r\n'
97
b'--' + b(BOUNDARY) + b'--\r\n'
100
self.assertEqual(content_type,
101
'multipart/form-data; boundary=' + str(BOUNDARY))
104
def test_explicit(self):
105
fields = [('k', ('somefile.txt', b'v', 'image/jpeg'))]
107
encoded, content_type = encode_multipart_formdata(fields, boundary=BOUNDARY)
109
self.assertEqual(encoded,
110
b'--' + b(BOUNDARY) + b'\r\n'
111
b'Content-Disposition: form-data; name="k"; filename="somefile.txt"\r\n'
112
b'Content-Type: image/jpeg\r\n'
115
b'--' + b(BOUNDARY) + b'--\r\n'
118
self.assertEqual(content_type,
119
'multipart/form-data; boundary=' + str(BOUNDARY))