diff --git a/tests/components/shelly/conftest.py b/tests/components/shelly/conftest.py index 9d7bb9404f8..0ad32409945 100644 --- a/tests/components/shelly/conftest.py +++ b/tests/components/shelly/conftest.py @@ -65,6 +65,24 @@ def mock_light_set_state( } +def mock_white_light_set_state( + turn="on", + temp=4050, + gain=19, + brightness=128, + transition=0, +): + """Mock white light block set_state.""" + return { + "ison": turn == "on", + "mode": "white", + "gain": gain, + "temp": temp, + "brightness": brightness, + "transition": transition, + } + + MOCK_BLOCKS = [ Mock( sensor_ids={ diff --git a/tests/components/shelly/test_light.py b/tests/components/shelly/test_light.py index 77b65ad3bb5..c27a1199d4b 100644 --- a/tests/components/shelly/test_light.py +++ b/tests/components/shelly/test_light.py @@ -1,4 +1,6 @@ """Tests for Shelly light platform.""" +from unittest.mock import AsyncMock + from aioshelly.const import ( MODEL_BULB, MODEL_BULB_RGBW, @@ -35,6 +37,7 @@ from homeassistant.const import ( from homeassistant.core import HomeAssistant from . import init_integration, mutate_rpc_device_status +from .conftest import mock_white_light_set_state RELAY_BLOCK_ID = 0 LIGHT_BLOCK_ID = 2 @@ -227,6 +230,11 @@ async def test_block_device_white_bulb( monkeypatch.delattr(mock_block_device.blocks[LIGHT_BLOCK_ID], "mode") monkeypatch.delattr(mock_block_device.blocks[LIGHT_BLOCK_ID], "colorTemp") monkeypatch.delattr(mock_block_device.blocks[LIGHT_BLOCK_ID], "effect") + monkeypatch.setattr( + mock_block_device.blocks[LIGHT_BLOCK_ID], + "set_state", + AsyncMock(side_effect=mock_white_light_set_state), + ) await init_integration(hass, 1, model=MODEL_VINTAGE_V2) # Test initial