(
buf: bytearray, stream: AbstractStreamWriter, writer: aiohttp.MultipartWriter
)
| 1230 | |
| 1231 | |
| 1232 | async def test_writer_write( |
| 1233 | buf: bytearray, stream: AbstractStreamWriter, writer: aiohttp.MultipartWriter |
| 1234 | ) -> None: |
| 1235 | writer.append("foo-bar-baz") |
| 1236 | writer.append_json({"test": "passed"}) |
| 1237 | writer.append_form({"test": "passed"}) |
| 1238 | writer.append_form([("one", 1), ("two", 2)]) |
| 1239 | |
| 1240 | sub_multipart = aiohttp.MultipartWriter(boundary="::") |
| 1241 | sub_multipart.append("nested content") |
| 1242 | sub_multipart.headers["X-CUSTOM"] = "test" |
| 1243 | writer.append(sub_multipart) |
| 1244 | await writer.write(stream) |
| 1245 | |
| 1246 | assert ( |
| 1247 | b"--:\r\n" |
| 1248 | b"Content-Type: text/plain; charset=utf-8\r\n" |
| 1249 | b"Content-Length: 11\r\n\r\n" |
| 1250 | b"foo-bar-baz" |
| 1251 | b"\r\n" |
| 1252 | b"--:\r\n" |
| 1253 | b"Content-Type: application/json\r\n" |
| 1254 | b"Content-Length: 18\r\n\r\n" |
| 1255 | b'{"test": "passed"}' |
| 1256 | b"\r\n" |
| 1257 | b"--:\r\n" |
| 1258 | b"Content-Type: application/x-www-form-urlencoded\r\n" |
| 1259 | b"Content-Length: 11\r\n\r\n" |
| 1260 | b"test=passed" |
| 1261 | b"\r\n" |
| 1262 | b"--:\r\n" |
| 1263 | b"Content-Type: application/x-www-form-urlencoded\r\n" |
| 1264 | b"Content-Length: 11\r\n\r\n" |
| 1265 | b"one=1&two=2" |
| 1266 | b"\r\n" |
| 1267 | b"--:\r\n" |
| 1268 | b'Content-Type: multipart/mixed; boundary="::"\r\n' |
| 1269 | b"X-CUSTOM: test\r\nContent-Length: 93\r\n\r\n" |
| 1270 | b"--::\r\n" |
| 1271 | b"Content-Type: text/plain; charset=utf-8\r\n" |
| 1272 | b"Content-Length: 14\r\n\r\n" |
| 1273 | b"nested content\r\n" |
| 1274 | b"--::--\r\n" |
| 1275 | b"\r\n" |
| 1276 | b"--:--\r\n" |
| 1277 | ) == bytes(buf) |
| 1278 | |
| 1279 | |
| 1280 | async def test_writer_write_no_close_boundary( |
nothing calls this directly
no test coverage detected
searching dependent graphs…