2222from roborock .data .b01_q10 .b01_q10_code_mappings import B01_Q10_DP
2323from roborock .devices .traits .b01 .q10 import Q10PropertiesApi , create
2424from roborock .devices .traits .b01 .q10 .map import MapContentTrait , MapDpsTrait
25- from roborock .exceptions import RoborockException
2625from roborock .map .b01_grid_layers import GridCalibration
2726from roborock .map .b01_q10_map_parser import (
2827 Q10HeaderCalibration ,
@@ -232,48 +231,25 @@ def test_trace_update_projects_short_path_using_header() -> None:
232231 trait = MapContentTrait ()
233232 packet = replace (parse_map_packet (FIXTURE .read_bytes ()), header_calibration = _USABLE_HEADER )
234233 trait .update_from_map_packet (packet )
234+ base = trait .image_content
235+ assert base is not None
235236 true = GridCalibration (resolution = 20.0 , origin_x = 0.0 , origin_y = 5.0 , y_sign = 1 )
236237 trait .update_from_trace_packet (Q10TracePacket (points = _floor_world_points (packet , true , 6 )))
237238 assert len (trait .path ) < 20 # far too short for the full origin+resolution fit
238239
239- assert trait .render_path_on_map ()[:8 ] == b"\x89 PNG\r \n \x1a \n "
240+ assert trait .image_content is not None
241+ assert trait .image_content != base
240242
241243
242244def test_short_trace_without_header_cannot_be_projected () -> None :
243245 """Without a header origin a short trace cannot be placed on the map."""
244246 packet = parse_map_packet (FIXTURE .read_bytes ())
245247 trait = MapContentTrait ()
246248 trait .update_from_map_packet (packet ) # the fixture header is a keepalive frame
249+ base = trait .image_content
247250 true = GridCalibration (resolution = 10.0 , origin_x = 0.0 , origin_y = 5.0 , y_sign = 1 )
248251 trait .update_from_trace_packet (Q10TracePacket (points = _floor_world_points (packet , true , 6 )))
249- with pytest .raises (RoborockException , match = "No calibration available" ):
250- trait .render_path_on_map ()
251-
252-
253- def test_render_path_on_map_requires_map () -> None :
254- trait = MapContentTrait ()
255- with pytest .raises (RoborockException , match = "No map available" ):
256- trait .render_path_on_map ()
257-
258-
259- def test_render_path_on_map_uses_derived_content () -> None :
260- """The renderer draws the already-derived map content as a PNG."""
261- trait = MapContentTrait ()
262- packet = replace (parse_map_packet (FIXTURE .read_bytes ()), header_calibration = _USABLE_HEADER )
263- trait .update_from_map_packet (packet )
264- true = GridCalibration (resolution = 20.0 , origin_x = 0.0 , origin_y = 5.0 , y_sign = 1 )
265- trait .update_from_trace_packet (Q10TracePacket (points = _floor_world_points (packet , true , 6 )))
266-
267- png = trait .render_path_on_map ()
268-
269- assert png [:8 ] == b"\x89 PNG\r \n \x1a \n "
270-
271-
272- def test_render_path_on_map_without_path_cannot_calibrate () -> None :
273- """A map but no cleaning path -> no calibration -> a clear error."""
274- trait = _trait_with_map ()
275- with pytest .raises (RoborockException , match = "No calibration available" ):
276- trait .render_path_on_map ()
252+ assert trait .image_content == base
277253
278254
279255# --- Overlays ----------------------------------------------------------------
@@ -287,7 +263,8 @@ def test_load_overlays_places_zones_after_calibration() -> None:
287263 trait .update_from_map_packet (packet )
288264 true = GridCalibration (resolution = 20.0 , origin_x = 0.0 , origin_y = 5.0 , y_sign = 1 )
289265 trait .update_from_trace_packet (Q10TracePacket (points = _floor_world_points (packet , true , 6 )))
290- before = trait .render_path_on_map ()
266+ before = trait .image_content
267+ assert before is not None
291268
292269 def rect (zone_type : int , corners : list [tuple [int , int ]]) -> bytes :
293270 out = bytes ([zone_type , len (corners )])
@@ -299,7 +276,7 @@ def rect(zone_type: int, corners: list[tuple[int, int]]) -> bytes:
299276 map_dps .update_from_dps ({B01_Q10_DP .RESTRICTED_ZONE_UP : base64 .b64encode (blob ).decode ()})
300277
301278 assert len (trait .zones ) == 1
302- assert trait .render_path_on_map () != before
279+ assert trait .image_content != before
303280
304281
305282def test_load_overlays_partial_update_keeps_existing_zones () -> None :
0 commit comments