Skip to content

Commit 38f8f20

Browse files
committed
unit test and error raise for blowout location
1 parent 2862106 commit 38f8f20

File tree

2 files changed

+42
-10
lines changed

2 files changed

+42
-10
lines changed

api/src/opentrons/protocol_api/core/engine/instrument.py

+11
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from opentrons_shared_data.errors.exceptions import (
3939
UnsupportedHardwareCommand,
4040
)
41+
from opentrons_shared_data.liquid_classes.liquid_class_definition import BlowoutLocation
4142
from opentrons.protocol_api._nozzle_layout import NozzleLayout
4243
from . import overlap_versions, pipette_movement_conflict
4344
from . import transfer_components_executor as tx_comps_executor
@@ -1246,6 +1247,16 @@ def consolidate_liquid( # noqa: C901
12461247
transfer_props = liquid_class.get_for(
12471248
pipette=self.get_pipette_name(), tip_rack=tiprack_uri_for_transfer_props
12481249
)
1250+
blow_out_properties = transfer_props.dispense.retract.blowout
1251+
if (
1252+
blow_out_properties.enabled
1253+
and blow_out_properties.location == BlowoutLocation.SOURCE
1254+
):
1255+
raise RuntimeError(
1256+
'Blowout location "source" incompatible with consolidate liquid.'
1257+
' Please choose "destination" or "trash".'
1258+
)
1259+
12491260
# TODO: use the ID returned by load_liquid_class in command annotations
12501261
self.load_liquid_class(
12511262
name=liquid_class.name,

api/tests/opentrons/protocol_api/test_instrument_context.py

+31-10
Original file line numberDiff line numberDiff line change
@@ -2350,16 +2350,6 @@ def test_consolidate_liquid_raises_if_tip_has_liquid(
23502350
decoy.when(mock_validation.ensure_new_tip_policy("never")).then_return(
23512351
TransferTipPolicyV2.ONCE
23522352
)
2353-
decoy.when(mock_instrument_core.get_nozzle_map()).then_return(MOCK_MAP)
2354-
decoy.when(mock_instrument_core.get_active_channels()).then_return(2)
2355-
decoy.when(
2356-
labware.next_available_tip(
2357-
starting_tip=None,
2358-
tip_racks=tip_racks,
2359-
channels=2,
2360-
nozzle_map=MOCK_MAP,
2361-
)
2362-
).then_return((decoy.mock(cls=Labware), decoy.mock(cls=Well)))
23632353
decoy.when(mock_instrument_core.get_current_volume()).then_return(1000)
23642354
with pytest.raises(RuntimeError, match="liquid already in the tip"):
23652355
subject.consolidate_liquid(
@@ -2371,6 +2361,37 @@ def test_consolidate_liquid_raises_if_tip_has_liquid(
23712361
)
23722362

23732363

2364+
@pytest.mark.parametrize("robot_type", ["OT-2 Standard", "OT-3 Standard"])
2365+
def test_consolidate_liquid_raises_if_tip_policy_per_source(
2366+
decoy: Decoy,
2367+
mock_protocol_core: ProtocolCore,
2368+
mock_instrument_core: InstrumentCore,
2369+
subject: InstrumentContext,
2370+
robot_type: RobotType,
2371+
minimal_liquid_class_def2: LiquidClassSchemaV1,
2372+
) -> None:
2373+
"""It should raise errors if the tip policy is "per source"."""
2374+
test_liq_class = LiquidClass.create(minimal_liquid_class_def2)
2375+
mock_well = decoy.mock(cls=Well)
2376+
2377+
decoy.when(
2378+
mock_validation.ensure_valid_flat_wells_list_for_transfer_v2([mock_well])
2379+
).then_return([mock_well])
2380+
decoy.when(mock_validation.ensure_new_tip_policy("per source")).then_return(
2381+
TransferTipPolicyV2.PER_SOURCE
2382+
)
2383+
with pytest.raises(
2384+
RuntimeError, match='"per source" incompatible with consolidate.'
2385+
):
2386+
subject.consolidate_liquid(
2387+
liquid_class=test_liq_class,
2388+
volume=10,
2389+
source=[mock_well],
2390+
dest=mock_well,
2391+
new_tip="per source",
2392+
)
2393+
2394+
23742395
@pytest.mark.parametrize("robot_type", ["OT-2 Standard", "OT-3 Standard"])
23752396
def test_consolidate_liquid_delegates_to_engine_core(
23762397
decoy: Decoy,

0 commit comments

Comments
 (0)