Skip to content

Commit c030d3e

Browse files
committed
fix unit tests following heartbeat update
1 parent 5b7627a commit c030d3e

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

tests/unit/test_connection.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@
2222
import time
2323
from threading import Lock
2424

25-
from cassandra.cluster import Cluster, Session
25+
from cassandra import OperationTimedOut
26+
from cassandra.cluster import Cluster
2627
from cassandra.connection import (Connection, HEADER_DIRECTION_TO_CLIENT, ProtocolError,
27-
locally_supported_compressions, ConnectionHeartbeat, _Frame, Timer, TimerManager)
28+
locally_supported_compressions, ConnectionHeartbeat, _Frame, Timer, TimerManager,
29+
ConnectionException)
2830
from cassandra.marshal import uint8_pack, uint32_pack, int32_pack
2931
from cassandra.protocol import (write_stringmultimap, write_int, write_string,
3032
SupportedMessage, ProtocolHandler)
@@ -382,8 +384,8 @@ def send_msg(msg, req_id, msg_callback):
382384
connection.send_msg.assert_has_calls([call(ANY, request_id, ANY)] * get_holders.call_count)
383385
connection.defunct.assert_has_calls([call(ANY)] * get_holders.call_count)
384386
exc = connection.defunct.call_args_list[0][0][0]
385-
self.assertIsInstance(exc, Exception)
386-
self.assertEqual(exc.args, Exception('Connection heartbeat failure').args)
387+
self.assertIsInstance(exc, ConnectionException)
388+
self.assertRegex(exc.args[0], r'^Received unexpected response to OptionsMessage.*')
387389
holder.return_connection.assert_has_calls([call(connection)] * get_holders.call_count)
388390

389391
def test_timeout(self, *args):
@@ -410,8 +412,9 @@ def send_msg(msg, req_id, msg_callback):
410412
connection.send_msg.assert_has_calls([call(ANY, request_id, ANY)] * get_holders.call_count)
411413
connection.defunct.assert_has_calls([call(ANY)] * get_holders.call_count)
412414
exc = connection.defunct.call_args_list[0][0][0]
413-
self.assertIsInstance(exc, Exception)
414-
self.assertEqual(exc.args, Exception('Connection heartbeat failure').args)
415+
self.assertIsInstance(exc, OperationTimedOut)
416+
self.assertEqual(exc.errors, 'Connection heartbeat timeout after 0.05 seconds')
417+
self.assertEqual(exc.last_host, 'localhost')
415418
holder.return_connection.assert_has_calls([call(connection)] * get_holders.call_count)
416419

417420

0 commit comments

Comments
 (0)