summaryrefslogtreecommitdiff
path: root/test/test_conn.py
diff options
context:
space:
mode:
authorDana Powers <dana.powers@rd.io>2014-08-17 23:11:33 -0700
committerDana Powers <dana.powers@rd.io>2014-08-19 21:27:44 -0700
commit635b293f0c09d97d9be3a8f47420d81685e29450 (patch)
tree8a5d2313f144f7f00d95eabb3232edf59061296b /test/test_conn.py
parentb106f3679eed9a8caa40d9e5353db3dc4b3c005c (diff)
downloadkafka-python-635b293f0c09d97d9be3a8f47420d81685e29450.tar.gz
Implement a few more skipped tests in test/test_conn.py
Diffstat (limited to 'test/test_conn.py')
-rw-r--r--test/test_conn.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/test/test_conn.py b/test/test_conn.py
index 6213440..7392bab 100644
--- a/test/test_conn.py
+++ b/test/test_conn.py
@@ -163,14 +163,29 @@ class ConnTest(unittest2.TestCase):
self.conn._read_bytes(len(self.config['payload']))
self.assertEqual(socket.create_connection.call_count, 1)
- @unittest2.skip("Not Implemented")
def test_recv__failure_sets_dirty_connection(self):
- pass
+
+ def raise_error(*args):
+ raise socket.error
+
+ # test that recv'ing attempts to reconnect
+ assert self.conn._dirty is False
+ assert isinstance(self.conn._sock, mock.Mock)
+ self.conn._sock.recv.side_effect=raise_error
+ try:
+ self.conn.recv(self.config['request_id'])
+ except ConnectionError:
+ self.assertEquals(self.conn._dirty, True)
@unittest2.skip("Not Implemented")
def test_recv__doesnt_consume_extra_data_in_stream(self):
pass
- @unittest2.skip("Not Implemented")
def test_close__object_is_reusable(self):
- pass
+
+ # test that sending to a closed connection
+ # will re-connect and send data to the socket
+ self.conn.close()
+ self.conn.send(self.config['request_id'], self.config['payload'])
+ self.assertEqual(socket.create_connection.call_count, 1)
+ self.conn._sock.sendall.assert_called_with(self.config['payload'])