diff options
author | David Arthur <mumrah@gmail.com> | 2012-09-27 20:35:00 -0400 |
---|---|---|
committer | David Arthur <mumrah@gmail.com> | 2012-09-27 20:35:00 -0400 |
commit | 2a332d2983ae306a692b3796e0a309a5e7504097 (patch) | |
tree | f5fef45e65f10dc197e4fbd3faec0819eb3eada0 /test.py | |
parent | 7c86d637f5b0c8088045e382055423024d734deb (diff) | |
download | kafka-python-2a332d2983ae306a692b3796e0a309a5e7504097.tar.gz |
Adding simple (dumb) request tests
Integration tests to come
Diffstat (limited to 'test.py')
-rw-r--r-- | test.py | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -3,7 +3,7 @@ import random import struct import unittest -from kafka import KafkaClient +from kafka import KafkaClient, ProduceRequest, FetchRequest from kafka import gzip_encode, gzip_decode, length_prefix_message ITERATIONS = 1000 @@ -102,5 +102,18 @@ class TestMessage(unittest.TestCase): for j in range(n): self.assertEquals(messages[j].payload, strings[j]) +class TestRequests(unittest.TestCase): + def test_produce_request(self): + req = ProduceRequest("my-topic", 0, [KafkaClient.create_message("testing")]) + enc = KafkaClient.encode_produce_request(req) + expect = "\x00\x00\x00\x08my-topic\x00\x00\x00\x00\x00\x00\x00\x11\x00\x00\x00\r\x01\x00\xe8\xf3Z\x06testing" + self.assertEquals(enc, expect) + + def test_fetch_request(self): + req = FetchRequest("my-topic", 0, 0, 1024) + enc = KafkaClient.encode_fetch_request(req) + expect = "\x00\x01\x00\x08my-topic\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00" + self.assertEquals(enc, expect) + if __name__ == '__main__': unittest.main() |