Skip to content

Commit 635b293

Browse files
author
Dana Powers
committed
Implement a few more skipped tests in test/test_conn.py
1 parent b106f36 commit 635b293

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

test/test_conn.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,29 @@ def test_recv__reconnects_on_dirty_conn(self):
163163
self.conn._read_bytes(len(self.config['payload']))
164164
self.assertEqual(socket.create_connection.call_count, 1)
165165

166-
@unittest2.skip("Not Implemented")
167166
def test_recv__failure_sets_dirty_connection(self):
168-
pass
167+
168+
def raise_error(*args):
169+
raise socket.error
170+
171+
# test that recv'ing attempts to reconnect
172+
assert self.conn._dirty is False
173+
assert isinstance(self.conn._sock, mock.Mock)
174+
self.conn._sock.recv.side_effect=raise_error
175+
try:
176+
self.conn.recv(self.config['request_id'])
177+
except ConnectionError:
178+
self.assertEquals(self.conn._dirty, True)
169179

170180
@unittest2.skip("Not Implemented")
171181
def test_recv__doesnt_consume_extra_data_in_stream(self):
172182
pass
173183

174-
@unittest2.skip("Not Implemented")
175184
def test_close__object_is_reusable(self):
176-
pass
185+
186+
# test that sending to a closed connection
187+
# will re-connect and send data to the socket
188+
self.conn.close()
189+
self.conn.send(self.config['request_id'], self.config['payload'])
190+
self.assertEqual(socket.create_connection.call_count, 1)
191+
self.conn._sock.sendall.assert_called_with(self.config['payload'])

0 commit comments

Comments
 (0)