Skip to content

Commit

Permalink
cupla instrument tests
Browse files Browse the repository at this point in the history
  • Loading branch information
caila-marashaj committed Jan 22, 2025
1 parent cd274cc commit b899144
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 13 deletions.
2 changes: 1 addition & 1 deletion api/src/opentrons/protocol_api/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ def validate_location(
A `PointTarget` if the input location is an x, y, z coordinate.
Raises:
NoLocationError: The is no input location and no cached loaction.
NoLocationError: The is no input location and no cached location.
LocationTypeError: The location supplied is of unexpected type.
"""
from .labware import Well
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Test for the ProtocolEngine-based instrument API core."""

from typing import cast, Optional
from typing import cast, Optional, Union, Literal

from opentrons_shared_data.errors.exceptions import PipetteLiquidNotFoundError
import pytest
Expand Down Expand Up @@ -677,11 +677,21 @@ def test_aspirate_from_coordinates(
)


@pytest.mark.parametrize(
("meniscus_target", "expected_volume_offset"),
[
(MeniscusTrackingTarget.BEGINNING, 0.0),
(MeniscusTrackingTarget.END, "operationVolume"),
(MeniscusTrackingTarget.DYNAMIC_MENISCUS, 0.0),
],
)
def test_aspirate_from_meniscus(
decoy: Decoy,
mock_engine_client: EngineClient,
mock_protocol_core: ProtocolCore,
subject: InstrumentCore,
meniscus_target: MeniscusTrackingTarget,
expected_volume_offset: Union[Literal["operationVolume"], float],
) -> None:
"""It should aspirate from a well."""
location = Location(point=Point(1, 2, 3), labware=None)
Expand All @@ -695,14 +705,14 @@ def test_aspirate_from_meniscus(
labware_id="123abc",
well_name="my cool well",
absolute_point=Point(1, 2, 3),
meniscus_tracking=MeniscusTrackingTarget.END,
meniscus_tracking=meniscus_target,
)
).then_return(
(
LiquidHandlingWellLocation(
origin=WellOrigin.MENISCUS,
offset=WellOffset(x=3, y=2, z=1),
volumeOffset="operationVolume",
volumeOffset=expected_volume_offset,
),
False,
)
Expand All @@ -715,7 +725,7 @@ def test_aspirate_from_meniscus(
rate=5.6,
flow_rate=7.8,
in_place=False,
meniscus_tracking=MeniscusTrackingTarget.END,
meniscus_tracking=meniscus_target,
)

decoy.verify(
Expand All @@ -727,7 +737,7 @@ def test_aspirate_from_meniscus(
well_location=LiquidHandlingWellLocation(
origin=WellOrigin.MENISCUS,
offset=WellOffset(x=3, y=2, z=1),
volumeOffset="operationVolume",
volumeOffset=expected_volume_offset,
),
),
mock_engine_client.execute_command(
Expand All @@ -738,7 +748,7 @@ def test_aspirate_from_meniscus(
wellLocation=LiquidHandlingWellLocation(
origin=WellOrigin.MENISCUS,
offset=WellOffset(x=3, y=2, z=1),
volumeOffset="operationVolume",
volumeOffset=expected_volume_offset,
),
volume=12.34,
flowRate=7.8,
Expand Down
17 changes: 14 additions & 3 deletions api/tests/opentrons/protocol_api/test_instrument_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

from opentrons.hardware_control.nozzle_manager import NozzleMap
from opentrons.protocol_api.disposal_locations import TrashBin, WasteChute
from opentrons.types import Location, Mount, Point
from opentrons.types import Location, Mount, Point, MeniscusTrackingTarget

from opentrons_shared_data.pipette.pipette_definition import ValidNozzleMaps
from opentrons_shared_data.errors.exceptions import (
Expand Down Expand Up @@ -386,15 +386,26 @@ def test_aspirate_well_location(
)


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

Expand All @@ -418,7 +429,7 @@ def test_aspirate_meniscus_well_location(
volume=42.0,
rate=1.23,
flow_rate=5.67,
meniscus_tracking=None,
meniscus_tracking=meniscus_target,
),
times=1,
)
Expand Down
16 changes: 13 additions & 3 deletions api/tests/opentrons/protocol_engine/state/test_geometry_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import json
from datetime import datetime
from math import isclose
from typing import cast, List, Tuple, Optional, NamedTuple, Dict
from typing import cast, List, Tuple, Optional, NamedTuple, Dict, Union, Literal
from unittest.mock import sentinel
from os import listdir, path

Expand Down Expand Up @@ -2000,12 +2000,22 @@ def test_get_relative_well_location(
)


@pytest.mark.parametrize(
("meniscus_target", "expected_volume_offset"),
[
(MeniscusTrackingTarget.BEGINNING, 0.0),
(MeniscusTrackingTarget.END, "operationVolume"),
(MeniscusTrackingTarget.DYNAMIC_MENISCUS, 0.0),
],
)
def test_get_relative_liquid_handling_well_location(
decoy: Decoy,
well_plate_def: LabwareDefinition,
mock_labware_view: LabwareView,
mock_addressable_area_view: AddressableAreaView,
subject: GeometryView,
meniscus_target: MeniscusTrackingTarget,
expected_volume_offset: Union[Literal["operationVolume"], float],
) -> None:
"""It should get the relative location of a well given an absolute position."""
(
Expand All @@ -2015,7 +2025,7 @@ def test_get_relative_liquid_handling_well_location(
labware_id="labware-id",
well_name="B2",
absolute_point=Point(x=0, y=0, z=-2),
meniscus_tracking=MeniscusTrackingTarget.END,
meniscus_tracking=meniscus_target,
)

assert result == LiquidHandlingWellLocation(
Expand All @@ -2025,7 +2035,7 @@ def test_get_relative_liquid_handling_well_location(
y=0.0,
z=cast(float, pytest.approx(-2)),
),
volumeOffset="operationVolume",
volumeOffset=expected_volume_offset,
)


Expand Down

0 comments on commit b899144

Please sign in to comment.