mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Add transitiontime to hue scene service (#45785)
This commit is contained in:
@@ -192,6 +192,41 @@ async def test_hue_activate_scene(hass, mock_api):
|
||||
assert mock_api.mock_requests[2]["path"] == "groups/group_1/action"
|
||||
|
||||
|
||||
async def test_hue_activate_scene_transition(hass, mock_api):
|
||||
"""Test successful hue_activate_scene with transition."""
|
||||
config_entry = config_entries.ConfigEntry(
|
||||
1,
|
||||
hue.DOMAIN,
|
||||
"Mock Title",
|
||||
{"host": "mock-host", "username": "mock-username"},
|
||||
"test",
|
||||
config_entries.CONN_CLASS_LOCAL_POLL,
|
||||
system_options={},
|
||||
options={CONF_ALLOW_HUE_GROUPS: True, CONF_ALLOW_UNREACHABLE: False},
|
||||
)
|
||||
hue_bridge = bridge.HueBridge(hass, config_entry)
|
||||
|
||||
mock_api.mock_group_responses.append(GROUP_RESPONSE)
|
||||
mock_api.mock_scene_responses.append(SCENE_RESPONSE)
|
||||
|
||||
with patch("aiohue.Bridge", return_value=mock_api), patch.object(
|
||||
hass.config_entries, "async_forward_entry_setup"
|
||||
):
|
||||
assert await hue_bridge.async_setup() is True
|
||||
|
||||
assert hue_bridge.api is mock_api
|
||||
|
||||
call = Mock()
|
||||
call.data = {"group_name": "Group 1", "scene_name": "Cozy dinner", "transition": 30}
|
||||
with patch("aiohue.Bridge", return_value=mock_api):
|
||||
assert await hue_bridge.hue_activate_scene(call) is None
|
||||
|
||||
assert len(mock_api.mock_requests) == 3
|
||||
assert mock_api.mock_requests[2]["json"]["scene"] == "scene_1"
|
||||
assert mock_api.mock_requests[2]["json"]["transitiontime"] == 30
|
||||
assert mock_api.mock_requests[2]["path"] == "groups/group_1/action"
|
||||
|
||||
|
||||
async def test_hue_activate_scene_group_not_found(hass, mock_api):
|
||||
"""Test failed hue_activate_scene due to missing group."""
|
||||
config_entry = config_entries.ConfigEntry(
|
||||
|
||||
Reference in New Issue
Block a user