From 275e3b7e73ce4f6dfef493daceed7e203bbae7f2 Mon Sep 17 00:00:00 2001 From: "Terence D. Honles" Date: Tue, 10 Jan 2017 13:52:12 -0800 Subject: [PATCH] add additional multipart test cases --- tests/test_multipart.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/test_multipart.py b/tests/test_multipart.py index dd11cd0e923..2387647351b 100644 --- a/tests/test_multipart.py +++ b/tests/test_multipart.py @@ -1014,6 +1014,13 @@ def test_filename(self): self.part.set_content_disposition('related', filename='foo.html') self.assertEqual('foo.html', self.part.filename) + def test_wrap_multipart(self): + writer = aiohttp.multipart.MultipartWriter(boundary=':') + part = aiohttp.multipart.BodyPartWriter(writer) + self.assertEqual(part.headers, writer.headers) + part.headers['X-Custom'] = 'test' + self.assertEqual(part.headers, writer.headers) + class MultipartWriterTestCase(unittest.TestCase): @@ -1080,6 +1087,14 @@ def test_append_form(self): self.assertEqual(part.headers[CONTENT_TYPE], 'application/x-www-form-urlencoded') + def test_append_multipart(self): + subwriter = aiohttp.multipart.MultipartWriter(boundary=':') + subwriter.append_json({'foo': 'bar'}) + self.writer.append(subwriter, {CONTENT_TYPE: 'test/passed'}) + self.assertEqual(1, len(self.writer)) + part = self.writer.parts[0] + self.assertEqual(part.headers[CONTENT_TYPE], 'test/passed') + def test_serialize(self): self.assertEqual([b''], list(self.writer.serialize()))