diff --git a/deebot_client/commands/json/auto_empty.py b/deebot_client/commands/json/auto_empty.py index 45130536..39ade08c 100644 --- a/deebot_client/commands/json/auto_empty.py +++ b/deebot_client/commands/json/auto_empty.py @@ -14,13 +14,13 @@ class GetAutoEmpty(OnAutoEmpty, JsonGetCommand): """Get auto empty command.""" - name = "getAutoEmpty" + NAME = "getAutoEmpty" class SetAutoEmpty(ExecuteCommand): """Set auto empty command.""" - name = "setAutoEmpty" + NAME = "setAutoEmpty" def __init__( self, enable: bool | None = None, frequency: Frequency | str | None = None diff --git a/deebot_client/messages/json/auto_empty.py b/deebot_client/messages/json/auto_empty.py index 1d73b61a..282f589e 100644 --- a/deebot_client/messages/json/auto_empty.py +++ b/deebot_client/messages/json/auto_empty.py @@ -14,7 +14,7 @@ class OnAutoEmpty(MessageBodyDataDict): """On auto empty message.""" - name = "onAutoEmpty" + NAME = "onAutoEmpty" @classmethod def _handle_body_data_dict( diff --git a/tests/messages/json/test_auto_empty.py b/tests/messages/json/test_auto_empty.py index 5fff7e93..f114740f 100644 --- a/tests/messages/json/test_auto_empty.py +++ b/tests/messages/json/test_auto_empty.py @@ -1,5 +1,7 @@ from __future__ import annotations +from typing import Any + import pytest from deebot_client.events import auto_empty @@ -7,18 +9,32 @@ from tests.messages import assert_message -@pytest.mark.parametrize("percentage", [0, 49, 100]) -def test_onAutoEmpty(percentage: int) -> None: - data = { +@pytest.mark.parametrize( + ("frequency", "expected_freq"), + [ + (None, None), + ("10", auto_empty.Frequency.MIN_10), + ("auto", auto_empty.Frequency.AUTO), + ("smart", auto_empty.Frequency.SMART), + ], +) +@pytest.mark.parametrize("enable", [True, False]) +def test_onAutoEmpty( + frequency: str | None, expected_freq: auto_empty.Frequency | None, enable: bool +) -> None: + data: dict[str, Any] = { "header": { "pri": 1, - "tzm": 480, - "ts": "1304637391896", + "tzm": 60, + "ts": "1734719921057", "ver": "0.0.1", - "fwVer": "1.8.2", + "fwVer": "1.30.0", "hwVer": "0.1.1", + "wkVer": "0.1.54", }, - "body": {"data": {"value": percentage, "isLow": 1 if percentage < 20 else 0}}, + "body": {"data": {"status": 0, "enable": int(enable)}}, } + if frequency is not None: + data["body"]["data"]["frequency"] = frequency - assert_message(OnAutoEmpty, data, auto_empty.AutoEmptyEvent(percentage)) + assert_message(OnAutoEmpty, data, auto_empty.AutoEmptyEvent(enable, expected_freq))