|
13 | 13 | from roborock.devices.traits.v1.consumeable import ConsumableAttribute |
14 | 14 | from roborock.exceptions import RoborockException |
15 | 15 | from roborock.map.map_parser import MapParser, MapParserConfig |
16 | | -from roborock.roborock_message import RoborockMessageProtocol |
| 16 | +from roborock.roborock_message import RoborockMessage, RoborockMessageProtocol |
17 | 17 | from roborock.testing import ( |
18 | 18 | DEFAULT_NETWORK_INFO, |
19 | 19 | DEFAULT_STATUS, |
@@ -317,18 +317,32 @@ async def test_simulator_multipart_map_framing() -> None: |
317 | 317 | simulator.map_parts = 3 |
318 | 318 | simulator.map_part_order = [2, 0, 1] |
319 | 319 |
|
320 | | - emitted: list[tuple[RoborockMessageProtocol, int]] = [] |
321 | | - unsub = await simulator.mqtt_channel.subscribe(lambda msg: emitted.append((msg.protocol, msg.seq))) |
| 320 | + emitted: list[RoborockMessage] = [] |
| 321 | + unsub = await simulator.mqtt_channel.subscribe(emitted.append) |
322 | 322 | try: |
323 | 323 | raw = await simulator.v1_channel.map_rpc_channel.send_command("get_map_v1") |
324 | 324 | finally: |
325 | 325 | unsub() |
326 | 326 |
|
327 | | - assert emitted == [ |
| 327 | + assert [(msg.protocol, msg.seq) for msg in emitted] == [ |
328 | 328 | (RoborockMessageProtocol.MAP_RESPONSE, 3), |
329 | 329 | (RoborockMessageProtocol.MAP_RESPONSE_PART, 1), |
330 | 330 | (RoborockMessageProtocol.MAP_RESPONSE_PART, 2), |
331 | 331 | ] |
| 332 | + first_part = next(msg for msg in emitted if msg.seq == 1) |
| 333 | + assert first_part.payload is not None |
| 334 | + assert first_part.payload.startswith(simulator.security_data.endpoint.encode()) |
| 335 | + assert len(first_part.payload) > 24 |
| 336 | + assert raw == simulator.build_map_bytes() |
| 337 | + |
| 338 | + |
| 339 | +async def test_simulator_multipart_preserves_header_at_high_part_count() -> None: |
| 340 | + """High part counts keep the complete 24-byte header on the first part.""" |
| 341 | + simulator = V1VacuumSimulator(duid="s7_many_parts") |
| 342 | + simulator.connect() |
| 343 | + simulator.map_parts = 20 |
| 344 | + |
| 345 | + raw = await simulator.v1_channel.map_rpc_channel.send_command("get_map_v1") |
332 | 346 | assert raw == simulator.build_map_bytes() |
333 | 347 |
|
334 | 348 |
|
|
0 commit comments