Fix Insteon tests (#71092)

pull/71294/head
Tom Harris 2022-04-30 00:26:27 -04:00 committed by Paulus Schoutsen
parent 4c7c7b72b7
commit 4346d8cc2f
2 changed files with 12 additions and 10 deletions

View File

@ -3,7 +3,7 @@
"program_lock_on": false, "program_lock_on": false,
"blink_on_tx_on": false, "blink_on_tx_on": false,
"resume_dim_on": false, "resume_dim_on": false,
"led_on": false, "led_off": false,
"key_beep_on": false, "key_beep_on": false,
"rf_disable_on": false, "rf_disable_on": false,
"powerline_disable_on": false, "powerline_disable_on": false,

View File

@ -1,7 +1,7 @@
"""Mock devices object to test Insteon.""" """Mock devices object to test Insteon."""
import asyncio import asyncio
from unittest.mock import AsyncMock, MagicMock from unittest.mock import AsyncMock, MagicMock, patch
from pyinsteon.address import Address from pyinsteon.address import Address
from pyinsteon.constants import ALDBStatus, ResponseStatus from pyinsteon.constants import ALDBStatus, ResponseStatus
@ -129,18 +129,20 @@ class MockDevices:
def fill_properties(self, address, props_dict): def fill_properties(self, address, props_dict):
"""Fill the operating flags and extended properties of a device.""" """Fill the operating flags and extended properties of a device."""
device = self._devices[Address(address)] device = self._devices[Address(address)]
operating_flags = props_dict.get("operating_flags", {}) operating_flags = props_dict.get("operating_flags", {})
properties = props_dict.get("properties", {}) properties = props_dict.get("properties", {})
for flag in operating_flags: with patch("pyinsteon.subscriber_base.publish_topic", MagicMock()):
value = operating_flags[flag] for flag in operating_flags:
if device.operating_flags.get(flag): value = operating_flags[flag]
device.operating_flags[flag].load(value) if device.operating_flags.get(flag):
for flag in properties: device.operating_flags[flag].load(value)
value = properties[flag] for flag in properties:
if device.properties.get(flag): value = properties[flag]
device.properties[flag].load(value) if device.properties.get(flag):
device.properties[flag].load(value)
async def async_add_device(self, address=None, multiple=False): async def async_add_device(self, address=None, multiple=False):
"""Mock the async_add_device method.""" """Mock the async_add_device method."""