-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix-email-obfuscation
- Loading branch information
Showing
3 changed files
with
82 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Midea local 40 device tests.""" |
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
"""Test 40 Device.""" | ||
|
||
from unittest.mock import patch | ||
|
||
import pytest | ||
|
||
from midealocal.devices.x40 import DeviceAttributes, MideaX40Device | ||
|
||
|
||
class TestMideaX40Device: | ||
"""Test Midea 40 Device.""" | ||
|
||
device: MideaX40Device | ||
|
||
@pytest.fixture(autouse=True) | ||
def _setup_device(self) -> None: | ||
"""Midea DA Device setup.""" | ||
self.device = MideaX40Device( | ||
name="Test Device", | ||
device_id=1, | ||
ip_address="192.168.1.100", | ||
port=6444, | ||
token="AA", | ||
key="BB", | ||
protocol=3, | ||
model="test_model", | ||
subtype=1, | ||
customize="", | ||
) | ||
|
||
def test_customize(self) -> None: | ||
"""Test precision halves.""" | ||
with patch( | ||
"midealocal.devices.x40.MessageX40Response", | ||
) as mock_message_response: | ||
mock_message = mock_message_response.return_value | ||
mock_message.light = True | ||
mock_message.ventilation = True | ||
mock_message.fan_speed = 1 | ||
mock_message.direction = 5 | ||
mock_message.smelly_sensor = True | ||
|
||
mock_message.current_temperature = 53 | ||
new_status = self.device.process_message(b"") | ||
assert new_status[DeviceAttributes.current_temperature] == 53 | ||
|
||
self.device.set_customize('{"precision_halves": true}') | ||
assert self.device.precision_halves is True | ||
mock_message.current_temperature = 53 | ||
new_status = self.device.process_message(b"") | ||
assert new_status[DeviceAttributes.current_temperature] == 26.5 | ||
|
||
self.device.set_customize("{") # Test invalid json | ||
assert self.device.precision_halves is False |