mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Fix Shelly white light test (#109855)
This commit is contained in:
parent
2e194c4ec3
commit
aea81a180c
@ -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_BLOCKS = [
|
||||||
Mock(
|
Mock(
|
||||||
sensor_ids={
|
sensor_ids={
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
"""Tests for Shelly light platform."""
|
"""Tests for Shelly light platform."""
|
||||||
|
from unittest.mock import AsyncMock
|
||||||
|
|
||||||
from aioshelly.const import (
|
from aioshelly.const import (
|
||||||
MODEL_BULB,
|
MODEL_BULB,
|
||||||
MODEL_BULB_RGBW,
|
MODEL_BULB_RGBW,
|
||||||
@ -35,6 +37,7 @@ from homeassistant.const import (
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from . import init_integration, mutate_rpc_device_status
|
from . import init_integration, mutate_rpc_device_status
|
||||||
|
from .conftest import mock_white_light_set_state
|
||||||
|
|
||||||
RELAY_BLOCK_ID = 0
|
RELAY_BLOCK_ID = 0
|
||||||
LIGHT_BLOCK_ID = 2
|
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], "mode")
|
||||||
monkeypatch.delattr(mock_block_device.blocks[LIGHT_BLOCK_ID], "colorTemp")
|
monkeypatch.delattr(mock_block_device.blocks[LIGHT_BLOCK_ID], "colorTemp")
|
||||||
monkeypatch.delattr(mock_block_device.blocks[LIGHT_BLOCK_ID], "effect")
|
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)
|
await init_integration(hass, 1, model=MODEL_VINTAGE_V2)
|
||||||
|
|
||||||
# Test initial
|
# Test initial
|
||||||
|
Loading…
x
Reference in New Issue
Block a user