Intelligent timeout handler for setup/bootstrap (#38329)

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
Pascal Vizeli
2020-08-05 14:58:19 +02:00
committed by GitHub
parent caca762088
commit c291d4aa7d
21 changed files with 901 additions and 89 deletions

View File

@@ -488,15 +488,12 @@ async def test_component_warn_slow_setup(hass):
assert result
assert mock_call.called
assert len(mock_call.mock_calls) == 5
assert len(mock_call.mock_calls) == 3
timeout, logger_method = mock_call.mock_calls[0][1][:2]
assert timeout == setup.SLOW_SETUP_WARNING
assert logger_method == setup._LOGGER.warning
timeout, function = mock_call.mock_calls[1][1][:2]
assert timeout == setup.SLOW_SETUP_MAX_WAIT
assert mock_call().cancel.called
@@ -508,8 +505,7 @@ async def test_platform_no_warn_slow(hass):
with patch.object(hass.loop, "call_later") as mock_call:
result = await setup.async_setup_component(hass, "test_component1", {})
assert result
timeout, function = mock_call.mock_calls[0][1][:2]
assert timeout == setup.SLOW_SETUP_MAX_WAIT
assert len(mock_call.mock_calls) == 0
async def test_platform_error_slow_setup(hass, caplog):