|
@@ -9,6 +9,7 @@ from custom_components.goldair_climate.fan.const import (
|
|
|
from custom_components.goldair_climate.fan.light import GoldairFanLedDisplayLight
|
|
from custom_components.goldair_climate.fan.light import GoldairFanLedDisplayLight
|
|
|
|
|
|
|
|
from ..const import FAN_PAYLOAD
|
|
from ..const import FAN_PAYLOAD
|
|
|
|
|
+from ..helpers import assert_device_properties_set
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestLight(IsolatedAsyncioTestCase):
|
|
class TestLight(IsolatedAsyncioTestCase):
|
|
@@ -51,26 +52,16 @@ class TestLight(IsolatedAsyncioTestCase):
|
|
|
self.assertEqual(self.subject.is_on, False)
|
|
self.assertEqual(self.subject.is_on, False)
|
|
|
|
|
|
|
|
async def test_turn_on(self):
|
|
async def test_turn_on(self):
|
|
|
- result = AsyncMock()
|
|
|
|
|
- self.subject._device.async_set_property.return_value = result()
|
|
|
|
|
-
|
|
|
|
|
- await self.subject.async_turn_on()
|
|
|
|
|
-
|
|
|
|
|
- self.subject._device.async_set_property.assert_called_once_with(
|
|
|
|
|
- PROPERTY_TO_DPS_ID[ATTR_DISPLAY_ON], True
|
|
|
|
|
- )
|
|
|
|
|
- result.assert_awaited()
|
|
|
|
|
|
|
+ async with assert_device_properties_set(
|
|
|
|
|
+ self.subject._device, {PROPERTY_TO_DPS_ID[ATTR_DISPLAY_ON]: True}
|
|
|
|
|
+ ):
|
|
|
|
|
+ await self.subject.async_turn_on()
|
|
|
|
|
|
|
|
async def test_turn_off(self):
|
|
async def test_turn_off(self):
|
|
|
- result = AsyncMock()
|
|
|
|
|
- self.subject._device.async_set_property.return_value = result()
|
|
|
|
|
-
|
|
|
|
|
- await self.subject.async_turn_off()
|
|
|
|
|
-
|
|
|
|
|
- self.subject._device.async_set_property.assert_called_once_with(
|
|
|
|
|
- PROPERTY_TO_DPS_ID[ATTR_DISPLAY_ON], False
|
|
|
|
|
- )
|
|
|
|
|
- result.assert_awaited()
|
|
|
|
|
|
|
+ async with assert_device_properties_set(
|
|
|
|
|
+ self.subject._device, {PROPERTY_TO_DPS_ID[ATTR_DISPLAY_ON]: False}
|
|
|
|
|
+ ):
|
|
|
|
|
+ await self.subject.async_turn_off()
|
|
|
|
|
|
|
|
async def test_toggle_takes_no_action_when_fan_off(self):
|
|
async def test_toggle_takes_no_action_when_fan_off(self):
|
|
|
self.dps[PROPERTY_TO_DPS_ID[ATTR_HVAC_MODE]] = False
|
|
self.dps[PROPERTY_TO_DPS_ID[ATTR_HVAC_MODE]] = False
|
|
@@ -78,30 +69,22 @@ class TestLight(IsolatedAsyncioTestCase):
|
|
|
self.subject._device.async_set_property.assert_not_called
|
|
self.subject._device.async_set_property.assert_not_called
|
|
|
|
|
|
|
|
async def test_toggle_turns_the_light_on_when_it_was_off(self):
|
|
async def test_toggle_turns_the_light_on_when_it_was_off(self):
|
|
|
- result = AsyncMock()
|
|
|
|
|
- self.subject._device.async_set_property.return_value = result()
|
|
|
|
|
self.dps[PROPERTY_TO_DPS_ID[ATTR_HVAC_MODE]] = True
|
|
self.dps[PROPERTY_TO_DPS_ID[ATTR_HVAC_MODE]] = True
|
|
|
self.dps[PROPERTY_TO_DPS_ID[ATTR_DISPLAY_ON]] = False
|
|
self.dps[PROPERTY_TO_DPS_ID[ATTR_DISPLAY_ON]] = False
|
|
|
|
|
|
|
|
- await self.subject.async_toggle()
|
|
|
|
|
-
|
|
|
|
|
- self.subject._device.async_set_property.assert_called_once_with(
|
|
|
|
|
- PROPERTY_TO_DPS_ID[ATTR_DISPLAY_ON], True
|
|
|
|
|
- )
|
|
|
|
|
- result.assert_awaited()
|
|
|
|
|
|
|
+ async with assert_device_properties_set(
|
|
|
|
|
+ self.subject._device, {PROPERTY_TO_DPS_ID[ATTR_DISPLAY_ON]: True}
|
|
|
|
|
+ ):
|
|
|
|
|
+ await self.subject.async_toggle()
|
|
|
|
|
|
|
|
async def test_toggle_turns_the_light_off_when_it_was_on(self):
|
|
async def test_toggle_turns_the_light_off_when_it_was_on(self):
|
|
|
- result = AsyncMock()
|
|
|
|
|
- self.subject._device.async_set_property.return_value = result()
|
|
|
|
|
self.dps[PROPERTY_TO_DPS_ID[ATTR_HVAC_MODE]] = True
|
|
self.dps[PROPERTY_TO_DPS_ID[ATTR_HVAC_MODE]] = True
|
|
|
self.dps[PROPERTY_TO_DPS_ID[ATTR_DISPLAY_ON]] = True
|
|
self.dps[PROPERTY_TO_DPS_ID[ATTR_DISPLAY_ON]] = True
|
|
|
|
|
|
|
|
- await self.subject.async_toggle()
|
|
|
|
|
-
|
|
|
|
|
- self.subject._device.async_set_property.assert_called_once_with(
|
|
|
|
|
- PROPERTY_TO_DPS_ID[ATTR_DISPLAY_ON], False
|
|
|
|
|
- )
|
|
|
|
|
- result.assert_awaited()
|
|
|
|
|
|
|
+ async with assert_device_properties_set(
|
|
|
|
|
+ self.subject._device, {PROPERTY_TO_DPS_ID[ATTR_DISPLAY_ON]: False}
|
|
|
|
|
+ ):
|
|
|
|
|
+ await self.subject.async_toggle()
|
|
|
|
|
|
|
|
async def test_update(self):
|
|
async def test_update(self):
|
|
|
result = AsyncMock()
|
|
result = AsyncMock()
|