Cleanup ColorMode in tests (#78807)
parent
41d2ac3943
commit
6b3c91bd6a
|
@ -8,9 +8,8 @@ from homeassistant.components.light import (
|
|||
ATTR_COLOR_TEMP,
|
||||
ATTR_RGB_COLOR,
|
||||
ATTR_SUPPORTED_COLOR_MODES,
|
||||
COLOR_MODE_COLOR_TEMP,
|
||||
COLOR_MODE_HS,
|
||||
DOMAIN as LIGHT_DOMAIN,
|
||||
ColorMode,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
|
@ -52,10 +51,10 @@ async def test_attributes(hass: HomeAssistant) -> None:
|
|||
assert state.attributes.get("device_type") == "RGB Dimmer"
|
||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Living Room Lamp"
|
||||
assert state.attributes.get(ATTR_SUPPORTED_FEATURES) == 0
|
||||
assert state.attributes.get(ATTR_COLOR_MODE) == COLOR_MODE_HS
|
||||
assert state.attributes.get(ATTR_COLOR_MODE) == ColorMode.HS
|
||||
assert state.attributes.get(ATTR_SUPPORTED_COLOR_MODES) == [
|
||||
COLOR_MODE_COLOR_TEMP,
|
||||
COLOR_MODE_HS,
|
||||
ColorMode.COLOR_TEMP,
|
||||
ColorMode.HS,
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -27,12 +27,8 @@ from homeassistant.components.light import (
|
|||
ATTR_RGBWW_COLOR,
|
||||
ATTR_SUPPORTED_COLOR_MODES,
|
||||
ATTR_WHITE,
|
||||
COLOR_MODE_COLOR_TEMP,
|
||||
COLOR_MODE_RGB,
|
||||
COLOR_MODE_RGBW,
|
||||
COLOR_MODE_RGBWW,
|
||||
COLOR_MODE_WHITE,
|
||||
DOMAIN,
|
||||
ColorMode,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
|
@ -583,24 +579,24 @@ async def test_light_restore(hass, hk_driver, events):
|
|||
"supported_color_modes, state_props, turn_on_props_with_brightness",
|
||||
[
|
||||
[
|
||||
[COLOR_MODE_COLOR_TEMP, COLOR_MODE_RGBW],
|
||||
[ColorMode.COLOR_TEMP, ColorMode.RGBW],
|
||||
{
|
||||
ATTR_RGBW_COLOR: (128, 50, 0, 255),
|
||||
ATTR_RGB_COLOR: (128, 50, 0),
|
||||
ATTR_HS_COLOR: (23.438, 100.0),
|
||||
ATTR_BRIGHTNESS: 255,
|
||||
ATTR_COLOR_MODE: COLOR_MODE_RGBW,
|
||||
ATTR_COLOR_MODE: ColorMode.RGBW,
|
||||
},
|
||||
{ATTR_HS_COLOR: (145, 75), ATTR_BRIGHTNESS_PCT: 25},
|
||||
],
|
||||
[
|
||||
[COLOR_MODE_COLOR_TEMP, COLOR_MODE_RGBWW],
|
||||
[ColorMode.COLOR_TEMP, ColorMode.RGBWW],
|
||||
{
|
||||
ATTR_RGBWW_COLOR: (128, 50, 0, 255, 255),
|
||||
ATTR_RGB_COLOR: (128, 50, 0),
|
||||
ATTR_HS_COLOR: (23.438, 100.0),
|
||||
ATTR_BRIGHTNESS: 255,
|
||||
ATTR_COLOR_MODE: COLOR_MODE_RGBWW,
|
||||
ATTR_COLOR_MODE: ColorMode.RGBWW,
|
||||
},
|
||||
{ATTR_HS_COLOR: (145, 75), ATTR_BRIGHTNESS_PCT: 25},
|
||||
],
|
||||
|
@ -703,24 +699,24 @@ async def test_light_rgb_with_color_temp(
|
|||
"supported_color_modes, state_props, turn_on_props_with_brightness",
|
||||
[
|
||||
[
|
||||
[COLOR_MODE_RGBW],
|
||||
[ColorMode.RGBW],
|
||||
{
|
||||
ATTR_RGBW_COLOR: (128, 50, 0, 255),
|
||||
ATTR_RGB_COLOR: (128, 50, 0),
|
||||
ATTR_HS_COLOR: (23.438, 100.0),
|
||||
ATTR_BRIGHTNESS: 255,
|
||||
ATTR_COLOR_MODE: COLOR_MODE_RGBW,
|
||||
ATTR_COLOR_MODE: ColorMode.RGBW,
|
||||
},
|
||||
{ATTR_RGBW_COLOR: (0, 0, 0, 191)},
|
||||
],
|
||||
[
|
||||
[COLOR_MODE_RGBWW],
|
||||
[ColorMode.RGBWW],
|
||||
{
|
||||
ATTR_RGBWW_COLOR: (128, 50, 0, 255, 255),
|
||||
ATTR_RGB_COLOR: (128, 50, 0),
|
||||
ATTR_HS_COLOR: (23.438, 100.0),
|
||||
ATTR_BRIGHTNESS: 255,
|
||||
ATTR_COLOR_MODE: COLOR_MODE_RGBWW,
|
||||
ATTR_COLOR_MODE: ColorMode.RGBWW,
|
||||
},
|
||||
{ATTR_RGBWW_COLOR: (0, 0, 0, 165, 26)},
|
||||
],
|
||||
|
@ -800,12 +796,12 @@ async def test_light_rgb_or_w_lights(
|
|||
entity_id,
|
||||
STATE_ON,
|
||||
{
|
||||
ATTR_SUPPORTED_COLOR_MODES: [COLOR_MODE_RGB, COLOR_MODE_WHITE],
|
||||
ATTR_SUPPORTED_COLOR_MODES: [ColorMode.RGB, ColorMode.WHITE],
|
||||
ATTR_RGBW_COLOR: (128, 50, 0, 255),
|
||||
ATTR_RGB_COLOR: (128, 50, 0),
|
||||
ATTR_HS_COLOR: (23.438, 100.0),
|
||||
ATTR_BRIGHTNESS: 255,
|
||||
ATTR_COLOR_MODE: COLOR_MODE_RGB,
|
||||
ATTR_COLOR_MODE: ColorMode.RGB,
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
@ -884,9 +880,9 @@ async def test_light_rgb_or_w_lights(
|
|||
entity_id,
|
||||
STATE_ON,
|
||||
{
|
||||
ATTR_SUPPORTED_COLOR_MODES: [COLOR_MODE_RGB, COLOR_MODE_WHITE],
|
||||
ATTR_SUPPORTED_COLOR_MODES: [ColorMode.RGB, ColorMode.WHITE],
|
||||
ATTR_BRIGHTNESS: 255,
|
||||
ATTR_COLOR_MODE: COLOR_MODE_WHITE,
|
||||
ATTR_COLOR_MODE: ColorMode.WHITE,
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
@ -900,23 +896,23 @@ async def test_light_rgb_or_w_lights(
|
|||
"supported_color_modes, state_props",
|
||||
[
|
||||
[
|
||||
[COLOR_MODE_COLOR_TEMP, COLOR_MODE_RGBW],
|
||||
[ColorMode.COLOR_TEMP, ColorMode.RGBW],
|
||||
{
|
||||
ATTR_RGBW_COLOR: (128, 50, 0, 255),
|
||||
ATTR_RGB_COLOR: (128, 50, 0),
|
||||
ATTR_HS_COLOR: (23.438, 100.0),
|
||||
ATTR_BRIGHTNESS: 255,
|
||||
ATTR_COLOR_MODE: COLOR_MODE_RGBW,
|
||||
ATTR_COLOR_MODE: ColorMode.RGBW,
|
||||
},
|
||||
],
|
||||
[
|
||||
[COLOR_MODE_COLOR_TEMP, COLOR_MODE_RGBWW],
|
||||
[ColorMode.COLOR_TEMP, ColorMode.RGBWW],
|
||||
{
|
||||
ATTR_RGBWW_COLOR: (128, 50, 0, 255, 255),
|
||||
ATTR_RGB_COLOR: (128, 50, 0),
|
||||
ATTR_HS_COLOR: (23.438, 100.0),
|
||||
ATTR_BRIGHTNESS: 255,
|
||||
ATTR_COLOR_MODE: COLOR_MODE_RGBWW,
|
||||
ATTR_COLOR_MODE: ColorMode.RGBWW,
|
||||
},
|
||||
],
|
||||
],
|
||||
|
@ -1013,12 +1009,12 @@ async def test_light_rgbww_with_color_temp_conversion(
|
|||
entity_id,
|
||||
STATE_ON,
|
||||
{
|
||||
ATTR_SUPPORTED_COLOR_MODES: [COLOR_MODE_RGBWW],
|
||||
ATTR_SUPPORTED_COLOR_MODES: [ColorMode.RGBWW],
|
||||
ATTR_RGBWW_COLOR: (128, 50, 0, 255, 255),
|
||||
ATTR_RGB_COLOR: (128, 50, 0),
|
||||
ATTR_HS_COLOR: (23.438, 100.0),
|
||||
ATTR_BRIGHTNESS: 255,
|
||||
ATTR_COLOR_MODE: COLOR_MODE_RGBWW,
|
||||
ATTR_COLOR_MODE: ColorMode.RGBWW,
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
@ -1091,12 +1087,12 @@ async def test_light_rgbww_with_color_temp_conversion(
|
|||
entity_id,
|
||||
STATE_ON,
|
||||
{
|
||||
ATTR_SUPPORTED_COLOR_MODES: [COLOR_MODE_RGBWW],
|
||||
ATTR_SUPPORTED_COLOR_MODES: [ColorMode.RGBWW],
|
||||
ATTR_RGBWW_COLOR: (0, 0, 0, 128, 255),
|
||||
ATTR_RGB_COLOR: (255, 163, 79),
|
||||
ATTR_HS_COLOR: (28.636, 69.02),
|
||||
ATTR_BRIGHTNESS: 180,
|
||||
ATTR_COLOR_MODE: COLOR_MODE_RGBWW,
|
||||
ATTR_COLOR_MODE: ColorMode.RGBWW,
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
@ -1134,12 +1130,12 @@ async def test_light_rgbw_with_color_temp_conversion(
|
|||
entity_id,
|
||||
STATE_ON,
|
||||
{
|
||||
ATTR_SUPPORTED_COLOR_MODES: [COLOR_MODE_RGBW],
|
||||
ATTR_SUPPORTED_COLOR_MODES: [ColorMode.RGBW],
|
||||
ATTR_RGBWW_COLOR: (128, 50, 0, 255, 255),
|
||||
ATTR_RGB_COLOR: (128, 50, 0),
|
||||
ATTR_HS_COLOR: (23.438, 100.0),
|
||||
ATTR_BRIGHTNESS: 255,
|
||||
ATTR_COLOR_MODE: COLOR_MODE_RGBW,
|
||||
ATTR_COLOR_MODE: ColorMode.RGBW,
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
|
|
@ -7,7 +7,7 @@ import aiohue
|
|||
from homeassistant.components import hue
|
||||
from homeassistant.components.hue.const import CONF_ALLOW_HUE_GROUPS
|
||||
from homeassistant.components.hue.v1 import light as hue_light
|
||||
from homeassistant.components.light import COLOR_MODE_COLOR_TEMP, COLOR_MODE_HS
|
||||
from homeassistant.components.light import ColorMode
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
from homeassistant.util import color
|
||||
|
||||
|
@ -237,10 +237,10 @@ async def test_lights_color_mode(hass, mock_bridge_v1):
|
|||
assert lamp_1.attributes["brightness"] == 145
|
||||
assert lamp_1.attributes["hs_color"] == (36.067, 69.804)
|
||||
assert "color_temp" not in lamp_1.attributes
|
||||
assert lamp_1.attributes["color_mode"] == COLOR_MODE_HS
|
||||
assert lamp_1.attributes["color_mode"] == ColorMode.HS
|
||||
assert lamp_1.attributes["supported_color_modes"] == [
|
||||
COLOR_MODE_COLOR_TEMP,
|
||||
COLOR_MODE_HS,
|
||||
ColorMode.COLOR_TEMP,
|
||||
ColorMode.HS,
|
||||
]
|
||||
|
||||
new_light1_on = LIGHT_1_ON.copy()
|
||||
|
@ -262,10 +262,10 @@ async def test_lights_color_mode(hass, mock_bridge_v1):
|
|||
assert lamp_1.attributes["brightness"] == 145
|
||||
assert lamp_1.attributes["color_temp"] == 467
|
||||
assert "hs_color" in lamp_1.attributes
|
||||
assert lamp_1.attributes["color_mode"] == COLOR_MODE_COLOR_TEMP
|
||||
assert lamp_1.attributes["color_mode"] == ColorMode.COLOR_TEMP
|
||||
assert lamp_1.attributes["supported_color_modes"] == [
|
||||
COLOR_MODE_COLOR_TEMP,
|
||||
COLOR_MODE_HS,
|
||||
ColorMode.COLOR_TEMP,
|
||||
ColorMode.HS,
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"""Philips Hue lights platform tests for V2 bridge/api."""
|
||||
|
||||
from homeassistant.components.light import COLOR_MODE_COLOR_TEMP, COLOR_MODE_XY
|
||||
from homeassistant.components.light import ColorMode
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from .conftest import setup_platform
|
||||
|
@ -27,10 +27,10 @@ async def test_lights(hass, mock_bridge_v2, v2_resources_test_data):
|
|||
assert light_1.state == "on"
|
||||
assert light_1.attributes["brightness"] == int(46.85 / 100 * 255)
|
||||
assert light_1.attributes["mode"] == "normal"
|
||||
assert light_1.attributes["color_mode"] == COLOR_MODE_XY
|
||||
assert light_1.attributes["color_mode"] == ColorMode.XY
|
||||
assert set(light_1.attributes["supported_color_modes"]) == {
|
||||
COLOR_MODE_COLOR_TEMP,
|
||||
COLOR_MODE_XY,
|
||||
ColorMode.COLOR_TEMP,
|
||||
ColorMode.XY,
|
||||
}
|
||||
assert light_1.attributes["xy_color"] == (0.5614, 0.4058)
|
||||
assert light_1.attributes["min_mireds"] == 153
|
||||
|
@ -47,7 +47,7 @@ async def test_lights(hass, mock_bridge_v2, v2_resources_test_data):
|
|||
)
|
||||
assert light_2.state == "off"
|
||||
assert light_2.attributes["mode"] == "normal"
|
||||
assert light_2.attributes["supported_color_modes"] == [COLOR_MODE_COLOR_TEMP]
|
||||
assert light_2.attributes["supported_color_modes"] == [ColorMode.COLOR_TEMP]
|
||||
assert light_2.attributes["min_mireds"] == 153
|
||||
assert light_2.attributes["max_mireds"] == 454
|
||||
assert light_2.attributes["dynamics"] == "none"
|
||||
|
@ -60,8 +60,8 @@ async def test_lights(hass, mock_bridge_v2, v2_resources_test_data):
|
|||
assert light_3.state == "on"
|
||||
assert light_3.attributes["brightness"] == 128
|
||||
assert light_3.attributes["mode"] == "normal"
|
||||
assert light_3.attributes["supported_color_modes"] == [COLOR_MODE_XY]
|
||||
assert light_3.attributes["color_mode"] == COLOR_MODE_XY
|
||||
assert light_3.attributes["supported_color_modes"] == [ColorMode.XY]
|
||||
assert light_3.attributes["color_mode"] == ColorMode.XY
|
||||
assert light_3.attributes["dynamics"] == "dynamic_palette"
|
||||
|
||||
# test light which supports on/off only
|
||||
|
@ -113,8 +113,8 @@ async def test_light_turn_on_service(hass, mock_bridge_v2, v2_resources_test_dat
|
|||
assert test_light is not None
|
||||
assert test_light.state == "on"
|
||||
assert test_light.attributes["mode"] == "normal"
|
||||
assert test_light.attributes["supported_color_modes"] == [COLOR_MODE_COLOR_TEMP]
|
||||
assert test_light.attributes["color_mode"] == COLOR_MODE_COLOR_TEMP
|
||||
assert test_light.attributes["supported_color_modes"] == [ColorMode.COLOR_TEMP]
|
||||
assert test_light.attributes["color_mode"] == ColorMode.COLOR_TEMP
|
||||
assert test_light.attributes["brightness"] == 255
|
||||
|
||||
# test again with sending transition with 250ms which should round up to 200ms
|
||||
|
@ -344,10 +344,10 @@ async def test_grouped_lights(hass, mock_bridge_v2, v2_resources_test_data):
|
|||
assert test_entity.attributes["friendly_name"] == "Test Zone"
|
||||
assert test_entity.state == "on"
|
||||
assert test_entity.attributes["brightness"] == 119
|
||||
assert test_entity.attributes["color_mode"] == COLOR_MODE_XY
|
||||
assert test_entity.attributes["color_mode"] == ColorMode.XY
|
||||
assert set(test_entity.attributes["supported_color_modes"]) == {
|
||||
COLOR_MODE_COLOR_TEMP,
|
||||
COLOR_MODE_XY,
|
||||
ColorMode.COLOR_TEMP,
|
||||
ColorMode.XY,
|
||||
}
|
||||
assert test_entity.attributes["min_mireds"] == 153
|
||||
assert test_entity.attributes["max_mireds"] == 500
|
||||
|
@ -365,7 +365,7 @@ async def test_grouped_lights(hass, mock_bridge_v2, v2_resources_test_data):
|
|||
assert test_entity is not None
|
||||
assert test_entity.attributes["friendly_name"] == "Test Room"
|
||||
assert test_entity.state == "off"
|
||||
assert test_entity.attributes["supported_color_modes"] == [COLOR_MODE_COLOR_TEMP]
|
||||
assert test_entity.attributes["supported_color_modes"] == [ColorMode.COLOR_TEMP]
|
||||
assert test_entity.attributes["min_mireds"] == 153
|
||||
assert test_entity.attributes["max_mireds"] == 454
|
||||
assert test_entity.attributes["is_hue_group"] is True
|
||||
|
@ -417,7 +417,7 @@ async def test_grouped_lights(hass, mock_bridge_v2, v2_resources_test_data):
|
|||
test_light = hass.states.get(test_light_id)
|
||||
assert test_light is not None
|
||||
assert test_light.state == "on"
|
||||
assert test_light.attributes["color_mode"] == COLOR_MODE_XY
|
||||
assert test_light.attributes["color_mode"] == ColorMode.XY
|
||||
assert test_light.attributes["brightness"] == 255
|
||||
assert test_light.attributes["xy_color"] == (0.123, 0.123)
|
||||
|
||||
|
|
Loading…
Reference in New Issue