From 01fdc685db5f2b9d44abfc6a924ba95ce28dbf4e Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Mon, 4 Jun 2018 22:57:58 +0200 Subject: [PATCH] Add test for the natural speed setter --- miio/tests/test_fan.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/miio/tests/test_fan.py b/miio/tests/test_fan.py index ccb1ab5c3..2f256ed6d 100644 --- a/miio/tests/test_fan.py +++ b/miio/tests/test_fan.py @@ -383,6 +383,23 @@ def direct_speed(): with pytest.raises(FanException): self.device.set_direct_speed(101) + def test_set_natural_speed(self): + def natural_speed(): + return self.device.status().natural_speed + + self.device.set_natural_speed(0) + assert natural_speed() == 0 + self.device.set_natural_speed(1) + assert natural_speed() == 1 + self.device.set_natural_speed(100) + assert natural_speed() == 100 + + with pytest.raises(FanException): + self.device.set_natural_speed(-1) + + with pytest.raises(FanException): + self.device.set_natural_speed(101) + def test_set_rotate(self): """The method is open-loop. The new state cannot be retrieved.""" self.device.set_rotate(MoveDirection.Left)