Update light device actions to check supported_color_modes (#50611)
This commit is contained in:
parent
646af533f0
commit
960ed13f94
3 changed files with 61 additions and 15 deletions
|
@ -3,10 +3,11 @@ import pytest
|
|||
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.light import (
|
||||
ATTR_SUPPORTED_COLOR_MODES,
|
||||
COLOR_MODE_BRIGHTNESS,
|
||||
DOMAIN,
|
||||
FLASH_LONG,
|
||||
FLASH_SHORT,
|
||||
SUPPORT_BRIGHTNESS,
|
||||
SUPPORT_FLASH,
|
||||
)
|
||||
from homeassistant.const import CONF_PLATFORM, STATE_OFF, STATE_ON
|
||||
|
@ -55,7 +56,8 @@ async def test_get_actions(hass, device_reg, entity_reg):
|
|||
"test",
|
||||
"5678",
|
||||
device_id=device_entry.id,
|
||||
supported_features=SUPPORT_BRIGHTNESS | SUPPORT_FLASH,
|
||||
supported_features=SUPPORT_FLASH,
|
||||
capabilities={"supported_color_modes": ["brightness"]},
|
||||
)
|
||||
expected_actions = [
|
||||
{
|
||||
|
@ -132,13 +134,15 @@ async def test_get_action_capabilities(hass, device_reg, entity_reg):
|
|||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"set_state,num_actions,supported_features_reg,supported_features_state,expected_capabilities",
|
||||
"set_state,num_actions,supported_features_reg,supported_features_state,capabilities_reg,attributes_state,expected_capabilities",
|
||||
[
|
||||
(
|
||||
False,
|
||||
5,
|
||||
SUPPORT_BRIGHTNESS,
|
||||
0,
|
||||
0,
|
||||
{ATTR_SUPPORTED_COLOR_MODES: [COLOR_MODE_BRIGHTNESS]},
|
||||
{},
|
||||
{
|
||||
"turn_on": [
|
||||
{
|
||||
|
@ -155,7 +159,9 @@ async def test_get_action_capabilities(hass, device_reg, entity_reg):
|
|||
True,
|
||||
5,
|
||||
0,
|
||||
SUPPORT_BRIGHTNESS,
|
||||
0,
|
||||
None,
|
||||
{ATTR_SUPPORTED_COLOR_MODES: [COLOR_MODE_BRIGHTNESS]},
|
||||
{
|
||||
"turn_on": [
|
||||
{
|
||||
|
@ -173,6 +179,8 @@ async def test_get_action_capabilities(hass, device_reg, entity_reg):
|
|||
4,
|
||||
SUPPORT_FLASH,
|
||||
0,
|
||||
None,
|
||||
{},
|
||||
{
|
||||
"turn_on": [
|
||||
{
|
||||
|
@ -189,6 +197,8 @@ async def test_get_action_capabilities(hass, device_reg, entity_reg):
|
|||
4,
|
||||
0,
|
||||
SUPPORT_FLASH,
|
||||
None,
|
||||
{},
|
||||
{
|
||||
"turn_on": [
|
||||
{
|
||||
|
@ -210,6 +220,8 @@ async def test_get_action_capabilities_features(
|
|||
num_actions,
|
||||
supported_features_reg,
|
||||
supported_features_state,
|
||||
capabilities_reg,
|
||||
attributes_state,
|
||||
expected_capabilities,
|
||||
):
|
||||
"""Test we get the expected capabilities from a light action."""
|
||||
|
@ -225,10 +237,13 @@ async def test_get_action_capabilities_features(
|
|||
"5678",
|
||||
device_id=device_entry.id,
|
||||
supported_features=supported_features_reg,
|
||||
capabilities=capabilities_reg,
|
||||
).entity_id
|
||||
if set_state:
|
||||
hass.states.async_set(
|
||||
entity_id, None, {"supported_features": supported_features_state}
|
||||
entity_id,
|
||||
None,
|
||||
{"supported_features": supported_features_state, **attributes_state},
|
||||
)
|
||||
|
||||
actions = await async_get_device_automations(hass, "action", device_entry.id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue