Skip to content

Commit

Permalink
add get and set fan speed tests (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
edenhaus authored Jan 28, 2022
1 parent 44b9fb6 commit 974c5cd
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion tests/commands/test_fan_speed.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,42 @@
from deebot_client.commands import FanSpeedLevel
from typing import Union

import pytest

from deebot_client.commands import FanSpeedLevel, GetFanSpeed, SetFanSpeed
from deebot_client.events import FanSpeedEvent
from tests.commands import assert_command_requested
from tests.helpers import verify_DisplayNameEnum_unique


def test_FanSpeedLevel_unique():
verify_DisplayNameEnum_unique(FanSpeedLevel)


def test_GetFanSpeed_requested():
data = {
"id": "WiQO",
"ret": "ok",
"resp": {
"header": {
"pri": 1,
"tzm": 480,
"ts": "1305336289055",
"ver": "0.0.1",
"fwVer": "1.8.2",
"hwVer": "0.1.1",
},
"body": {"code": 0, "msg": "ok", "data": {"speed": 2}},
},
}

assert_command_requested(GetFanSpeed(), data, FanSpeedEvent("max+"))


@pytest.mark.parametrize(
"value, expected", [("quiet", 1000), ("max+", 2), (0, 0), (FanSpeedLevel.MAX, 1)]
)
def test_SetFanSpeed(value: Union[str, int, FanSpeedLevel], expected: int):

command = SetFanSpeed(value)
assert command.name == "setSpeed"
assert command.args == {"speed": expected}

0 comments on commit 974c5cd

Please sign in to comment.