Skip to content

Commit

Permalink
Fix test and remove useless function
Browse files Browse the repository at this point in the history
  • Loading branch information
edenhaus committed Jan 21, 2025
1 parent 8b27eb1 commit 8fbd644
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
6 changes: 1 addition & 5 deletions deebot_client/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,6 @@ async def on_map_subset(event: MapSubsetEvent) -> None:

# ---------------------------- METHODS ----------------------------

def _update_trace_points(self, data: str) -> None:
_LOGGER.debug("[_update_trace_points]: %s", data)
self._map_data.trace_values.extend(extract_trace_points(data))

def _draw_map_pieces(self, image: Image.Image) -> None:
_LOGGER.debug("[_draw_map_pieces] Draw")
image_x = 0
Expand Down Expand Up @@ -467,7 +463,7 @@ async def on_map_trace(event: MapTraceEvent) -> None:
if event.start == 0:
self._map_data.trace_values.clear()

self._update_trace_points(event.data)
self._map_data.trace_values.extend(extract_trace_points(event.data))

unsubscribers.append(self._event_bus.subscribe(MapTraceEvent, on_map_trace))

Expand Down
11 changes: 4 additions & 7 deletions tests/test_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import asyncio
from typing import TYPE_CHECKING
from unittest.mock import ANY, AsyncMock, Mock, call, patch
from unittest.mock import ANY, AsyncMock, Mock, call

import pytest
from svg import (
Expand Down Expand Up @@ -40,7 +40,6 @@
MapData,
Path,
Point,
TracePoint,
ViewBoxFloat,
_calc_point,
_calc_point_in_viewbox,
Expand All @@ -49,6 +48,7 @@
_points_to_svg_path,
)
from deebot_client.models import Room
from deebot_client.rs import TracePoint

from .common import block_till_done

Expand Down Expand Up @@ -186,10 +186,6 @@ async def on_change() -> None:
assert not map._unsubscribers


@patch(
"deebot_client.map.decompress_7z_base64_data",
Mock(return_value=b"\x10\x00\x00\x01\x00"),
)
async def test_Map_svg_traces_path(
execute_mock: AsyncMock, event_bus_mock: Mock
) -> None:
Expand All @@ -198,7 +194,8 @@ async def test_Map_svg_traces_path(
path = map._get_svg_traces_path()
assert path is None

map._update_trace_points("")
# Normally trace points would be added by MapTraceEvent
map._map_data.trace_values.append(TracePoint(x=16, y=256, connected=True))
path = map._get_svg_traces_path()

assert path == Path(
Expand Down

0 comments on commit 8fbd644

Please sign in to comment.