mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-10-09 08:58:01 +00:00
Migrate RuleModule to mashumaro (#1283)
Also fixes a bug whereby multiple queries for the same module would overwrite each other.
This commit is contained in:
@@ -136,6 +136,34 @@ CLOUD_MODULE = {
|
||||
}
|
||||
}
|
||||
|
||||
SCHEDULE_MODULE = {
|
||||
"get_next_action": {
|
||||
"action": 1,
|
||||
"err_code": 0,
|
||||
"id": "0794F4729DB271627D1CF35A9A854030",
|
||||
"schd_time": 68927,
|
||||
"type": 2,
|
||||
},
|
||||
"get_rules": {
|
||||
"enable": 1,
|
||||
"err_code": 0,
|
||||
"rule_list": [
|
||||
{
|
||||
"eact": -1,
|
||||
"enable": 1,
|
||||
"id": "8AA75A50A8440B17941D192BD9E01FFA",
|
||||
"name": "name",
|
||||
"repeat": 1,
|
||||
"sact": 1,
|
||||
"smin": 1027,
|
||||
"soffset": 0,
|
||||
"stime_opt": 2,
|
||||
"wday": [1, 1, 1, 1, 1, 1, 1],
|
||||
},
|
||||
],
|
||||
"version": 2,
|
||||
},
|
||||
}
|
||||
|
||||
AMBIENT_MODULE = {
|
||||
"get_current_brt": {"value": 26, "err_code": 0},
|
||||
@@ -450,6 +478,8 @@ class FakeIotTransport(BaseTransport):
|
||||
"smartlife.iot.PIR": MOTION_MODULE,
|
||||
"cnCloud": CLOUD_MODULE,
|
||||
"smartlife.iot.common.cloud": CLOUD_MODULE,
|
||||
"schedule": SCHEDULE_MODULE,
|
||||
"smartlife.iot.common.schedule": SCHEDULE_MODULE,
|
||||
}
|
||||
|
||||
async def send(self, request, port=9999):
|
||||
|
17
tests/iot/modules/test_schedule.py
Normal file
17
tests/iot/modules/test_schedule.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import pytest
|
||||
|
||||
from kasa import Device, Module
|
||||
from kasa.iot.modules.rulemodule import Action, TimeOption
|
||||
|
||||
from ...device_fixtures import device_iot
|
||||
|
||||
|
||||
@device_iot
|
||||
def test_schedule(dev: Device, caplog: pytest.LogCaptureFixture):
|
||||
schedule = dev.modules.get(Module.IotSchedule)
|
||||
assert schedule
|
||||
if rules := schedule.rules:
|
||||
first = rules[0]
|
||||
assert isinstance(first.sact, Action)
|
||||
assert isinstance(first.stime_opt, TimeOption)
|
||||
assert "Unable to read rule list" not in caplog.text
|
Reference in New Issue
Block a user