Skip to content

Commit

Permalink
add additional multipart test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
terencehonles authored and Nikolay Kim committed Jan 21, 2017
1 parent 5978706 commit 275e3b7
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/test_multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down Expand Up @@ -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()))

Expand Down

0 comments on commit 275e3b7

Please sign in to comment.