Skip to content

Commit 6b79e3e

Browse files
committed
tests: update idle_to_connected tests
1 parent cf467b7 commit 6b79e3e

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

test/test_idle_to_connected.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,20 @@ def test_idle_to_connected(manager):
6969
# Verify the state change message
7070
assert state_change_msg[0][0]["state"] == "connected"
7171
assert state_change_msg[1]["command"] == "state-changed"
72+
73+
74+
def test_idle_to_connected_with_exception(manager):
75+
"""Test transitioning Manager from 'idle' to 'connected' state with an exception."""
76+
# Simulate an exception during the connection process
77+
manager.consumer.send_message = lambda *args, **kwargs: (
78+
1 / 0 # This will raise a ZeroDivisionError
79+
)
80+
81+
with pytest.raises(ZeroDivisionError):
82+
manager.trigger("connect", event=None)
83+
84+
# State should still be 'idle' after the exception
85+
assert manager.state == "idle"
86+
87+
# Check that no messages were sent to the consumer
88+
assert not manager.consumer.messages

0 commit comments

Comments
 (0)