Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): represent Location correctly in log #7565

Merged
merged 1 commit into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/src/opentrons/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ def move(self, point: Point) -> 'Location':
return Location(point=self.point + point,
labware=self._labware.object)

def __repr__(self) -> str:
return f"Location(point={repr(self._point)}, labware={self._labware})"


# TODO(mc, 2020-10-22): use MountType implementation for Mount
class Mount(enum.Enum):
Expand Down
23 changes: 22 additions & 1 deletion api/tests/opentrons/test_types.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from opentrons.types import Point
from opentrons.types import Point, Location


def test_point_mul():
Expand All @@ -21,3 +21,24 @@ def test_point_rmul():

b = 3.1
assert b * a == Point(3.1, 6.2, 9.3)


def test_location_repr_labware(min_lw):
"""It should represent labware as Labware"""
loc = Location(point=Point(x=1.1, y=2.1, z=3.5), labware=min_lw)
assert f'{loc}' ==\
"Location(point=Point(x=1.1, y=2.1, z=3.5), labware=minimal labware on deck)"


def test_location_repr_well(min_lw):
"""It should represent labware as Well"""
loc = Location(point=Point(x=1, y=2, z=3), labware=min_lw.wells()[0])
assert f'{loc}' == \
"Location(point=Point(x=1, y=2, z=3), labware=A1 of minimal labware on deck)"


def test_location_repr_slot():
"""It should represent labware as a slot"""
loc = Location(point=Point(x=-1, y=2, z=3), labware="1")
assert f'{loc}' == \
"Location(point=Point(x=-1, y=2, z=3), labware=1)"