Skip to content

Commit

Permalink
Added unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
thedrow committed Oct 3, 2024
1 parent db4973a commit 0435548
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions t/unit/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,41 @@ def test_connection_failover_with_total_timeout(self):
conn.default_channel
assert conn._establish_connection.call_count == 2

def test_connection_timeout_with_errback(self):
errback = Mock()
with Connection(
['server1', 'server2'],
transport=TimeoutingTransport,
connect_timeout=1,
transport_options={
'connect_retries_timeout': 2,
'interval_start': 0,
'interval_step': 0,
'errback': errback
},
) as conn:
with pytest.raises(OperationalError):
conn.default_channel

errback.assert_called()

def test_connection_timeout_with_callback(self):
callback = Mock()
with Connection(
['server1', 'server2'],
transport=TimeoutingTransport,
connect_timeout=1,
transport_options={
'connect_retries_timeout': 2,
'interval_start': 0,
'interval_step': 0,
'callback': callback
},
) as conn:
with pytest.raises(OperationalError):
conn.default_channel

callback.assert_called()

class test_Connection_with_transport_options:

Expand Down

0 comments on commit 0435548

Please sign in to comment.