Skip to content

Commit 131b9c8

Browse files
committed
chore: add some docs and a basic test
1 parent c2587fd commit 131b9c8

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

roborock/devices/traits/v1/status.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,19 @@
99

1010

1111
class StatusTrait(StatusV2, common.V1TraitMixin):
12-
"""Trait for managing the status of Roborock devices."""
12+
"""Trait for managing the status of Roborock devices.
13+
14+
The StatusTrait gives you the access to the state of a Roborock vacuum.
15+
The various attribute options on state change per each device.
16+
Values like fan speed, mop mode, etc. have different options for every device
17+
and are dynamically determined.
18+
19+
Usage:
20+
Before accessing status properties, you should call `refresh()` to fetch
21+
the latest data from the device. You must pass in the device feature trait
22+
to this trait so that the dynamic attributes can be pre-determined.
23+
24+
"""
1325

1426
command = RoborockCommand.GET_STATUS
1527

tests/data/v1/test_v1_containers.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
"""Test cases for the containers module."""
22

3-
from syrupy import SnapshotAssertion
3+
import copy
4+
5+
import pytest
6+
from syrupy.assertion import SnapshotAssertion
47

58
from roborock.data.v1 import (
69
MultiMapsList,
@@ -102,6 +105,26 @@ def test_status():
102105
assert s.dock_cool_fan_status == 0
103106

104107

108+
@pytest.mark.parametrize(
109+
"dss_val, expected_clean_box_status, expected_dirty_box_status",
110+
[
111+
(None, None, None),
112+
(169, ClearWaterBoxStatus.okay, DirtyWaterBoxStatus.okay),
113+
(149, ClearWaterBoxStatus.out_of_water, DirtyWaterBoxStatus.full_not_installed),
114+
(153, ClearWaterBoxStatus.okay, DirtyWaterBoxStatus.full_not_installed),
115+
],
116+
)
117+
def test_dss_status(
118+
dss_val: int | None, expected_clean_box_status: ClearWaterBoxStatus, expected_dirty_box_status: DirtyWaterBoxStatus
119+
):
120+
"""Test dss status properly setting child values."""
121+
status = copy.deepcopy(STATUS)
122+
status["dss"] = dss_val
123+
s = StatusV2.from_dict(status)
124+
assert s.clear_water_box_status == expected_clean_box_status
125+
assert s.dirty_water_box_status == expected_dirty_box_status
126+
127+
105128
def test_current_map() -> None:
106129
"""Test the current map logic based on map status."""
107130
s = S7MaxVStatus.from_dict(STATUS)

0 commit comments

Comments
 (0)