Add check to validate gamut (#20518)
* color.util - Add check to validate gamut * fix indents * fix typo * Add check to validate gamut * Add tests for gamut checker * fix test * fix pylint issues * fix hue light gamut tests * add check to validate gamut * move None check * Move None check * Include prompt to update bridge/bulb on error * fix wrong commit * fix error message * Update light.py
This commit is contained in:
1 parent
63fd5f2d31
commit
d7bbdb033d
4 files changed
+58
-4
No files matched your search
@@ -701,7 +701,9 @@ def test_available():
|
||||
"""Test available property."""
|
||||
light = hue_light.HueLight(
|
||||
light=Mock(state={'reachable': False},
|
||||
raw=LIGHT_RAW),
|
||||
raw=LIGHT_RAW,
|
||||
colorgamuttype=LIGHT_GAMUT_TYPE,
|
||||
colorgamut=LIGHT_GAMUT),
|
||||
request_bridge_update=None,
|
||||
bridge=Mock(allow_unreachable=False),
|
||||
is_group=False,
|
||||
@@ -711,7 +713,9 @@ def test_available():
|
||||
|
||||
light = hue_light.HueLight(
|
||||
light=Mock(state={'reachable': False},
|
||||
raw=LIGHT_RAW),
|
||||
raw=LIGHT_RAW,
|
||||
colorgamuttype=LIGHT_GAMUT_TYPE,
|
||||
colorgamut=LIGHT_GAMUT),
|
||||
request_bridge_update=None,
|
||||
bridge=Mock(allow_unreachable=True),
|
||||
is_group=False,
|
||||
@@ -721,7 +725,9 @@ def test_available():
|
||||
|
||||
light = hue_light.HueLight(
|
||||
light=Mock(state={'reachable': False},
|
||||
raw=LIGHT_RAW),
|
||||
raw=LIGHT_RAW,
|
||||
colorgamuttype=LIGHT_GAMUT_TYPE,
|
||||
colorgamut=LIGHT_GAMUT),
|
||||
request_bridge_update=None,
|
||||
bridge=Mock(allow_unreachable=False),
|
||||
is_group=True,
|
||||
|
||||
@@ -8,6 +8,18 @@ import voluptuous as vol
|
||||
GAMUT = color_util.GamutType(color_util.XYPoint(0.704, 0.296),
|
||||
color_util.XYPoint(0.2151, 0.7106),
|
||||
color_util.XYPoint(0.138, 0.08))
|
||||
GAMUT_INVALID_1 = color_util.GamutType(color_util.XYPoint(0.704, 0.296),
|
||||
color_util.XYPoint(-0.201, 0.7106),
|
||||
color_util.XYPoint(0.138, 0.08))
|
||||
GAMUT_INVALID_2 = color_util.GamutType(color_util.XYPoint(0.704, 1.296),
|
||||
color_util.XYPoint(0.2151, 0.7106),
|
||||
color_util.XYPoint(0.138, 0.08))
|
||||
GAMUT_INVALID_3 = color_util.GamutType(color_util.XYPoint(0.0, 0.0),
|
||||
color_util.XYPoint(0.0, 0.0),
|
||||
color_util.XYPoint(0.0, 0.0))
|
||||
GAMUT_INVALID_4 = color_util.GamutType(color_util.XYPoint(0.1, 0.1),
|
||||
color_util.XYPoint(0.3, 0.3),
|
||||
color_util.XYPoint(0.7, 0.7))
|
||||
|
||||
|
||||
class TestColorUtil(unittest.TestCase):
|
||||
@@ -338,6 +350,14 @@ class TestColorUtil(unittest.TestCase):
|
||||
assert color_util.color_rgb_to_hex(51, 153, 255) == '3399ff'
|
||||
assert color_util.color_rgb_to_hex(255, 67.9204190, 0) == 'ff4400'
|
||||
|
||||
def test_gamut(self):
|
||||
"""Test gamut functions."""
|
||||
assert color_util.check_valid_gamut(GAMUT)
|
||||
assert not color_util.check_valid_gamut(GAMUT_INVALID_1)
|
||||
assert not color_util.check_valid_gamut(GAMUT_INVALID_2)
|
||||
assert not color_util.check_valid_gamut(GAMUT_INVALID_3)
|
||||
assert not color_util.check_valid_gamut(GAMUT_INVALID_4)
|
||||
|
||||
|
||||
class ColorTemperatureMiredToKelvinTests(unittest.TestCase):
|
||||
"""Test color_temperature_mired_to_kelvin."""
|
||||
|
||||
Reference in new issue
Block a user