Skip to content

docs(q7): document live map pushes and cover them in tests - #927

Open
ximex wants to merge 1 commit into
Python-roborock:mainfrom
ximex:q7-map-push-docs-tests
Open

docs(q7): document live map pushes and cover them in tests#927
ximex wants to merge 1 commit into
Python-roborock:mainfrom
ximex:q7-map-push-docs-tests

Conversation

@ximex

@ximex ximex commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Follow-up on the Q7 (B01) live map pushes: the runtime behaviour is unchanged, this only makes the push path discoverable and pins it down in tests.

Docs

MapContentTrait's module docstring describes a pure pull contract — refresh() does I/O, parse_map_content() reparses, fields "are then readable". That no longer holds: update_from_push() writes the same cached fields from the MQTT receive callback and notifies listeners, so image_content / map_data / raw_api_response can change without the reader calling anything. The docstring now says so.

docs/DEVICES.md listed only device.b01_q7_properties under B01 Q7, with no hint that maps arrive on their own. A consumer reading it finds just the pull API and builds a polling loop for something the device streams by itself — so the entry point (map_content.add_update_listener(cb)) and the fields to read are now named, the way the Q10 section already does for its commands.

Tests

Two gaps in test_q7_map_content_updates_from_push:

  • map_data was not asserted, even though it carries the live robot pose and cleaning path. _parse_and_store() sets three fields; dropping the map_data assignment left the test green. Asserted by identity, since two empty MapData instances compare equal and equality would also accept a stale or copied object.
  • Nothing asserted that the push path publishes no command. That is the actual claim of the feature: refresh() needs map_trait.current_map_id and costs two round trips (the refresh tests assert len(published_commands) == 2), while a push needs neither. Without the assertion the test would still pass if update_from_push() or start() started issuing RPCs.

uv run pytest tests/devices/traits/b01/q7 tests/devices/rpc/test_b01_q7_channel.py → 55 passed.

🤖 Generated with Claude Code

The map content trait's module docstring described a pure pull contract --
`refresh()` does I/O, `parse_map_content()` reparses, fields "are then
readable" -- which no longer holds: `update_from_push()` mutates the same
cached fields from the MQTT receive callback and notifies listeners, so
they can change without the reader calling anything. Spell that out.

`docs/DEVICES.md` only mentioned `device.b01_q7_properties` for Q7, so the
push path was undiscoverable and consumers would build a polling loop for
something the device streams by itself. Name the listener entry point and
the fields to read.

The push test checked `image_content` and `raw_api_response` but not
`map_data`, the field carrying the live pose and cleaning path -- dropping
its assignment kept the test green. It also never asserted that no RPC was
published, which is the whole point of the push path: unlike `refresh()`,
it needs no map id and no round trips.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant