Skip to content

Commit

Permalink
fix: fix volume=0 commands
Browse files Browse the repository at this point in the history
  • Loading branch information
DerekMaggio committed Dec 14, 2023
1 parent a7d1187 commit 76cb709
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 4 deletions.
120 changes: 120 additions & 0 deletions api/tests/opentrons/protocol_api/test_instrument_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -990,3 +990,123 @@ def test_configure_nozzle_layout(
"""The correct model is passed to the engine client."""
with exception:
subject.configure_nozzle_layout(style, primary_nozzle, front_right_nozzle)



@pytest.mark.parametrize("api_version", [APIVersion(2, 15)])
def test_dispense_0_volume_means_dispense_everything(
decoy: Decoy,
mock_instrument_core: InstrumentCore,
subject: InstrumentContext,
mock_protocol_core: ProtocolCore,
) -> None:
"""It should dispense all liquid to a well."""
mock_well = decoy.mock(cls=Well)
bottom_location = Location(point=Point(1, 2, 3), labware=mock_well)
input_location = Location(point=Point(2, 2, 2), labware=None)


subject.dispense(volume=0, location=input_location, rate=1.23, push_out=None)

decoy.verify(
mock_instrument_core.dispense(
location=bottom_location,
well_core=mock_well._core,
in_place=False,
volume=mock_instrument_core.get_availabe_volume(),
rate=1.23,
flow_rate=5.67,
push_out=None,
),
times=1,
)

@pytest.mark.parametrize("api_version", [APIVersion(2, 16)])
def test_dispense_0_volume_means_dispense_nothing(
decoy: Decoy,
mock_instrument_core: InstrumentCore,
subject: InstrumentContext,
mock_protocol_core: ProtocolCore,
) -> None:
"""It should dispense no liquid to a well."""
mock_well = decoy.mock(cls=Well)
bottom_location = Location(point=Point(1, 2, 3), labware=mock_well)
input_location = Location(point=Point(2, 2, 2), labware=None)


subject.dispense(volume=0, location=input_location, rate=1.23, push_out=None)

decoy.verify(
mock_instrument_core.dispense(
location=bottom_location,
well_core=mock_well._core,
in_place=False,
volume=0,
rate=1.23,
flow_rate=5.67,
push_out=None,
),
times=1,
)

@pytest.mark.parametrize("api_version", [APIVersion(2, 15)])
def test_aspirate_0_volume_means_aspirate_everything(
decoy: Decoy,
mock_instrument_core: InstrumentCore,
subject: InstrumentContext,
mock_protocol_core: ProtocolCore,
) -> None:
"""It should aspirate to a well."""
mock_well = decoy.mock(cls=Well)
input_location = Location(point=Point(2, 2, 2), labware=mock_well)
last_location = Location(point=Point(9, 9, 9), labware=None)
decoy.when(mock_instrument_core.get_mount()).then_return(Mount.RIGHT)

decoy.when(mock_protocol_core.get_last_location(Mount.RIGHT)).then_return(
last_location
)

subject.aspirate(volume=0, location=input_location, rate=1.23)

decoy.verify(
mock_instrument_core.aspirate(
location=input_location,
well_core=mock_well._core,
in_place=False,
volume=mock_instrument_core.get_available_volume(),
rate=1.23,
flow_rate=5.67,
),
times=1,
)

@pytest.mark.parametrize("api_version", [APIVersion(2, 16)])
def test_aspirate_0_volume_means_aspirate_nothing(
decoy: Decoy,
mock_instrument_core: InstrumentCore,
subject: InstrumentContext,
mock_protocol_core: ProtocolCore,
) -> None:
"""It should aspirate to a well."""
mock_well = decoy.mock(cls=Well)
input_location = Location(point=Point(2, 2, 2), labware=mock_well)
last_location = Location(point=Point(9, 9, 9), labware=None)
decoy.when(mock_instrument_core.get_mount()).then_return(Mount.RIGHT)

decoy.when(mock_protocol_core.get_last_location(Mount.RIGHT)).then_return(
last_location
)

subject.aspirate(volume=0, location=input_location, rate=1.23)

decoy.verify(
mock_instrument_core.aspirate(
location=input_location,
well_core=mock_well._core,
in_place=False,
volume=0,
rate=1.23,
flow_rate=5.67,
),
times=1,
)
8 changes: 4 additions & 4 deletions shared-data/command/schemas/8.json
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@
},
"volume": {
"title": "Volume",
"description": "Amount of liquid in uL. Must be greater than 0 and less than a pipette-specific maximum volume.",
"exclusiveMinimum": 0,
"description": "Amount of liquid in uL. Must be greater than or equal to 0 and less than a pipette-specific maximum volume.",
"minimum": 0,
"type": "number"
},
"pipetteId": {
Expand Down Expand Up @@ -684,8 +684,8 @@
},
"volume": {
"title": "Volume",
"description": "Amount of liquid in uL. Must be greater than 0 and less than a pipette-specific maximum volume.",
"exclusiveMinimum": 0,
"description": "Amount of liquid in uL. Must be greater than or equal to 0 and less than a pipette-specific maximum volume.",
"minimum": 0,
"type": "number"
},
"pipetteId": {
Expand Down

0 comments on commit 76cb709

Please sign in to comment.