Skip to content

Commit

Permalink
z height drop increase and test fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
CaseyBatten committed Oct 30, 2024
1 parent cb4ab7a commit 115957d
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 3 deletions.
5 changes: 3 additions & 2 deletions api/src/opentrons/protocol_api/protocol_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
UnsupportedAPIError,
)
from opentrons_shared_data.errors.exceptions import CommandPreconditionViolated
from opentrons.protocol_engine.errors import LabwareMovementNotAllowedError

from ._types import OffDeckType
from .core.common import ModuleCore, LabwareCore, ProtocolCore
Expand Down Expand Up @@ -737,8 +738,8 @@ def move_labware(
if labware._core.is_lid():
location = new_location
else:
raise CommandPreconditionViolated(
"Can only dispose of Lid-type labware and tips in the Trash Bin. Did you mean to use a Waste Chute?"
raise LabwareMovementNotAllowedError(
"Can only dispose of tips and Lid-type labware in a Trash Bin. Did you mean to use a Waste Chute?"
)
else:
location = validation.ensure_and_convert_deck_slot(
Expand Down
2 changes: 1 addition & 1 deletion api/src/opentrons/protocol_engine/commands/move_labware.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ async def execute(self, params: MoveLabwareParams) -> _ExecuteReturn: # noqa: C
trash_lid_drop_offset = LabwareOffsetVector(
x=0,
y=20.0,
z=0,
z=50.0,
)
else:
raise LabwareMovementNotAllowedError(
Expand Down
76 changes: 76 additions & 0 deletions api/tests/opentrons/protocol_api/test_protocol_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
from opentrons.protocols.api_support.deck_type import (
NoTrashDefinedError,
)
from opentrons.protocol_engine.errors import LabwareMovementNotAllowedError
from opentrons.protocol_engine.clients import SyncClient as EngineClient


@pytest.fixture(autouse=True)
Expand Down Expand Up @@ -101,6 +103,12 @@ def api_version() -> APIVersion:
return MAX_SUPPORTED_VERSION


@pytest.fixture
def mock_engine_client(decoy: Decoy) -> EngineClient:
"""Get a mock ProtocolEngine synchronous client."""
return decoy.mock(cls=EngineClient)


@pytest.fixture
def subject(
mock_core: ProtocolCore,
Expand Down Expand Up @@ -944,6 +952,74 @@ def test_move_labware_off_deck_raises(
subject.move_labware(labware=movable_labware, new_location=OFF_DECK)


def test_move_labware_to_trash_raises(
subject: ProtocolContext,
decoy: Decoy,
mock_core: ProtocolCore,
mock_core_map: LoadedCoreMap,
mock_engine_client: EngineClient,
) -> None:
"""It should raise an LabwareMovementNotAllowedError if using move_labware to move something that is not a lid to a TrashBin."""
mock_labware_core = decoy.mock(cls=LabwareCore)
trash_location = TrashBin(
location=DeckSlotName.SLOT_D3,
addressable_area_name="moveableTrashD3",
api_version=MAX_SUPPORTED_VERSION,
engine_client=mock_engine_client,
)

decoy.when(mock_labware_core.get_well_columns()).then_return([])

movable_labware = Labware(
core=mock_labware_core,
api_version=MAX_SUPPORTED_VERSION,
protocol_core=mock_core,
core_map=mock_core_map,
)

with pytest.raises(LabwareMovementNotAllowedError):
subject.move_labware(labware=movable_labware, new_location=trash_location)


def test_move_lid_to_trash_passes(
decoy: Decoy,
mock_core: ProtocolCore,
mock_core_map: LoadedCoreMap,
subject: ProtocolContext,
mock_engine_client: EngineClient,
) -> None:
"""It should move a lid labware into a trashbin successfully."""
mock_labware_core = decoy.mock(cls=LabwareCore)
trash_location = TrashBin(
location=DeckSlotName.SLOT_D3,
addressable_area_name="moveableTrashD3",
api_version=MAX_SUPPORTED_VERSION,
engine_client=mock_engine_client,
)

decoy.when(mock_labware_core.get_well_columns()).then_return([])
decoy.when(mock_labware_core.is_lid()).then_return(True)

movable_labware = Labware(
core=mock_labware_core,
api_version=MAX_SUPPORTED_VERSION,
protocol_core=mock_core,
core_map=mock_core_map,
)

subject.move_labware(labware=movable_labware, new_location=trash_location)
decoy.verify(
mock_core.move_labware(
labware_core=mock_labware_core,
new_location=trash_location,
use_gripper=True,
pause_for_manual_move=True,
pick_up_offset=None,
drop_offset=None,
)
)


def test_load_trash_bin(
decoy: Decoy,
mock_core: ProtocolCore,
Expand Down

0 comments on commit 115957d

Please sign in to comment.