Skip to content

Commit

Permalink
Go on
Browse files Browse the repository at this point in the history
  • Loading branch information
edenhaus committed Dec 20, 2024
1 parent b5d05a1 commit 5a9e5c7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
4 changes: 2 additions & 2 deletions deebot_client/commands/json/auto_empty.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion deebot_client/messages/json/auto_empty.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
class OnAutoEmpty(MessageBodyDataDict):
"""On auto empty message."""

name = "onAutoEmpty"
NAME = "onAutoEmpty"

@classmethod
def _handle_body_data_dict(
Expand Down
32 changes: 24 additions & 8 deletions tests/messages/json/test_auto_empty.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,40 @@
from __future__ import annotations

from typing import Any

import pytest

from deebot_client.events import auto_empty
from deebot_client.messages.json.auto_empty import OnAutoEmpty
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))

0 comments on commit 5a9e5c7

Please sign in to comment.