diff --git a/tests/components/husqvarna_automower/test_init.py b/tests/components/husqvarna_automower/test_init.py index 2636e109cd6..88f0a87e865 100644 --- a/tests/components/husqvarna_automower/test_init.py +++ b/tests/components/husqvarna_automower/test_init.py @@ -158,9 +158,15 @@ async def test_websocket_not_available( assert mock_config_entry.state is ConfigEntryState.LOADED # Simulate a successful connection + caplog.clear() mock_automower_client.auth.websocket_connect.side_effect = None await hass.async_block_till_done() + assert ( + mock_automower_client.auth.websocket_connect.call_count + == temporary_recursion_limit + 1 + ) assert mock_automower_client.start_listening.call_count == 1 + assert "Trying to reconnect: Boom" not in caplog.text # Simulate a start_listening TimeoutException mock_automower_client.start_listening.side_effect = TimeoutException("Boom") @@ -169,6 +175,19 @@ async def test_websocket_not_available( mock_automower_client.auth.websocket_connect.call_count == temporary_recursion_limit + 2 ) + assert mock_automower_client.start_listening.call_count == 2 + + # Simulate a successful connection + caplog.clear() + mock_automower_client.start_listening.side_effect = None + await hass.async_block_till_done() + assert ( + mock_automower_client.auth.websocket_connect.call_count + == temporary_recursion_limit + 3 + ) + assert mock_automower_client.start_listening.call_count == 3 + assert "Trying to reconnect: Boom" not in caplog.text + sys.setrecursionlimit(default_recursion_limit) assert sys.getrecursionlimit() == default_recursion_limit