async def test_change_light_state( sut: LightController, mocker: MockerFixture, old: int, attribute: str, direction: Literal["up", "down"], stepper: MinMaxStepper, smooth_power_on_check: bool, stop_expected: bool, expected_value_attribute: int, ): called_service_patch = mocker.patch.object(sut, "call_service") sut.value_attribute = old sut.smooth_power_on_check = smooth_power_on_check sut.remove_transition_check = False sut.manual_steppers = {attribute: stepper} sut.automatic_steppers = {attribute: stepper} sut.feature_support._supported_features = 0 stop = await sut.change_light_state(old, attribute, direction, stepper, "hold") assert stop == stop_expected assert sut.value_attribute == expected_value_attribute called_service_patch.assert_called()
async def test_click( sut: LightController, monkeypatch: MonkeyPatch, mocker: MockerFixture, attribute_input: str, direction_input: Literal["up", "down"], light_state: Literal["on", "off"], smooth_power_on: bool, expected_calls: int, ): value_attribute = 10 monkeypatch.setattr(sut, "get_entity_state", fake_fn(to_return=light_state, async_=True)) monkeypatch.setattr(sut, "get_value_attribute", fake_fn(to_return=value_attribute, async_=True)) monkeypatch.setattr(sut, "get_attribute", fake_fn(to_return=attribute_input, async_=True)) change_light_state_patch = mocker.patch.object(sut, "change_light_state") sut.smooth_power_on = smooth_power_on sut.feature_support._supported_features = 0 stepper = MinMaxStepper(1, 10, 10) sut.manual_steppers = {attribute_input: stepper} await sut.click(attribute_input, direction_input) assert change_light_state_patch.call_count == expected_calls
async def test_change_light_state( sut: LightController, mocker: MockerFixture, monkeypatch: MonkeyPatch, old: int, attribute: str, direction: Literal["up", "down"], stepper: MinMaxStepper, light_state: str, smooth_power_on: bool, stop_expected: bool, expected_value_attribute: int, ): called_service_patch = mocker.patch.object(sut, "call_service") sut.smooth_power_on = smooth_power_on sut.value_attribute = old sut.manual_steppers = {attribute: stepper} sut.automatic_steppers = {attribute: stepper} sut.feature_support._supported_features = 0 monkeypatch.setattr( sut, "get_entity_state", fake_fn(to_return=light_state, async_=True) ) stop = await sut.change_light_state(old, attribute, direction, stepper, "hold") assert stop == stop_expected assert sut.value_attribute == expected_value_attribute called_service_patch.assert_called()