-
-
Notifications
You must be signed in to change notification settings - Fork 574
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Air Humidifier: Strong mode property added and docstrings updated #300
Merged
syssi
merged 7 commits into
rytilahti:master
from
syssi:feature/airhumidifier-docstrings
Aug 21, 2018
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6977fdc
Docstrings for trans_level, depth and dry mode added
syssi d7cb889
trans_level evaluated for illustration
syssi 1a65b1d
Repr updated
syssi 6922621
Retrieve the miIO.info once and provide some details
syssi 7bf39f0
Merge branch 'master' into feature/airhumidifier-docstrings
syssi b15898a
Update tests
syssi 5d8e3a8
Fix name
syssi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,10 +6,32 @@ | |
from miio.airhumidifier import (OperationMode, LedBrightness, | ||
AirHumidifierStatus, AirHumidifierException, ) | ||
from .dummies import DummyDevice | ||
from miio.device import DeviceInfo | ||
|
||
|
||
class DummyAirHumidifier(DummyDevice, AirHumidifier): | ||
def __init__(self, *args, **kwargs): | ||
self.dummy_device_info = { | ||
'fw_ver': '1.2.9_5033', | ||
'token': '68ffffffffffffffffffffffffffffff', | ||
'otu_stat': [101, 74, 5343, 0, 5327, 407], | ||
'mmfree': 228248, | ||
'netif': {'gw': '192.168.0.1', | ||
'localIp': '192.168.0.25', | ||
'mask': '255.255.255.0'}, | ||
'ott_stat': [0, 0, 0, 0], | ||
'model': 'zhimi.humidifier.v1', | ||
'cfg_time': 0, | ||
'life': 575661, | ||
'ap': {'rssi': -35, 'ssid': 'ap', | ||
'bssid': 'FF:FF:FF:FF:FF:FF'}, | ||
'wifi_fw_ver': 'SD878x-14.76.36.p84-702.1.0-WM', | ||
'hw_ver': 'MW300', | ||
'ot': 'otu', | ||
'mac': '78:11:FF:FF:FF:FF' | ||
} | ||
self.device_info = None | ||
|
||
self.state = { | ||
'power': 'on', | ||
'mode': 'medium', | ||
|
@@ -37,9 +59,14 @@ def __init__(self, *args, **kwargs): | |
'set_child_lock': lambda x: self._set_state("child_lock", x), | ||
'set_limit_hum': lambda x: self._set_state("limit_hum", x), | ||
'set_dry': lambda x: self._set_state("dry", x), | ||
'miIO.info': self._get_device_info, | ||
} | ||
super().__init__(args, kwargs) | ||
|
||
def _get_device_info(self, _): | ||
"""Return dummy device info.""" | ||
return self.dummy_device_info | ||
|
||
|
||
@pytest.fixture(scope="class") | ||
def airhumidifier(request): | ||
|
@@ -72,7 +99,9 @@ def test_off(self): | |
def test_status(self): | ||
self.device._reset_state() | ||
|
||
assert repr(self.state()) == repr(AirHumidifierStatus(self.device.start_state)) | ||
device_info = DeviceInfo(self.device.dummy_device_info) | ||
|
||
assert repr(self.state()) == repr(AirHumidifierStatus(self.device.start_state, device_info)) | ||
|
||
assert self.is_on() is True | ||
assert self.state().temperature == self.device.start_state["temp_dec"] / 10.0 | ||
|
@@ -90,6 +119,11 @@ def test_status(self): | |
assert self.state().hardware_version == self.device.start_state["hw_version"] | ||
assert self.state().button_pressed == self.device.start_state["button_pressed"] | ||
|
||
assert self.state().firmware_version == device_info.firmware_version | ||
assert self.state().firmware_version_major == device_info.firmware_version.rsplit('_', 1)[0] | ||
assert self.state().firmware_version_minor == int(device_info.firmware_version.rsplit('_', 1)[1]) | ||
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 (105 > 100 characters) |
||
assert self.state().strong_mode_enabled is False | ||
|
||
def test_set_mode(self): | ||
def mode(): | ||
return self.device.status().mode | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
continuation line under-indented for visual indent