Cache matching MQTT subscriptions (#41433)

This commit is contained in:
Erik Montnemery authored and GitHub committed 2020-10-08 08:52:23 +02:00
1 parent 85603dcd08
commit 392d5c673a
2 files changed
+19 -5

No files matched your search

+5 -1
View File
@@ -384,9 +384,13 @@ async def mqtt_mock(hass, mqtt_client_mock, mqtt_config):
assert result
await hass.async_block_till_done()
# Workaround: asynctest==0.13 fails on @functools.lru_cache
spec = dir(hass.data["mqtt"])
spec.remove("_matching_subscriptions")
mqtt_component_mock = MagicMock(
return_value=hass.data["mqtt"],
spec_set=hass.data["mqtt"],
spec_set=spec,
wraps=hass.data["mqtt"],
)
mqtt_component_mock._mqttc = mqtt_client_mock