test that we connect and listen successfully

This commit is contained in:
Thomas Protzner
2024-08-12 19:15:19 +00:00
parent 40632e3aea
commit 196bbb684e

View File

@@ -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