Skip to content

Commit

Permalink
Add InstrumentCore tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
SyntaxColoring committed Jan 10, 2024
1 parent 3c83d90 commit fc9e39b
Showing 1 changed file with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
DropTipWellLocation,
DropTipWellOrigin,
)
from opentrons.protocol_engine.clients.sync_client import SyncClient
from opentrons.protocol_engine.errors.exceptions import TipNotAttachedError
from opentrons.protocol_engine.clients import SyncClient as EngineClient
from opentrons.protocol_engine.types import (
Expand All @@ -36,6 +37,8 @@
ProtocolCore,
deck_conflict,
)
from opentrons.protocols.api_support.definitions import MAX_SUPPORTED_VERSION
from opentrons.protocols.api_support.types import APIVersion
from opentrons.types import Location, Mount, MountType, Point


Expand Down Expand Up @@ -600,6 +603,8 @@ def test_dispense_to_well(
name="my cool well", labware_id="123abc", engine_client=mock_engine_client
)

decoy.when(mock_protocol_core.api_version).then_return(MAX_SUPPORTED_VERSION)

decoy.when(
mock_engine_client.state.geometry.get_relative_well_location(
labware_id="123abc", well_name="my cool well", absolute_point=Point(1, 2, 3)
Expand Down Expand Up @@ -648,6 +653,7 @@ def test_dispense_in_place(
subject: InstrumentCore,
) -> None:
"""It should dispense in place."""
decoy.when(mock_protocol_core.api_version).then_return(MAX_SUPPORTED_VERSION)
location = Location(point=Point(1, 2, 3), labware=None)
subject.dispense(
volume=12.34,
Expand All @@ -673,6 +679,7 @@ def test_dispense_to_coordinates(
subject: InstrumentCore,
) -> None:
"""It should dispense in place."""
decoy.when(mock_protocol_core.api_version).then_return(MAX_SUPPORTED_VERSION)
location = Location(point=Point(1, 2, 3), labware=None)
subject.dispense(
volume=12.34,
Expand All @@ -698,6 +705,51 @@ def test_dispense_to_coordinates(
)


@pytest.mark.parametrize(
("api_version", "expect_clampage"),
[(APIVersion(2, 16), True), (APIVersion(2, 17), False)],
)
def test_dispense_conditionally_clamps_volume(
api_version: APIVersion,
expect_clampage: bool,
decoy: Decoy,
subject: InstrumentCore,
mock_protocol_core: ProtocolCore,
mock_engine_client: SyncClient,
) -> None:
"""It should clamp the dispensed volume to the available volume on older API versions."""
decoy.when(mock_protocol_core.api_version).then_return(api_version)
decoy.when(
mock_engine_client.state.pipettes.get_aspirated_volume(subject.pipette_id)
).then_return(111.111)

subject.dispense(
volume=99999999.99999999,
rate=5.6,
flow_rate=7.8,
well_core=None,
location=Location(point=Point(1, 2, 3), labware=None),
in_place=True,
push_out=None,
)

if expect_clampage:
decoy.verify(
mock_engine_client.dispense_in_place(
pipette_id="abc123", volume=111.111, flow_rate=7.8, push_out=None
),
)
else:
decoy.verify(
mock_engine_client.dispense_in_place(
pipette_id="abc123",
volume=99999999.99999999,
flow_rate=7.8,
push_out=None,
),
)


def test_initialization_sets_default_movement_speed(
decoy: Decoy,
subject: InstrumentCore,
Expand Down

0 comments on commit fc9e39b

Please sign in to comment.