Permalink
Browse files

add test case for decoding a chunked message

  • Loading branch information...
1 parent 116f851 commit 47be0793e1f5ada2f100a83ecabf346a58e2b30a @flaviogrossi committed May 13, 2014
Showing with 15 additions and 1 deletion.
  1. +15 −1 tests/test_codec.py
View
@@ -104,7 +104,7 @@ class MilterDecoderTest(MilterCodecTest):
def setUp(self):
self.decoder = MilterDecoder()
- def test_encode_messages(self):
+ def test_decode_messages(self):
for msg, encoded in self.msgs:
self.decoder.feed(encoded)
self.assertEquals(next(self.decoder.decode()), msg)
@@ -119,6 +119,20 @@ def test_multiple_messages(self):
self.assertEquals(messages, res)
+ def test_chunked_messages(self):
+ chunks = ('\x00\x00\x00\x07Bmy', 'body')
+
+ decoded = []
+ for chunk in chunks:
+ self.decoder.feed(chunk)
+ try:
+ decoded.append(next(self.decoder.decode()))
+ except StopIteration:
+ pass
+ self.assertEquals(len(decoded), 1)
+ self.assertEquals(decoded[0],
+ MilterMessage('SMFIC_BODY', dict(buf='mybody')))
+
class MilterEncoderTest(MilterCodecTest):
def setUp(self):

0 comments on commit 47be079

Please sign in to comment.