Wait for config entry platforms in KNX (#77437)

pull/77447/head
Matthias Alphart 2022-08-28 12:36:31 +02:00 committed by GitHub
parent eab0ff5185
commit 441d7c0461
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 7 deletions

View File

@ -247,7 +247,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
create_knx_exposure(hass, knx_module.xknx, expose_config)
)
hass.config_entries.async_setup_platforms(
await hass.config_entries.async_forward_entry_setups(
entry,
[
platform

View File

@ -55,16 +55,21 @@ class KNXTestKit:
async def setup_integration(self, config):
"""Create the KNX integration."""
def disable_rate_limiter():
"""Disable rate limiter for tests."""
async def patch_xknx_start():
"""Patch `xknx.start` for unittests."""
# after XKNX.__init__() to not overwrite it by the config entry again
# before StateUpdater starts to avoid slow down of tests
self.xknx.rate_limit = 0
# set XknxConnectionState.CONNECTED to avoid `unavailable` entities at startup
# and start StateUpdater. This would be awaited on normal startup too.
await self.xknx.connection_manager.connection_state_changed(
XknxConnectionState.CONNECTED
)
def knx_ip_interface_mock():
"""Create a xknx knx ip interface mock."""
mock = Mock()
mock.start = AsyncMock(side_effect=disable_rate_limiter)
mock.start = AsyncMock(side_effect=patch_xknx_start)
mock.stop = AsyncMock()
mock.send_telegram = AsyncMock(side_effect=self._outgoing_telegrams.put)
return mock
@ -81,9 +86,6 @@ class KNXTestKit:
):
self.mock_config_entry.add_to_hass(self.hass)
await async_setup_component(self.hass, KNX_DOMAIN, {KNX_DOMAIN: config})
await self.xknx.connection_manager.connection_state_changed(
XknxConnectionState.CONNECTED
)
await self.hass.async_block_till_done()
########################