示例#1
0
def test_available():
    """Test available property."""
    light = hue_light.HueLight(
        light=Mock(state={'reachable': False}, raw=LIGHT_RAW),
        request_bridge_update=None,
        bridge=Mock(allow_unreachable=False),
        is_group=False,
    )

    assert light.available is False

    light = hue_light.HueLight(
        light=Mock(state={'reachable': False}, raw=LIGHT_RAW),
        request_bridge_update=None,
        bridge=Mock(allow_unreachable=True),
        is_group=False,
    )

    assert light.available is True

    light = hue_light.HueLight(
        light=Mock(state={'reachable': False}, raw=LIGHT_RAW),
        request_bridge_update=None,
        bridge=Mock(allow_unreachable=False),
        is_group=True,
    )

    assert light.available is True
示例#2
0
def test_hs_color():
    """Test hs_color property."""
    light = hue_light.HueLight(
        light=Mock(
            state={
                "colormode": "ct",
                "hue": 1234,
                "sat": 123
            },
            raw=LIGHT_RAW,
            colorgamuttype=LIGHT_GAMUT_TYPE,
            colorgamut=LIGHT_GAMUT,
        ),
        coordinator=Mock(last_update_success=True),
        bridge=Mock(),
        is_group=False,
        supported_features=hue_light.SUPPORT_HUE_EXTENDED,
    )

    assert light.hs_color is None

    light = hue_light.HueLight(
        light=Mock(
            state={
                "colormode": "hs",
                "hue": 1234,
                "sat": 123
            },
            raw=LIGHT_RAW,
            colorgamuttype=LIGHT_GAMUT_TYPE,
            colorgamut=LIGHT_GAMUT,
        ),
        coordinator=Mock(last_update_success=True),
        bridge=Mock(),
        is_group=False,
        supported_features=hue_light.SUPPORT_HUE_EXTENDED,
    )

    assert light.hs_color is None

    light = hue_light.HueLight(
        light=Mock(
            state={
                "colormode": "xy",
                "hue": 1234,
                "sat": 123,
                "xy": [0.4, 0.5]
            },
            raw=LIGHT_RAW,
            colorgamuttype=LIGHT_GAMUT_TYPE,
            colorgamut=LIGHT_GAMUT,
        ),
        coordinator=Mock(last_update_success=True),
        bridge=Mock(),
        is_group=False,
        supported_features=hue_light.SUPPORT_HUE_EXTENDED,
    )

    assert light.hs_color == color.color_xy_to_hs(0.4, 0.5, LIGHT_GAMUT)
示例#3
0
def test_hs_color():
    """Test hs_color property."""
    light = hue_light.HueLight(
        light=Mock(
            state={
                "colormode": "ct",
                "hue": 1234,
                "sat": 123
            },
            raw=LIGHT_RAW,
            colorgamuttype=LIGHT_GAMUT_TYPE,
            colorgamut=LIGHT_GAMUT,
        ),
        request_bridge_update=None,
        bridge=Mock(),
        is_group=False,
    )

    assert light.hs_color is None

    light = hue_light.HueLight(
        light=Mock(
            state={
                "colormode": "hs",
                "hue": 1234,
                "sat": 123
            },
            raw=LIGHT_RAW,
            colorgamuttype=LIGHT_GAMUT_TYPE,
            colorgamut=LIGHT_GAMUT,
        ),
        request_bridge_update=None,
        bridge=Mock(),
        is_group=False,
    )

    assert light.hs_color is None

    light = hue_light.HueLight(
        light=Mock(
            state={
                "colormode": "xy",
                "hue": 1234,
                "sat": 123,
                "xy": [0.4, 0.5]
            },
            raw=LIGHT_RAW,
            colorgamuttype=LIGHT_GAMUT_TYPE,
            colorgamut=LIGHT_GAMUT,
        ),
        request_bridge_update=None,
        bridge=Mock(),
        is_group=False,
    )

    assert light.hs_color == color.color_xy_to_hs(0.4, 0.5, LIGHT_GAMUT)
