-
-
Notifications
You must be signed in to change notification settings - Fork 570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New properties of the Xiaomi Air Humidifier added #173
Changes from all commits
6e083cc
204d0d3
552327a
0d2b4e8
aaa7c4e
15586f7
51d381b
cdfe82c
3eb5c88
000d06e
02e1e53
55b2f0a
29562b5
ce2c387
ec258ba
b3b7e8a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
from unittest import TestCase | ||
from miio import AirHumidifier | ||
from miio.airhumidifier import OperationMode, LedBrightness | ||
from miio.airhumidifier import OperationMode, LedBrightness, AirHumidifierException | ||
from .dummies import DummyDevice | ||
import pytest | ||
|
||
|
@@ -10,17 +10,22 @@ def __init__(self, *args, **kwargs): | |
self.state = { | ||
'power': 'on', | ||
'mode': 'medium', | ||
'temp_dec': 186, | ||
'humidity': 62, | ||
'temp_dec': 294, | ||
'humidity': 33, | ||
'buzzer': 'off', | ||
'led_b': 2, | ||
'child_lock': 'on', | ||
'limit_hum': 40, | ||
'trans_level': 85, | ||
} | ||
self.return_values = { | ||
'get_prop': self._get_state, | ||
'set_power': lambda x: self._set_state("power", x), | ||
'set_mode': lambda x: self._set_state("mode", x), | ||
'set_led_b': lambda x: self._set_state("led_b", x), | ||
'set_buzzer': lambda x: self._set_state("buzzer", x), | ||
'set_child_lock': lambda x: self._set_state("child_lock", x), | ||
'set_limit_hum': lambda x: self._set_state("limit_hum", x), | ||
} | ||
super().__init__(args, kwargs) | ||
|
||
|
@@ -64,6 +69,9 @@ def test_status(self): | |
assert self.state().mode == OperationMode(self.device.start_state["mode"]) | ||
assert self.state().led_brightness == LedBrightness(self.device.start_state["led_b"]) | ||
assert self.state().buzzer == (self.device.start_state["buzzer"] == 'on') | ||
assert self.state().child_lock == (self.device.start_state["child_lock"] == 'on') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line too long (89 > 79 characters) |
||
assert self.state().target_humidity == self.device.start_state["limit_hum"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line too long (83 > 79 characters) |
||
assert self.state().trans_level == self.device.start_state["trans_level"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line too long (81 > 79 characters) |
||
|
||
def test_set_mode(self): | ||
def mode(): | ||
|
@@ -112,3 +120,36 @@ def test_status_without_led_brightness(self): | |
self.device.state["led_b"] = None | ||
|
||
assert self.state().led_brightness is None | ||
|
||
def test_set_target_humidity(self): | ||
def target_humidity(): | ||
return self.device.status().target_humidity | ||
|
||
self.device.set_target_humidity(30) | ||
assert target_humidity() == 30 | ||
self.device.set_target_humidity(60) | ||
assert target_humidity() == 60 | ||
self.device.set_target_humidity(80) | ||
assert target_humidity() == 80 | ||
|
||
with pytest.raises(AirHumidifierException): | ||
self.device.set_target_humidity(-1) | ||
|
||
with pytest.raises(AirHumidifierException): | ||
self.device.set_target_humidity(20) | ||
|
||
with pytest.raises(AirHumidifierException): | ||
self.device.set_target_humidity(90) | ||
|
||
with pytest.raises(AirHumidifierException): | ||
self.device.set_target_humidity(110) | ||
|
||
def test_set_child_lock(self): | ||
def child_lock(): | ||
return self.device.status().child_lock | ||
|
||
self.device.set_child_lock(True) | ||
assert child_lock() is True | ||
|
||
self.device.set_child_lock(False) | ||
assert child_lock() is False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (83 > 79 characters)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think houndci should be configured to allow lines up to 100 lines, even when <80 is mostly preferred. This is not a biggie (esp. as it is in the tests), but can be fixed at some point.