mirror of
https://github.com/home-assistant/core.git
synced 2025-08-17 19:41:45 +02:00
test that we connect and listen successfully
This commit is contained in:
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user