-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 325adependabot/pip/paho-mqtt-2.1.0
- Loading branch information
Showing
5 changed files
with
152 additions
and
34 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
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"""Tests for the Roborock Local Client V1.""" | ||
|
||
from queue import Queue | ||
|
||
from roborock.protocol import MessageParser | ||
from roborock.roborock_message import RoborockMessage, RoborockMessageProtocol | ||
from roborock.version_1_apis import RoborockLocalClientV1 | ||
|
||
from .mock_data import LOCAL_KEY | ||
|
||
|
||
def build_rpc_response(protocol: RoborockMessageProtocol, seq: int) -> bytes: | ||
"""Build an encoded RPC response message.""" | ||
message = RoborockMessage( | ||
protocol=protocol, | ||
random=23, | ||
seq=seq, | ||
payload=b"ignored", | ||
) | ||
return MessageParser.build(message, local_key=LOCAL_KEY) | ||
|
||
|
||
async def test_async_connect( | ||
local_client: RoborockLocalClientV1, | ||
received_requests: Queue, | ||
response_queue: Queue, | ||
): | ||
"""Test that we can connect to the Roborock device.""" | ||
response_queue.put(build_rpc_response(RoborockMessageProtocol.HELLO_RESPONSE, 1)) | ||
response_queue.put(build_rpc_response(RoborockMessageProtocol.PING_RESPONSE, 2)) | ||
|
||
await local_client.async_connect() | ||
assert local_client.is_connected() | ||
assert received_requests.qsize() == 2 | ||
|
||
await local_client.async_disconnect() | ||
assert not local_client.is_connected() |