File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments