Skip to content

Commit 613db33

Browse files
author
NOisi-X
committed
fix: update tests for A01 QoS 1 and timestamp changes
1 parent 6eaf4f9 commit 613db33

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

tests/devices/traits/a01/test_init.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ async def test_dyad_api_query_values(dyad_api: DyadApi, fake_channel: FakeChanne
7777
assert message.protocol == RoborockMessageProtocol.RPC_REQUEST
7878
assert message.version == b"A01"
7979
payload_data = json.loads(unpad(message.payload, AES.block_size))
80-
assert payload_data == {"dps": {"10000": "[209, 201, 207, 214, 215, 227, 229, 230, 222, 224]"}}
80+
assert payload_data["dps"] == {"10000": "[209, 201, 207, 214, 215, 227, 229, 230, 222, 224]"}
81+
assert "t" in payload_data
8182

8283

8384
@pytest.mark.parametrize(
@@ -174,7 +175,8 @@ async def test_zeo_api_query_values(zeo_api: ZeoApi, fake_channel: FakeChannel):
174175
assert message.protocol == RoborockMessageProtocol.RPC_REQUEST
175176
assert message.version == b"A01"
176177
payload_data = json.loads(unpad(message.payload, AES.block_size))
177-
assert payload_data == {"dps": {"10000": "[203, 207, 226, 227, 224, 218]"}}
178+
assert payload_data["dps"] == {"10000": "[203, 207, 226, 227, 224, 218]"}
179+
assert "t" in payload_data
178180

179181

180182
@pytest.mark.parametrize(
@@ -245,7 +247,8 @@ async def test_dyad_api_set_value(dyad_api: DyadApi, fake_channel: FakeChannel):
245247
# decode the payload to verify contents
246248
payload_data = json.loads(unpad(message.payload, AES.block_size))
247249
# A01 protocol expects values to be strings in the dps dict
248-
assert payload_data == {"dps": {"209": 1}}
250+
assert payload_data["dps"] == {"209": 1}
251+
assert "t" in payload_data
249252

250253

251254
async def test_zeo_api_set_value(zeo_api: ZeoApi, fake_channel: FakeChannel):
@@ -261,4 +264,5 @@ async def test_zeo_api_set_value(zeo_api: ZeoApi, fake_channel: FakeChannel):
261264
# decode the payload to verify contents
262265
payload_data = json.loads(unpad(message.payload, AES.block_size))
263266
# A01 protocol expects values to be strings in the dps dict
264-
assert payload_data == {"dps": {"204": "standard"}}
267+
assert payload_data["dps"] == {"204": "standard"}
268+
assert "t" in payload_data

tests/e2e/test_device_manager.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ async def test_v1_device(
226226
test_topic = TEST_TOPIC_FORMAT.format(duid="abc123")
227227
mqtt_responses: list[bytes] = [
228228
*MQTT_DEFAULT_RESPONSES,
229+
# PUBACK for the QoS 1 publish (MID=2)
230+
mqtt_packet.gen_puback(mid=2),
229231
# ACK the GET_NETWORK_INFO call. id is deterministic based on deterministic_message_fixtures
230232
mqtt_packet.gen_publish(
231233
test_topic, mid=2, payload=response_builder.build_v1_rpc(data={"id": 9090, "result": NETWORK_INFO})
@@ -335,6 +337,8 @@ async def test_l01_device(
335337
test_topic = TEST_TOPIC_FORMAT.format(duid="abc123")
336338
mqtt_responses: list[bytes] = [
337339
*MQTT_DEFAULT_RESPONSES,
340+
# PUBACK for the QoS 1 publish (MID=2)
341+
mqtt_packet.gen_puback(mid=2),
338342
# ACK the GET_NETWORK_INFO call. id is deterministic based on deterministic_message_fixtures
339343
mqtt_packet.gen_publish(
340344
test_topic, mid=2, payload=mqtt_response_builder.build_v1_rpc(data={"id": 9090, "result": NETWORK_INFO})
@@ -466,10 +470,14 @@ async def test_q7_device(
466470
test_topic = TEST_TOPIC_FORMAT.format(duid="device-id-q7")
467471
mqtt_responses: list[bytes] = [
468472
*MQTT_DEFAULT_RESPONSES,
473+
# PUBACK for the QoS 1 query publish (MID=2)
474+
mqtt_packet.gen_puback(mid=2),
469475
# ACK the Query status call sent below. id is deterministic based on deterministic_message_fixtures
470476
mqtt_packet.gen_publish(
471477
test_topic, mid=2, payload=response_builder.build_b01_q7_rpc({"status": 2}, msg_id=9090)
472478
),
479+
# PUBACK for the QoS 1 start clean publish (MID=3)
480+
mqtt_packet.gen_puback(mid=3),
473481
# ACK the start clean call sent below. id is deterministic based on deterministic_message_fixtures
474482
mqtt_packet.gen_publish(test_topic, mid=2, payload=response_builder.build_b01_q7_rpc("ok", msg_id=9093)),
475483
]
@@ -527,6 +535,8 @@ async def test_a01_device(
527535
test_topic = TEST_TOPIC_FORMAT.format(duid="zeo_duid")
528536
mqtt_responses: list[bytes] = [
529537
*MQTT_DEFAULT_RESPONSES,
538+
# PUBACK for the QoS 1 publish (MID=2, matches the query publish below)
539+
mqtt_packet.gen_puback(mid=2),
530540
# ACK the Query state call sent below. id is deterministic based on deterministic_message_fixtures
531541
mqtt_packet.gen_publish(test_topic, mid=2, payload=response_builder.build_a01_rpc({"203": 6})),
532542
]

0 commit comments

Comments
 (0)