From d6463b57e4f63f97a38843f8eb45bebbe15bec53 Mon Sep 17 00:00:00 2001 From: Robert Resch Date: Thu, 30 May 2024 09:09:19 +0200 Subject: [PATCH] Apply suggestions from code review --- deebot_client/map.py | 10 +++------- tests/test_map.py | 20 +++++++------------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/deebot_client/map.py b/deebot_client/map.py index 41fa1734..dc938b7e 100644 --- a/deebot_client/map.py +++ b/deebot_client/map.py @@ -269,11 +269,7 @@ def _get_svg_positions( for position in sorted(positions, key=lambda x: _POSITIONS_SVG[x.type].order): pos = _calc_point_in_viewbox(position.x, position.y, viewbox) svg_positions.append( - svg.Use( - href=f"#{_POSITIONS_SVG[position.type].svg_id}", - x=pos.x, - y=pos.y, - ) + svg.Use(href=f"#{_POSITIONS_SVG[position.type].svg_id}", x=pos.x, y=pos.y) ) return svg_positions @@ -385,7 +381,7 @@ async def on_map_subset(event: MapSubsetEvent) -> None: def _update_trace_points(self, data: str) -> None: _LOGGER.debug("[_update_trace_points] Begin") - trace_points = util.decompress_7z_base64_data(data) + trace_points = decompress_7z_base64_data(data) for i in range(0, len(trace_points), 5): position_x, position_y = struct.unpack(" Image.Image: def update_points(self, base64_data: str) -> None: """Add map piece points.""" - decoded = util.decompress_7z_base64_data(base64_data) + decoded = decompress_7z_base64_data(base64_data) old_crc32 = self._crc32 self._crc32 = zlib.crc32(decoded) diff --git a/tests/test_map.py b/tests/test_map.py index 4231f2a0..16126079 100644 --- a/tests/test_map.py +++ b/tests/test_map.py @@ -280,27 +280,27 @@ def test_get_svg_subset(subset: MapSubsetEvent, expected: Path | Polygon) -> Non _test_get_svg_positions_data = [ ( - [Position(PositionType.CHARGER, 5000, -55000)], + [Position(PositionType.CHARGER, 5000, -55000, 0)], ViewBoxSpec(-500, -500, 1000, 1000), [Use(href="#c", x=100, y=500)], ), ( - [Position(PositionType.DEEBOT, 15000, 15000)], + [Position(PositionType.DEEBOT, 15000, 15000, 0)], ViewBoxSpec(-500, -500, 1000, 1000), [Use(href="#d", x=300, y=-300)], ), ( [ - Position(PositionType.CHARGER, 25000, 55000), - Position(PositionType.DEEBOT, -5000, -50000), + Position(PositionType.CHARGER, 25000, 55000, 0), + Position(PositionType.DEEBOT, -5000, -50000, 0), ], ViewBoxSpec(-500, -500, 1000, 1000), [Use(href="#d", x=-100, y=500), Use(href="#c", x=500, y=-500)], ), ( [ - Position(PositionType.DEEBOT, -10000, 10000), - Position(PositionType.CHARGER, 50000, 5000), + Position(PositionType.DEEBOT, -10000, 10000, 0), + Position(PositionType.CHARGER, 50000, 5000, 0), ], ViewBoxSpec(-500, -500, 1000, 1000), [Use(href="#d", x=-200, y=-200), Use(href="#c", x=500, y=-100)], @@ -317,10 +317,4 @@ def test_get_svg_positions( expected: list[Use], ) -> None: result = _get_svg_positions(positions, viewbox) - assert len(result) == len(expected) - for result_item, expected_item in zip(result, expected, strict=True): - assert type(result_item) == Use - assert result_item.href == expected_item.href - assert result_item.x == expected_item.x - assert result_item.y == expected_item.y - assert result_item == expected_item + assert result == expected