Use debouncer in mysensors (#84638)
* Use debouncer in mysensors * Clean cover tests * Fix debouncer mocking * Follow typing
This commit is contained in:
parent
624c93bb38
commit
d441fb2ec5
9 changed files with 31 additions and 159 deletions
|
@ -144,8 +144,26 @@ async def integration_fixture(
|
|||
"""Set up the mysensors integration with a config entry."""
|
||||
config: dict[str, Any] = {}
|
||||
config_entry.add_to_hass(hass)
|
||||
with patch(
|
||||
"homeassistant.components.mysensors.device.Debouncer", autospec=True
|
||||
) as debouncer_class:
|
||||
|
||||
def debouncer(
|
||||
*args: Any, function: Callable | None = None, **kwargs: Any
|
||||
) -> MagicMock:
|
||||
"""Mock the debouncer."""
|
||||
|
||||
async def call_debouncer():
|
||||
"""Mock call to debouncer."""
|
||||
if function is not None:
|
||||
function()
|
||||
|
||||
debounce_instance = MagicMock()
|
||||
debounce_instance.async_call.side_effect = call_debouncer
|
||||
return debounce_instance
|
||||
|
||||
debouncer_class.side_effect = debouncer
|
||||
|
||||
with patch("homeassistant.components.mysensors.device.UPDATE_DELAY", new=0):
|
||||
await async_setup_component(hass, DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
yield config_entry
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue