Skip to content

Commit 01ca744

Browse files
tests
1 parent 7ab716a commit 01ca744

File tree

3 files changed

+116
-16
lines changed

3 files changed

+116
-16
lines changed

api/src/opentrons/protocol_engine/commands/aspirate_while_tracking.py

-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ async def execute(self, params: AspirateWhileTrackingParams) -> _ExecuteReturn:
114114
labware_id=params.labwareId,
115115
well_name=params.wellName,
116116
)
117-
118117
move_result = await move_to_well(
119118
movement=self._movement,
120119
model_utils=self._model_utils,

api/tests/opentrons/protocol_engine/commands/test_aspirate_while_tracking.py

+85-15
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
import pytest
66
from decoy import Decoy, matchers
7+
from mock import AsyncMock, patch
8+
from typing import Iterator
79

810
from opentrons_shared_data.errors.exceptions import PipetteOverpressureError
911

@@ -15,6 +17,7 @@
1517
GantryMover,
1618
MovementHandler,
1719
)
20+
from opentrons.protocol_engine.commands.movement_common import move_to_well
1821
from opentrons.protocol_engine.commands.aspirate_while_tracking import (
1922
AspirateWhileTrackingParams,
2023
AspirateWhileTrackingResult,
@@ -36,6 +39,7 @@
3639
WellOrigin,
3740
WellOffset,
3841
DeckPoint,
42+
WellLocation,
3943
)
4044
from opentrons.protocol_engine.state import update_types
4145

@@ -58,6 +62,12 @@ def pipetting(decoy: Decoy) -> PipettingHandler:
5862
return decoy.mock(cls=PipettingHandler)
5963

6064

65+
@pytest.fixture
66+
def movement(decoy: Decoy) -> MovementHandler:
67+
"""Get a mock in the shape of a MovementHandler."""
68+
return decoy.mock(cls=MovementHandler)
69+
70+
6171
@pytest.fixture
6272
def subject(
6373
pipetting: PipettingHandler,
@@ -87,11 +97,11 @@ def subject(
8797
(
8898
CurrentWell(
8999
pipette_id="pipette-id-abc",
90-
labware_id="labware-id-1",
91-
well_name="well-name-1",
100+
labware_id="funky-labware",
101+
well_name="funky-well",
92102
),
93-
"labware-id-1",
94-
"well-name-1",
103+
"funky-labware",
104+
"funky-well",
95105
),
96106
(
97107
CurrentAddressableArea("pipette-id-abc", "addressable-area-1"),
@@ -161,6 +171,26 @@ async def test_aspirate_while_tracking_implementation(
161171

162172
decoy.when(state_store.pipettes.get_current_location()).then_return(location)
163173

174+
_well_location = LiquidHandlingWellLocation(
175+
origin=WellOrigin.MENISCUS, offset=WellOffset(x=0.0, y=0.0, z=1.0)
176+
)
177+
_current_well = CurrentWell(
178+
pipette_id="pipette-id-abc", labware_id="funky-labware", well_name="funky-well"
179+
)
180+
decoy.when(
181+
await subject._movement.move_to_well(
182+
pipette_id="pipette-id-abc",
183+
labware_id="funky-labware",
184+
well_name="funky-well",
185+
well_location=_well_location,
186+
current_well=_current_well,
187+
force_direct=False,
188+
minimum_z_height=None,
189+
speed=None,
190+
operation_volume=-123.0,
191+
),
192+
).then_return(Point(x=4, y=5, z=6))
193+
164194
result = await subject.execute(params=data)
165195

166196
if isinstance(location, CurrentWell):
@@ -272,6 +302,26 @@ async def test_aspirate_raises_volume_error(
272302
)
273303
).then_raise(AssertionError("blah blah"))
274304

305+
_well_location = LiquidHandlingWellLocation(
306+
origin=WellOrigin.MENISCUS, offset=WellOffset(x=0.0, y=0.0, z=1.0)
307+
)
308+
_current_well = CurrentWell(
309+
pipette_id="pipette-id-abc", labware_id="funky-labware", well_name="funky-well"
310+
)
311+
decoy.when(
312+
await subject._movement.move_to_well(
313+
pipette_id="pipette-id-abc",
314+
labware_id="funky-labware",
315+
well_name="funky-well",
316+
well_location=_well_location,
317+
current_well=_current_well,
318+
force_direct=False,
319+
minimum_z_height=None,
320+
speed=None,
321+
operation_volume=-50.0,
322+
),
323+
).then_return(Point(x=4, y=5, z=6))
324+
275325
with pytest.raises(AssertionError):
276326
await subject.execute(data)
277327

@@ -281,15 +331,15 @@ async def test_aspirate_raises_volume_error(
281331
[
282332
(
283333
CurrentWell(
284-
pipette_id="pipette-id",
285-
labware_id="labware-id-1",
286-
well_name="well-name-1",
334+
pipette_id="pipette-id-abc",
335+
labware_id="funky-labware",
336+
well_name="funky-well",
287337
),
288-
"labware-id-1",
289-
"well-name-1",
338+
"funky-labware",
339+
"funky-well",
290340
),
291341
(None, None, None),
292-
(CurrentAddressableArea("pipette-id", "addressable-area-1"), None, None),
342+
(CurrentAddressableArea("pipette-id-abc", "addressable-area-1"), None, None),
293343
],
294344
)
295345
async def test_overpressure_error(
@@ -305,7 +355,7 @@ async def test_overpressure_error(
305355
stateupdateWell: str,
306356
) -> None:
307357
"""It should return an overpressure error if the hardware API indicates that."""
308-
pipette_id = "pipette-id"
358+
pipette_id = "pipette-id-abc"
309359

310360
position = Point(x=1, y=2, z=3)
311361

@@ -315,13 +365,13 @@ async def test_overpressure_error(
315365
state_store.geometry.get_nozzles_per_well(
316366
labware_id=stateupdateLabware,
317367
target_well_name=stateupdateWell,
318-
pipette_id="pipette-id",
368+
pipette_id="pipette-id-abc",
319369
)
320370
).then_return(2)
321371

322372
decoy.when(
323373
state_store.geometry.get_wells_covered_by_pipette_with_active_well(
324-
stateupdateLabware, stateupdateWell, "pipette-id"
374+
stateupdateLabware, stateupdateWell, "pipette-id-abc"
325375
)
326376
).then_return(["A3", "A4"])
327377
well_location = LiquidHandlingWellLocation(
@@ -357,6 +407,26 @@ async def test_overpressure_error(
357407
decoy.when(await gantry_mover.get_position(pipette_id)).then_return(position)
358408
decoy.when(state_store.pipettes.get_current_location()).then_return(location)
359409

410+
_well_location = LiquidHandlingWellLocation(
411+
origin=WellOrigin.MENISCUS, offset=WellOffset(x=0.0, y=0.0, z=1.0)
412+
)
413+
_current_well = CurrentWell(
414+
pipette_id="pipette-id-abc", labware_id="funky-labware", well_name="funky-well"
415+
)
416+
decoy.when(
417+
await subject._movement.move_to_well(
418+
pipette_id=pipette_id,
419+
labware_id="funky-labware",
420+
well_name="funky-well",
421+
well_location=_well_location,
422+
current_well=_current_well,
423+
force_direct=False,
424+
minimum_z_height=None,
425+
speed=None,
426+
operation_volume=-50.0,
427+
),
428+
).then_return(Point(x=4, y=5, z=6))
429+
360430
result = await subject.execute(data)
361431

362432
if isinstance(location, CurrentWell):
@@ -374,7 +444,7 @@ async def test_overpressure_error(
374444
volume_added=update_types.CLEAR,
375445
),
376446
pipette_aspirated_fluid=update_types.PipetteUnknownFluidUpdate(
377-
pipette_id="pipette-id"
447+
pipette_id="pipette-id-abc"
378448
),
379449
),
380450
)
@@ -388,7 +458,7 @@ async def test_overpressure_error(
388458
),
389459
state_update=update_types.StateUpdate(
390460
pipette_aspirated_fluid=update_types.PipetteUnknownFluidUpdate(
391-
pipette_id="pipette-id"
461+
pipette_id="pipette-id-abc"
392462
)
393463
),
394464
)

api/tests/opentrons/protocol_engine/state/test_geometry_view.py

+31
Original file line numberDiff line numberDiff line change
@@ -4299,3 +4299,34 @@ def test_virtual_find_height_and_volume(
42994299
# SimulatedProbeResult
43004300
if isinstance(target_height_volume, SimulatedProbeResult):
43014301
assert height_estimate == volume_estimate == target_height_volume
4302+
4303+
4304+
def test_get_liquid_handling_z_change(
4305+
decoy: Decoy,
4306+
subject: GeometryView,
4307+
mock_labware_view: LabwareView,
4308+
mock_well_view: WellView,
4309+
) -> None:
4310+
decoy.when(mock_labware_view.get_well_definition("labware-id", "A1")).then_return(
4311+
RectangularWellDefinition3.model_construct(totalLiquidVolume=1100000) # type: ignore[call-arg]
4312+
)
4313+
decoy.when(mock_labware_view.get_well_geometry("labware-id", "A1")).then_return(
4314+
_TEST_INNER_WELL_GEOMETRY
4315+
)
4316+
probe_time = datetime.now()
4317+
decoy.when(mock_well_view.get_last_liquid_update("labware-id", "A1")).then_return(
4318+
probe_time
4319+
)
4320+
decoy.when(mock_well_view.get_well_liquid_info("labware-id", "A1")).then_return(
4321+
WellLiquidInfo(
4322+
loaded_volume=None,
4323+
probed_height=ProbedHeightInfo(height=40.0, last_probed=probe_time),
4324+
probed_volume=None,
4325+
)
4326+
)
4327+
# make sure that liquid handling z change math stays the same
4328+
change = subject.get_liquid_handling_z_change(
4329+
labware_id="labware-id", well_name="A1", operation_volume=199.0
4330+
)
4331+
expected_change = 3.2968
4332+
assert isclose(change, expected_change)

0 commit comments

Comments
 (0)