示例#4
0
def test_hs_color():
    """Test hs_color property."""
    light = hue_light.HueLight(
        light=Mock(state={
            'colormode': 'ct',
            'hue': 1234,
            'sat': 123,
        },
                   raw=LIGHT_RAW,
                   colorgamuttype=LIGHT_GAMUT_TYPE,
                   colorgamut=LIGHT_GAMUT),
        request_bridge_update=None,
        bridge=Mock(),
        is_group=False,
    )

    assert light.hs_color is None

    light = hue_light.HueLight(
        light=Mock(state={
            'colormode': 'hs',
            'hue': 1234,
            'sat': 123,
        },
                   raw=LIGHT_RAW,
                   colorgamuttype=LIGHT_GAMUT_TYPE,
                   colorgamut=LIGHT_GAMUT),
        request_bridge_update=None,
        bridge=Mock(),
        is_group=False,
    )

    assert light.hs_color is None

    light = hue_light.HueLight(
        light=Mock(state={
            'colormode': 'xy',
            'hue': 1234,
            'sat': 123,
            'xy': [0.4, 0.5]
        },
                   raw=LIGHT_RAW,
                   colorgamuttype=LIGHT_GAMUT_TYPE,
                   colorgamut=LIGHT_GAMUT),
        request_bridge_update=None,
        bridge=Mock(),
        is_group=False,
    )

    assert light.hs_color == color.color_xy_to_hs(0.4, 0.5, LIGHT_GAMUT)
示例#5
0
def test_available():
    """Test available property."""
    light = hue_light.HueLight(
        light=Mock(
            state={"reachable": False},
            raw=LIGHT_RAW,
            colorgamuttype=LIGHT_GAMUT_TYPE,
            colorgamut=LIGHT_GAMUT,
        ),
        coordinator=Mock(last_update_success=True),
        bridge=Mock(allow_unreachable=False),
        is_group=False,
        supported_features=hue_light.SUPPORT_HUE_EXTENDED,
        rooms={},
    )

    assert light.available is False

    light = hue_light.HueLight(
        light=Mock(
            state={"reachable": False},
            raw=LIGHT_RAW,
            colorgamuttype=LIGHT_GAMUT_TYPE,
            colorgamut=LIGHT_GAMUT,
        ),
        coordinator=Mock(last_update_success=True),
        bridge=Mock(allow_unreachable=True),
        is_group=False,
        supported_features=hue_light.SUPPORT_HUE_EXTENDED,
        rooms={},
    )

    assert light.available is True

    light = hue_light.HueLight(
        light=Mock(
            state={"reachable": False},
            raw=LIGHT_RAW,
            colorgamuttype=LIGHT_GAMUT_TYPE,
            colorgamut=LIGHT_GAMUT,
        ),
        coordinator=Mock(last_update_success=True),
        bridge=Mock(allow_unreachable=False),
        is_group=True,
        supported_features=hue_light.SUPPORT_HUE_EXTENDED,
        rooms={},
    )

    assert light.available is True
示例#6
0
def test_available():
    """Test available property."""
    light = hue_light.HueLight(
        light=Mock(
            state={"reachable": False},
            raw=LIGHT_RAW,
            colorgamuttype=LIGHT_GAMUT_TYPE,
            colorgamut=LIGHT_GAMUT,
        ),
        request_bridge_update=None,
        bridge=Mock(allow_unreachable=False),
        is_group=False,
    )

    assert light.available is False

    light = hue_light.HueLight(
        light=Mock(
            state={"reachable": False},
            raw=LIGHT_RAW,
            colorgamuttype=LIGHT_GAMUT_TYPE,
            colorgamut=LIGHT_GAMUT,
        ),
        request_bridge_update=None,
        bridge=Mock(allow_unreachable=True),
        is_group=False,
    )

    assert light.available is True

    light = hue_light.HueLight(
        light=Mock(
            state={"reachable": False},
            raw=LIGHT_RAW,
            colorgamuttype=LIGHT_GAMUT_TYPE,
            colorgamut=LIGHT_GAMUT,
        ),
        request_bridge_update=None,
        bridge=Mock(allow_unreachable=False),
        is_group=True,
    )

    assert light.available is True