summaryrefslogtreecommitdiff
path: root/test/test_conn.py
diff options
context:
space:
mode:
authorDana Powers <dana.powers@rd.io>2014-08-17 23:39:38 -0700
committerDana Powers <dana.powers@rd.io>2014-08-19 21:27:44 -0700
commitf5802d8a7a846a4660391655874581df96a82691 (patch)
tree532dc7ce8e20b2aa74fe600fa4aebfd6e4d72b27 /test/test_conn.py
parent635b293f0c09d97d9be3a8f47420d81685e29450 (diff)
downloadkafka-python-f5802d8a7a846a4660391655874581df96a82691.tar.gz
Implement last of the skipped test_conn.py tests
Diffstat (limited to 'test/test_conn.py')
-rw-r--r--test/test_conn.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/test/test_conn.py b/test/test_conn.py
index 7392bab..d7d6958 100644
--- a/test/test_conn.py
+++ b/test/test_conn.py
@@ -177,9 +177,25 @@ class ConnTest(unittest2.TestCase):
except ConnectionError:
self.assertEquals(self.conn._dirty, True)
- @unittest2.skip("Not Implemented")
def test_recv__doesnt_consume_extra_data_in_stream(self):
- pass
+ data1 = self.config['payload']
+ size1 = len(data1)
+ encoded1 = struct.pack('>i%ds' % size1, size1, data1)
+ data2 = "an extra payload"
+ size2 = len(data2)
+ encoded2 = struct.pack('>i%ds' % size2, size2, data2)
+
+ self.conn._recv_buffer = encoded1
+ self.conn._recv_buffer += encoded2
+
+ def mock_socket_recv(num_bytes):
+ data = self.conn._recv_buffer[0:num_bytes]
+ self.conn._recv_buffer = self.conn._recv_buffer[num_bytes:]
+ return data
+
+ with mock.patch.object(self.conn._sock, 'recv', new=mock_socket_recv):
+ self.assertEquals(self.conn.recv(self.config['request_id']), self.config['payload'])
+ self.assertEquals(str(self.conn._recv_buffer), encoded2)
def test_close__object_is_reusable(self):