-
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
27 additions
and
11 deletions.
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
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
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 |
---|---|---|
@@ -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)) |