|
| 1 | +"""Test evotip dispense in place commands.""" |
| 2 | +import json |
| 3 | + |
| 4 | +import pytest |
| 5 | +from decoy import Decoy |
| 6 | + |
| 7 | +from opentrons.protocol_engine import ( |
| 8 | + LiquidHandlingWellLocation, |
| 9 | + WellOrigin, |
| 10 | + WellOffset, |
| 11 | + DeckPoint, |
| 12 | +) |
| 13 | +from opentrons.types import Point |
| 14 | +from opentrons.protocol_engine.execution import ( |
| 15 | + PipettingHandler, |
| 16 | + GantryMover, |
| 17 | + MovementHandler, |
| 18 | +) |
| 19 | + |
| 20 | +from opentrons.protocols.models import LabwareDefinition |
| 21 | +from opentrons.protocol_engine.commands.command import SuccessData |
| 22 | +from opentrons.protocol_engine.commands.evotip_dispense import ( |
| 23 | + EvotipDispenseParams, |
| 24 | + EvotipDispenseResult, |
| 25 | + EvotipDispenseImplementation, |
| 26 | +) |
| 27 | +from opentrons.protocol_engine.resources import ModelUtils |
| 28 | +from opentrons.protocol_engine.state.state import StateView |
| 29 | +from opentrons.protocol_engine.state import update_types |
| 30 | + |
| 31 | +from opentrons_shared_data import load_shared_data |
| 32 | + |
| 33 | + |
| 34 | +@pytest.fixture |
| 35 | +def evotips_definition() -> LabwareDefinition: |
| 36 | + """A fixturee of the evotips definition.""" |
| 37 | + # TODO (chb 2025-01-29): When we migrate all labware to v3 we can clean this up |
| 38 | + return LabwareDefinition.model_validate( |
| 39 | + json.loads( |
| 40 | + load_shared_data( |
| 41 | + "labware/definitions/3/evotips_opentrons_96_labware/1.json" |
| 42 | + ) |
| 43 | + ) |
| 44 | + ) |
| 45 | + |
| 46 | + |
| 47 | +@pytest.fixture |
| 48 | +def subject( |
| 49 | + pipetting: PipettingHandler, |
| 50 | + state_view: StateView, |
| 51 | + gantry_mover: GantryMover, |
| 52 | + model_utils: ModelUtils, |
| 53 | + movement: MovementHandler, |
| 54 | + **kwargs: object, |
| 55 | +) -> EvotipDispenseImplementation: |
| 56 | + """Build a command implementation.""" |
| 57 | + return EvotipDispenseImplementation( |
| 58 | + pipetting=pipetting, |
| 59 | + state_view=state_view, |
| 60 | + gantry_mover=gantry_mover, |
| 61 | + model_utils=model_utils, |
| 62 | + movement=movement, |
| 63 | + ) |
| 64 | + |
| 65 | + |
| 66 | +async def test_evotip_dispense_implementation( |
| 67 | + decoy: Decoy, |
| 68 | + movement: MovementHandler, |
| 69 | + gantry_mover: GantryMover, |
| 70 | + pipetting: PipettingHandler, |
| 71 | + state_view: StateView, |
| 72 | + subject: EvotipDispenseImplementation, |
| 73 | + evotips_definition: LabwareDefinition, |
| 74 | +) -> None: |
| 75 | + """It should dispense in place.""" |
| 76 | + well_location = LiquidHandlingWellLocation( |
| 77 | + origin=WellOrigin.TOP, offset=WellOffset(x=0, y=0, z=0) |
| 78 | + ) |
| 79 | + |
| 80 | + data = EvotipDispenseParams( |
| 81 | + pipetteId="pipette-id-abc123", |
| 82 | + labwareId="labware-id-abc123", |
| 83 | + wellName="A3", |
| 84 | + volume=100, |
| 85 | + flowRate=456, |
| 86 | + ) |
| 87 | + |
| 88 | + decoy.when( |
| 89 | + await movement.move_to_well( |
| 90 | + pipette_id="pipette-id-abc123", |
| 91 | + labware_id="labware-id-abc123", |
| 92 | + well_name="A3", |
| 93 | + well_location=well_location, |
| 94 | + current_well=None, |
| 95 | + force_direct=False, |
| 96 | + minimum_z_height=None, |
| 97 | + speed=None, |
| 98 | + operation_volume=None, |
| 99 | + ) |
| 100 | + ).then_return(Point(x=1, y=2, z=3)) |
| 101 | + |
| 102 | + decoy.when(state_view.labware.get_definition("labware-id-abc123")).then_return( |
| 103 | + evotips_definition |
| 104 | + ) |
| 105 | + |
| 106 | + decoy.when( |
| 107 | + await pipetting.dispense_in_place( |
| 108 | + pipette_id="pipette-id-abc123", volume=100.0, flow_rate=456.0, push_out=None |
| 109 | + ) |
| 110 | + ).then_return(100) |
| 111 | + |
| 112 | + decoy.when(await gantry_mover.get_position("pipette-id-abc123")).then_return( |
| 113 | + Point(1, 2, 3) |
| 114 | + ) |
| 115 | + |
| 116 | + result = await subject.execute(data) |
| 117 | + |
| 118 | + assert result == SuccessData( |
| 119 | + public=EvotipDispenseResult(volume=100), |
| 120 | + state_update=update_types.StateUpdate( |
| 121 | + pipette_location=update_types.PipetteLocationUpdate( |
| 122 | + pipette_id="pipette-id-abc123", |
| 123 | + new_location=update_types.Well( |
| 124 | + labware_id="labware-id-abc123", |
| 125 | + well_name="A3", |
| 126 | + ), |
| 127 | + new_deck_point=DeckPoint.model_construct(x=1, y=2, z=3), |
| 128 | + ), |
| 129 | + pipette_aspirated_fluid=update_types.PipetteEjectedFluidUpdate( |
| 130 | + pipette_id="pipette-id-abc123", volume=100 |
| 131 | + ), |
| 132 | + ), |
| 133 | + ) |
0 commit comments