Skip to content

Commit a64ff99

Browse files
committed
Add more tests
1 parent 592a084 commit a64ff99

1 file changed

Lines changed: 31 additions & 2 deletions

File tree

tests/commands/xml/test_pos.py

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from deebot_client.command import CommandResult
66
from deebot_client.commands.xml import GetPos
7+
from deebot_client.commands.xml.pos import GetChargerPos
78
from deebot_client.events import Position, PositionsEvent
89
from deebot_client.message import HandlingState
910
from deebot_client.rs.map import PositionType
@@ -22,8 +23,13 @@ async def test_get_pos() -> None:
2223

2324
@pytest.mark.parametrize(
2425
"xml",
25-
["<ctl ret='error'/>", "<ctl ret='ok' t='p'></ctl>"],
26-
ids=["error", "no_state"],
26+
[
27+
"<ctl ret='error'/>",
28+
"<ctl ret='ok' t='p'></ctl>",
29+
"<ctl ret='ok' t='??' p='77,-5' a='-3' valid='1'/>",
30+
"<ctl ret='ok' t='p' p='77,-5' a='-3' valid='0'/>",
31+
],
32+
ids=["error", "no_state", "wrong_type", "not_valid"],
2733
)
2834
async def test_get_pos_error(xml: str) -> None:
2935
json = get_request_xml(xml)
@@ -33,3 +39,26 @@ async def test_get_pos_error(xml: str) -> None:
3339
None,
3440
command_result=CommandResult(HandlingState.ANALYSE_LOGGED),
3541
)
42+
43+
44+
async def test_get_charger_pos() -> None:
45+
json = get_request_xml("<ctl ret='ok' p='77,-5' a='-3'/>")
46+
expected_event = PositionsEvent(
47+
positions=[Position(type=PositionType.CHARGER, x=77, y=-5, a=-3)]
48+
)
49+
await assert_command(GetPos(), json, expected_event)
50+
51+
52+
@pytest.mark.parametrize(
53+
"xml",
54+
["<ctl ret='error'/>", "<ctl ret='ok'></ctl>"],
55+
ids=["error", "no_state"],
56+
)
57+
async def test_get_charger_pos_error(xml: str) -> None:
58+
json = get_request_xml(xml)
59+
await assert_command(
60+
GetChargerPos(),
61+
json,
62+
None,
63+
command_result=CommandResult(HandlingState.ANALYSE_LOGGED),
64+
)

0 commit comments

Comments
 (0)