use recursion_limit

This commit is contained in:
Thomas Protzner
2024-08-12 17:39:21 +00:00
parent dec1b0fc4c
commit 9e51c57160

View File

@@ -2,6 +2,7 @@
from datetime import timedelta
import http
import sys
import time
from unittest.mock import AsyncMock, patch
@@ -148,12 +149,12 @@ async def test_websocket_not_available(
)
# Initial call count and range for reconnection attempts
mock_automower_client.reset_mock()
recursion_limit = sys.getrecursionlimit()
# Perform reconnection attempts
for count in range(1, 945):
for count in range(recursion_limit):
await hass.async_block_till_done()
assert mock_automower_client.auth.websocket_connect.call_count == count
assert mock_automower_client.auth.websocket_connect.call_count == count + 1
assert mock_config_entry.state is ConfigEntryState.LOADED
# Simulate a successful connection
@@ -170,7 +171,10 @@ async def test_websocket_not_available(
freezer.tick(timedelta(seconds=0))
async_fire_time_changed(hass)
await hass.async_block_till_done()
assert mock_automower_client.auth.websocket_connect.call_count == 946
assert (
mock_automower_client.auth.websocket_connect.call_count
== recursion_limit + 2
)
async def test_device_info(