summaryrefslogtreecommitdiff
path: root/test/test_protocol.py
diff options
context:
space:
mode:
authorMark Roberts <wizzat@gmail.com>2014-04-08 11:02:57 -0700
committerMark Roberts <wizzat@gmail.com>2014-04-08 11:02:57 -0700
commitd7c5bbf7d4c59d9fe58e96c53340be17392cfa02 (patch)
tree74bdd7fa474c6c555cf0eeb332722d7fec06c093 /test/test_protocol.py
parentf0def436c6c9499aa384d8a3fe5319e0c8b9d7da (diff)
downloadkafka-python-d7c5bbf7d4c59d9fe58e96c53340be17392cfa02.tar.gz
Reinstate test_integrate, make test_protocol more explicit, create testutil
Diffstat (limited to 'test/test_protocol.py')
-rw-r--r--test/test_protocol.py33
1 files changed, 28 insertions, 5 deletions
diff --git a/test/test_protocol.py b/test/test_protocol.py
index 430e65e..e86b6f0 100644
--- a/test/test_protocol.py
+++ b/test/test_protocol.py
@@ -86,7 +86,13 @@ class TestProtocol(unittest.TestCase):
self.assertEqual(msg.value, expect)
def test_encode_message_header(self):
- expect = '\x00\n\x00\x00\x00\x00\x00\x04\x00\x07client3'
+ expect = (
+ "\x00\n" # API Key
+ "\x00\x00" # API Version
+ "\x00\x00\x00\x04" # CorrelationId
+ "\x00\x07" # Client length
+ "client3" # Client Id
+ )
encoded = KafkaProtocol._encode_message_header("client3", 4, 10)
self.assertEqual(encoded, expect)
@@ -111,10 +117,27 @@ class TestProtocol(unittest.TestCase):
def test_encode_message_set(self):
message_set = [create_message("v1", "k1"), create_message("v2", "k2")]
encoded = KafkaProtocol._encode_message_set(message_set)
- expect = ("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x12W\xe7In\x00"
- "\x00\x00\x00\x00\x02k1\x00\x00\x00\x02v1\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\x00\x00\x12\xff\x06\x02I\x00\x00\x00"
- "\x00\x00\x02k2\x00\x00\x00\x02v2")
+ expect = (
+ "\x00\x00\x00\x00\x00\x00\x00\x00" # Msgset1, Offset (Meaningless)
+ "\x00\x00\x00\x12" # Msgset1, Msg Size
+ "\x57\xe7\x49\x6e" # Msg1, CRC
+ "\x00" # Msg1, Magic
+ "\x00" # Msg1, Flags
+ "\x00\x00\x00\x02" # Msg1, key size
+ "k1" # Msg1, key
+ "\x00\x00\x00\x02" # Msg1, value size
+ "v1" # Msg1, value
+ "\x00\x00\x00\x00\x00\x00\x00\x00" # Msgset2, Offset (Meaningless)
+ "\x00\x00\x00\x12" # Msgset2, Msg Size
+ "\xff\x06\x02\x49" # Msg2, CRC
+ "\x00" # Msg2, Magic
+ "\x00" # Msg2, flags
+ "\x00\x00\x00\x02" # Msg2, key size
+ "k2" # Msg2, key
+ "\x00\x00\x00\x02" # Msg2, value size
+ "v2" # MSg2, value
+ )
+
self.assertEqual(encoded, expect)
def test_decode_message(self):