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): disallow moving a fixed-trash labware #13534

Merged
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
5 changes: 5 additions & 0 deletions api/src/opentrons/protocol_engine/commands/move_labware.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ async def execute(self, params: MoveLabwareParams) -> MoveLabwareResult:
)
definition_uri = current_labware.definitionUri

if self._state_view.labware.is_fixed_trash(params.labwareId):
raise LabwareMovementNotAllowedError(
f"Cannot move fixed trash labware '{current_labware_definition.parameters.loadName}'."
)

available_new_location = self._state_view.geometry.ensure_location_not_occupied(
location=params.newLocation
)
Expand Down
49 changes: 49 additions & 0 deletions api/tests/opentrons/protocol_engine/commands/test_move_labware.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,3 +531,52 @@ async def test_move_labware_with_gripper_raises_on_ot2(
)
with pytest.raises(errors.NotSupportedOnRobotType):
await subject.execute(data)


async def test_move_labware_raises_when_moving_fixed_trash_labware(
decoy: Decoy,
equipment: EquipmentHandler,
labware_movement: LabwareMovementHandler,
state_view: StateView,
run_control: RunControlHandler,
) -> None:
"""It should raise an error when trying to move a fixed trash."""
subject = MoveLabwareImplementation(
state_view=state_view,
equipment=equipment,
labware_movement=labware_movement,
run_control=run_control,
)

data = MoveLabwareParams(
labwareId="my-cool-labware-id",
newLocation=DeckSlotLocation(slotName=DeckSlotName.FIXED_TRASH),
strategy=LabwareMovementStrategy.USING_GRIPPER,
)

definition = LabwareDefinition.construct( # type: ignore[call-arg]
parameters=Parameters.construct(loadName="My cool labware", quirks=["fixedTrash"]), # type: ignore[call-arg]
)

decoy.when(state_view.labware.get(labware_id="my-cool-labware-id")).then_return(
LoadedLabware(
id="my-cool-labware-id",
loadName="load-name",
definitionUri="opentrons-test/load-name/1",
location=DeckSlotLocation(slotName=DeckSlotName.SLOT_4),
offsetId=None,
)
)
decoy.when(
state_view.labware.get_definition(labware_id="my-cool-labware-id")
).then_return(definition)

decoy.when(state_view.labware.is_fixed_trash("my-cool-labware-id")).then_return(
True
)

with pytest.raises(
errors.LabwareMovementNotAllowedError,
match="Cannot move fixed trash labware 'My cool labware'.",
):
await subject.execute(data)