Skip to content

Commit

Permalink
Fix Shelly white light test (#109855)
Browse files Browse the repository at this point in the history
  • Loading branch information
emontnemery authored Feb 7, 2024
1 parent 2e194c4 commit aea81a1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/components/shelly/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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={
Expand Down
8 changes: 8 additions & 0 deletions tests/components/shelly/test_light.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Tests for Shelly light platform."""
from unittest.mock import AsyncMock

from aioshelly.const import (
MODEL_BULB,
MODEL_BULB_RGBW,
Expand Down Expand Up @@ -35,6 +37,7 @@
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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit aea81a1

Please sign in to comment.