-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some initial tests for heaters (#167)
Co-authored-by: Andy Cooper <andcooper@cisco.com>
- Loading branch information
1 parent
5322225
commit 736aca5
Showing
3 changed files
with
204 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
153 changes: 153 additions & 0 deletions
153
tests/pydreo/api_responses/get_device_state_HSH004S_1.json
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,153 @@ | ||
{ | ||
"code": 0, | ||
"msg": "OK", | ||
"data": { | ||
"currentPage": 1, | ||
"pageSize": 100, | ||
"totalNum": 2, | ||
"totalPage": 1, | ||
"familyRooms": null, | ||
"list": [ | ||
{ | ||
"deviceId": "4456", | ||
"sn": "HSH004S_1", | ||
"brand": "Dreo", | ||
"model": "DR-HSH004S", | ||
"productId": "1536529638074978306", | ||
"productName": "Heater", | ||
"deviceName": "Heater 1", | ||
"shared": false, | ||
"series": null, | ||
"seriesName": "Atom One S", | ||
"type": 0, | ||
"owner": true, | ||
"familyId": null, | ||
"familyName": null, | ||
"roomId": null, | ||
"roomName": null, | ||
"roomNameI18Key": "", | ||
"color": "b", | ||
"controlsConf": { | ||
"template": "DR-HSH004S", | ||
"lottie": { | ||
"key": "poweron", | ||
"frames": [ | ||
{ | ||
"value": 0, | ||
"frame": [ | ||
0 | ||
] | ||
}, | ||
{ | ||
"value": 1, | ||
"frame": [ | ||
2 | ||
] | ||
} | ||
] | ||
}, | ||
"instructions": { | ||
"en": "https://fe.dreo.com/en/safety-protection-instructions/", | ||
"zh": "https://fe.dreo.com/zh/safety-protection-instructions/" | ||
}, | ||
"cards": [ | ||
{ | ||
"type": 2, | ||
"title": "device_control_temp", | ||
"icon": "", | ||
"image": "", | ||
"url": "", | ||
"show": true | ||
}, | ||
{ | ||
"type": 6, | ||
"title": "device_settings_title", | ||
"icon": "ic_setting", | ||
"image": "", | ||
"url": "dreo://nav/device/setting?deviceSn=${sn}", | ||
"show": true, | ||
"key": "setting" | ||
} | ||
], | ||
"preference": [ | ||
{ | ||
"id": "200", | ||
"type": "Panel Sound", | ||
"title": "device_control_panelsound", | ||
"image": "ic_mute", | ||
"reverse": true, | ||
"cmd": "muteon" | ||
}, | ||
{ | ||
"id": "210", | ||
"type": "Display Auto Off", | ||
"title": "device_fans_mode_auto_display", | ||
"image": "ic_display", | ||
"reverse": true, | ||
"cmd": "lighton" | ||
}, | ||
{ | ||
"id": "220", | ||
"type": "Child Lock", | ||
"title": "device_control_childlock", | ||
"image": "ic_child_lock", | ||
"reverse": false, | ||
"cmd": "childlockon" | ||
}, | ||
{ | ||
"id": "230", | ||
"type": "Temperature Unit", | ||
"title": "device_control_temp_unit", | ||
"image": "ic_temp_unit" | ||
}, | ||
{ | ||
"id": "240", | ||
"type": "Temperature Calibration", | ||
"title": "device_control_temp_calibration", | ||
"image": "ic_temp_cal" | ||
} | ||
], | ||
"control": [ | ||
{ | ||
"swingtype": false, | ||
"hideSafeMode": false | ||
} | ||
], | ||
"category": "Space Heater" | ||
}, | ||
"mainConf": { | ||
"isSmart": true, | ||
"isWifi": true, | ||
"isBluetooth": true, | ||
"isVoiceControl": true | ||
}, | ||
"resourcesConf": { | ||
"imageSmallSrc": "https://resources.dreo-cloud.com/app/preSigned202406/285c6f0e219a6f40b5a2b79a053cf6d3cb.png", | ||
"imageFullSrc": "https://resources.dreo-cloud.com/app/preSigned202406/288eb1e27a155b4b4c875393b04313706a.zip", | ||
"imageSmallDarkSrc": "", | ||
"imageFullDarkSrc": "" | ||
}, | ||
"servicesConf": [ | ||
{ | ||
"key": "user_manual", | ||
"value": "https://resources.dreo-cloud.com/app/202310/12056ea09c80d5455f9aa4e713ca8bd84e.pdf" | ||
} | ||
], | ||
"userManuals": [ | ||
{ | ||
"url": "https://resources.dreo-cloud.com/app/preSigned202407/2b5ae671ab4f64b05a03cb3d4ba3527b4.pdf", | ||
"icon": null, | ||
"desc": "Smart PTC Fan Heater (US)", | ||
"lang": "en" | ||
}, | ||
{ | ||
"url": "https://resources.dreo-cloud.com/app/preSigned202407/24bc6a0c439f348ca9a73d5108a82c9be.pdf", | ||
"icon": null, | ||
"desc": "Smart PTC Fan Heater (EU)", | ||
"lang": "en" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} |
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,48 @@ | ||
"""Tests for Dreo Fans""" | ||
# pylint: disable=used-before-assignment | ||
import logging | ||
from typing import TYPE_CHECKING | ||
from unittest.mock import patch, call | ||
import pytest | ||
|
||
if TYPE_CHECKING: | ||
from .imports import * # pylint: disable=W0401,W0614 | ||
from . import call_json | ||
from .testbase import TestBase | ||
else: | ||
from imports import * # pylint: disable=W0401,W0614 | ||
import call_json | ||
from testbase import TestBase | ||
|
||
logger = logging.getLogger(__name__) | ||
logger.setLevel(logging.DEBUG) | ||
|
||
LOGIN_RESPONSE = call_json.LOGIN_RET_BODY | ||
|
||
|
||
class TestPyDreoHeater(TestBase): | ||
"""Test PyDreoHeater class.""" | ||
def test_heater_load_and_send_commands(self): | ||
"""Load heater and test sending commands.""" | ||
|
||
self.get_devices_file_name = "get_device_state_HSH004S_1.json" | ||
self.manager.load_devices() | ||
assert len(self.manager.heaters) == 1 | ||
heater = self.manager.heaters[0] | ||
|
||
assert heater.heat_range == (1, 3) | ||
assert heater.preset_modes == ['H1', 'H2', 'H3'] | ||
|
||
with patch('pydreo.PyDreo.send_command') as mock_send_command: | ||
heater.poweron = True | ||
mock_send_command.assert_called_once_with(heater, {POWERON_KEY: True}) | ||
|
||
with (patch('pydreo.PyDreo.send_command') as mock_send_command): | ||
heater.preset_mode = 'H1' | ||
mock_send_command.assert_has_calls([call(heater, {HTALEVEL_KEY: 1})], True) | ||
|
||
with pytest.raises(ValueError): | ||
heater.preset_mode = 'not_a_mode' | ||
|
||
|
||
|