def test_available(): """Test available property.""" light = hue_light.HueLight( light=Mock(state={'reachable': False}), 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}), 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}), request_bridge_update=None, bridge=Mock(allow_unreachable=False), is_group=True, ) assert light.available is True
def test_hs_color(): """Test hs_color property.""" light = hue_light.HueLight( light=Mock(state={ 'colormode': 'ct', 'hue': 1234, 'sat': 123, }), 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] }), request_bridge_update=None, bridge=Mock(), is_group=False, ) assert light.hs_color == color.color_xy_to_hs(0.4, 0.5)
def test_available(): """Test available property.""" light = hue_light.HueLight( info={'state': {'reachable': False}}, allow_unreachable=False, is_group=False, light_id=None, bridge=mock.Mock(), update_lights_cb=None, allow_in_emulated_hue=False, ) assert light.available is False light = hue_light.HueLight( info={'state': {'reachable': False}}, allow_unreachable=True, is_group=False, light_id=None, bridge=mock.Mock(), update_lights_cb=None, allow_in_emulated_hue=False, ) assert light.available is True light = hue_light.HueLight( info={'state': {'reachable': False}}, allow_unreachable=False, is_group=True, light_id=None, bridge=mock.Mock(), update_lights_cb=None, allow_in_emulated_hue=False, ) assert light.available is True
def buildLight( self, light_id=None, info=None, update_lights=None, is_group=None): """Helper to build a HueLight object with minimal fuss.""" return hue_light.HueLight( light_id if light_id is not None else self.light_id, info if info is not None else self.mock_info, self.mock_bridge, (update_lights if update_lights is not None else self.mock_update_lights), self.mock_bridge_type, self.mock_allow_unreachable, self.mock_allow_in_emulated_hue, is_group if is_group is not None else self.mock_is_group)
def buildLight( self, light_id=None, info=None, update_lights=None, is_group=None): """Helper to build a HueLight object with minimal fuss.""" if 'state' not in info: on_key = 'any_on' if is_group is not None else 'on' info['state'] = {on_key: False} return hue_light.HueLight( light_id if light_id is not None else self.light_id, info if info is not None else self.mock_info, self.mock_bridge, (update_lights if update_lights is not None else self.mock_update_lights), self.mock_allow_unreachable, self.mock_allow_in_emulated_hue, is_group if is_group is not None else self.mock_is_group)