diff --git a/apps/controllerx/core/type/light_controller.py b/apps/controllerx/core/type/light_controller.py index d1e757c4..bb64c445 100644 --- a/apps/controllerx/core/type/light_controller.py +++ b/apps/controllerx/core/type/light_controller.py @@ -279,10 +279,14 @@ async def set_value(self, attribute, fraction): @action async def on_full(self, attribute): + stepper = self.manual_steppers[attribute] + stepper.previous_direction = Stepper.UP await self.set_value(attribute, 1) @action async def on_min(self, attribute): + stepper = self.manual_steppers[attribute] + stepper.previous_direction = Stepper.DOWN await self.set_value(attribute, 0) async def get_attribute(self, attribute): diff --git a/tests/core/type/light_controller_test.py b/tests/core/type/light_controller_test.py index 2de31f26..612e6a1a 100644 --- a/tests/core/type/light_controller_test.py +++ b/tests/core/type/light_controller_test.py @@ -228,9 +228,15 @@ async def test_on_full(sut, mocker): max_ = 10 on_patch = mocker.patch.object(sut, "on") stepper = MinMaxStepper(1, max_, 10) + stepper.previous_direction = Stepper.DOWN sut.manual_steppers = {attribute: stepper} + + # SUT await sut.on_full(attribute) + + # Checks on_patch.assert_called_once_with(**{attribute: max_}) + assert stepper.previous_direction == Stepper.UP @pytest.mark.asyncio @@ -239,9 +245,15 @@ async def test_on_min(sut, mocker): min_ = 1 on_patch = mocker.patch.object(sut, "on") stepper = MinMaxStepper(min_, 10, 10) + stepper.previous_direction = Stepper.UP sut.manual_steppers = {attribute: stepper} + + # SUT await sut.on_min(attribute) + + # Checks on_patch.assert_called_once_with(**{attribute: min_}) + assert stepper.previous_direction == Stepper.DOWN @pytest.mark.parametrize(