def mock_light(test_features=None, test_state=None, light_number=0): """Mock a tradfri light.""" if test_features is None: test_features = {} if test_state is None: test_state = {} mock_light_data = Mock(**test_state) dev_info_mock = MagicMock() dev_info_mock.manufacturer = "manufacturer" dev_info_mock.model_number = "model" dev_info_mock.firmware_version = "1.2.3" _mock_light = Mock( id=f"mock-light-id-{light_number}", reachable=True, observe=Mock(), device_info=dev_info_mock, has_light_control=True, has_socket_control=False, has_blind_control=False, has_signal_repeater_control=False, has_air_purifier_control=False, ) _mock_light.name = f"tradfri_light_{light_number}" # Set supported features for the light. features = {**DEFAULT_TEST_FEATURES, **test_features} light_control = LightControl(_mock_light) for attr, value in features.items(): setattr(light_control, attr, value) # Store the initial state. setattr(light_control, "lights", [mock_light_data]) _mock_light.light_control = light_control return _mock_light
def mock_light(test_features={}, test_state={}, n=0): """Mock a tradfri light.""" mock_light_data = Mock(**test_state) dev_info_mock = MagicMock() dev_info_mock.manufacturer = "manufacturer" dev_info_mock.model_number = "model" dev_info_mock.firmware_version = "1.2.3" mock_light = Mock( id=f"mock-light-id-{n}", reachable=True, observe=Mock(), device_info=dev_info_mock, ) mock_light.name = f"tradfri_light_{n}" # Set supported features for the light. features = {**DEFAULT_TEST_FEATURES, **test_features} lc = LightControl(mock_light) for k, v in features.items(): setattr(lc, k, v) # Store the initial state. setattr(lc, "lights", [mock_light_data]) mock_light.light_control = lc return mock_light
def mock_light(test_features={}, test_state={}, n=0): """Mock a tradfri light.""" mock_light_data = Mock(**test_state) mock_light = Mock( id="mock-light-id-{}".format(n), reachable=True, observe=Mock(), device_info=MagicMock(), ) mock_light.name = "tradfri_light_{}".format(n) # Set supported features for the light. features = {**DEFAULT_TEST_FEATURES, **test_features} lc = LightControl(mock_light) for k, v in features.items(): setattr(lc, k, v) # Store the initial state. setattr(lc, "lights", [mock_light_data]) mock_light.light_control = lc return mock_light
def light_control(self): return LightControl(self)