Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
edenhaus committed Dec 23, 2023
1 parent b11a5f2 commit a7de74f
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions tests/test_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,42 @@
Position,
PositionType,
)
from deebot_client.map import Map, MapData, _calc_point
from deebot_client.map import (
AxisManipulation,
Map,
MapData,
MapManipulation,
Point,
_calc_point,
)
from deebot_client.models import Room

_test_calc_point_data = [
(0, 10, None, (0.0, 10.0)),
(10, 100, (100, 0, 200, 50), (200.0, 50.0)),
(10, 100, (0, 0, 1000, 1000), (400.2, 402.0)),
(10, 100, (100, 0, 200, 50), Point(100.0, 0.0)),
(10, 100, (0, 0, 1000, 1000), Point(400.2, 598.0)),
]


@pytest.mark.parametrize(("x", "y", "image_box", "expected"), _test_calc_point_data)
def test_calc_point(
x: int,
y: int,
image_box: tuple[int, int, int, int] | None,
expected: tuple[float, float],
image_box: tuple[int, int, int, int],
expected: Point,
) -> None:
result = _calc_point(x, y, image_box)
manipulation = MapManipulation(
AxisManipulation(
map_shift=image_box[0],
svg_max=image_box[2] - image_box[0],
_transform=lambda _, y: y,
),
AxisManipulation(
map_shift=image_box[1],
svg_max=image_box[3] - image_box[1],
_transform=lambda x, y: 2 * x - y,
),
)
result = _calc_point(x, y, manipulation)
assert result == expected


Expand Down

0 comments on commit a7de74f

Please sign in to comment.