mirror of
https://github.com/home-assistant/core.git
synced 2025-08-24 06:51:33 +02:00
use recursion_limit
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import http
|
import http
|
||||||
|
import sys
|
||||||
import time
|
import time
|
||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
@@ -148,12 +149,12 @@ async def test_websocket_not_available(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Initial call count and range for reconnection attempts
|
# Initial call count and range for reconnection attempts
|
||||||
|
|
||||||
mock_automower_client.reset_mock()
|
mock_automower_client.reset_mock()
|
||||||
|
recursion_limit = sys.getrecursionlimit()
|
||||||
# Perform reconnection attempts
|
# Perform reconnection attempts
|
||||||
for count in range(1, 945):
|
for count in range(recursion_limit):
|
||||||
await hass.async_block_till_done()
|
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
|
assert mock_config_entry.state is ConfigEntryState.LOADED
|
||||||
|
|
||||||
# Simulate a successful connection
|
# Simulate a successful connection
|
||||||
@@ -170,7 +171,10 @@ async def test_websocket_not_available(
|
|||||||
freezer.tick(timedelta(seconds=0))
|
freezer.tick(timedelta(seconds=0))
|
||||||
async_fire_time_changed(hass)
|
async_fire_time_changed(hass)
|
||||||
await hass.async_block_till_done()
|
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(
|
async def test_device_info(
|
||||||
|
Reference in New Issue
Block a user