From 4346d8cc2f2ac71fd9900cafb7bbad4310a01a44 Mon Sep 17 00:00:00 2001 From: Tom Harris Date: Sat, 30 Apr 2022 00:26:27 -0400 Subject: [PATCH] Fix Insteon tests (#71092) --- .../insteon/fixtures/kpl_properties.json | 2 +- tests/components/insteon/mock_devices.py | 20 ++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/tests/components/insteon/fixtures/kpl_properties.json b/tests/components/insteon/fixtures/kpl_properties.json index 725432dbedc..db694e4a7eb 100644 --- a/tests/components/insteon/fixtures/kpl_properties.json +++ b/tests/components/insteon/fixtures/kpl_properties.json @@ -3,7 +3,7 @@ "program_lock_on": false, "blink_on_tx_on": false, "resume_dim_on": false, - "led_on": false, + "led_off": false, "key_beep_on": false, "rf_disable_on": false, "powerline_disable_on": false, diff --git a/tests/components/insteon/mock_devices.py b/tests/components/insteon/mock_devices.py index 6e6a8eccfcc..ef64b1e0969 100644 --- a/tests/components/insteon/mock_devices.py +++ b/tests/components/insteon/mock_devices.py @@ -1,7 +1,7 @@ """Mock devices object to test Insteon.""" import asyncio -from unittest.mock import AsyncMock, MagicMock +from unittest.mock import AsyncMock, MagicMock, patch from pyinsteon.address import Address from pyinsteon.constants import ALDBStatus, ResponseStatus @@ -129,18 +129,20 @@ class MockDevices: def fill_properties(self, address, props_dict): """Fill the operating flags and extended properties of a device.""" + device = self._devices[Address(address)] operating_flags = props_dict.get("operating_flags", {}) properties = props_dict.get("properties", {}) - for flag in operating_flags: - value = operating_flags[flag] - if device.operating_flags.get(flag): - device.operating_flags[flag].load(value) - for flag in properties: - value = properties[flag] - if device.properties.get(flag): - device.properties[flag].load(value) + with patch("pyinsteon.subscriber_base.publish_topic", MagicMock()): + for flag in operating_flags: + value = operating_flags[flag] + if device.operating_flags.get(flag): + device.operating_flags[flag].load(value) + for flag in properties: + value = properties[flag] + if device.properties.get(flag): + device.properties[flag].load(value) async def async_add_device(self, address=None, multiple=False): """Mock the async_add_device method."""