Add warning for slow platforms/components (#6467)
* Add warning for slow platforms/components * Add test for slow component setup. * Add test for slow platform setup * Fix tests on Py34
This commit is contained in:
parent
629b2e81ba
commit
bb4f23f8e7
4 changed files with 67 additions and 4 deletions
|
@ -407,3 +407,23 @@ def test_component_cannot_depend_config(hass):
|
|||
result = yield from setup._async_process_dependencies(
|
||||
hass, None, 'test', ['config'])
|
||||
assert not result
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_component_warn_slow_setup(hass):
|
||||
"""Warn we log when a component setup takes a long time."""
|
||||
loader.set_component('test_component1', MockModule('test_component1'))
|
||||
with mock.patch.object(hass.loop, 'call_later', mock.MagicMock()) \
|
||||
as mock_call:
|
||||
result = yield from setup.async_setup_component(
|
||||
hass, 'test_component1', {})
|
||||
assert result
|
||||
assert mock_call.called
|
||||
assert len(mock_call.mock_calls) == 2
|
||||
|
||||
timeout, logger_method = mock_call.mock_calls[0][1][:2]
|
||||
|
||||
assert timeout == setup.SLOW_SETUP_WARNING
|
||||
assert logger_method == setup._LOGGER.warning
|
||||
|
||||
assert mock_call().cancel.called
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue