Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron-kulkarni committed Jul 22, 2024
1 parent 0f7dc8b commit d572ce3
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 12 deletions.
25 changes: 13 additions & 12 deletions api/src/opentrons/protocol_api/instrument_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -1684,18 +1684,6 @@ def tip_racks(self) -> List[labware.Labware]:
def tip_racks(self, racks: List[labware.Labware]) -> None:
self._tip_racks = racks

def _96_tip_config_valid(self) -> bool:
n_map = self._core.get_nozzle_map()
if self.channels == 96:
if (
n_map.back_left != n_map.full_instrument_back_left
and n_map.front_right != n_map.full_instrument_front_right
):
raise TipNotAttachedError(
"Either the front right or the back left nozzle must have a tip attached to do LLD."
)
return True

@property
@requires_version(2, 20)
def liquid_presence_detection(self) -> bool:
Expand Down Expand Up @@ -1888,6 +1876,19 @@ def _get_last_location_by_api_version(self) -> Optional[types.Location]:
else:
return self._protocol_core.get_last_location()

def _96_tip_config_valid(self) -> bool:
n_map = self._core.get_nozzle_map()
channels = self._core.get_active_channels()
if channels == 96:
if (
n_map.back_left != n_map.full_instrument_back_left
and n_map.front_right != n_map.full_instrument_front_right
):
raise TipNotAttachedError(
"Either the front right or the back left nozzle must have a tip attached to do LLD."
)
return True

def __repr__(self) -> str:
return "<{}: {} in {}>".format(
self.__class__.__name__,
Expand Down
59 changes: 59 additions & 0 deletions api/tests/opentrons/protocol_api/test_instrument_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@

from opentrons.legacy_broker import LegacyBroker

from opentrons.protocol_engine.errors.exceptions import TipNotAttachedError
from tests.opentrons.protocol_engine.pipette_fixtures import (
NINETY_SIX_COLS,
NINETY_SIX_MAP,
NINETY_SIX_ROWS,
)
from opentrons.protocols.api_support import instrument as mock_instrument_support
from opentrons.protocols.api_support.types import APIVersion
from opentrons.protocols.api_support.util import (
Expand Down Expand Up @@ -1351,3 +1357,56 @@ def test_measure_liquid_height(
with pytest.raises(ProtocolCommandFailedError) as pcfe:
subject.measure_liquid_height(mock_well)
assert pcfe.value is errorToRaise


def test_96_tip_config_valid(
decoy: Decoy, mock_instrument_core: InstrumentCore, subject: InstrumentContext
) -> None:
"""It should error when there's no tips on the correct corner nozzles."""
nozzle_map = NozzleMap.build(
physical_nozzles=NINETY_SIX_MAP,
physical_rows=NINETY_SIX_ROWS,
physical_columns=NINETY_SIX_COLS,
starting_nozzle="A5",
back_left_nozzle="A5",
front_right_nozzle="H5",
valid_nozzle_maps=ValidNozzleMaps(maps={"Column12": NINETY_SIX_COLS["5"]}),
)
decoy.when(mock_instrument_core.get_nozzle_map()).then_return(nozzle_map)
decoy.when(mock_instrument_core.get_active_channels()).then_return(96)
with pytest.raises(TipNotAttachedError):
subject._96_tip_config_valid()


def test_96_tip_config_invalid(
decoy: Decoy, mock_instrument_core: InstrumentCore, subject: InstrumentContext
) -> None:
"""It should return True when there are tips on the correct corner nozzles."""
nozzle_map = NozzleMap.build(
physical_nozzles=NINETY_SIX_MAP,
physical_rows=NINETY_SIX_ROWS,
physical_columns=NINETY_SIX_COLS,
starting_nozzle="A1",
back_left_nozzle="A1",
front_right_nozzle="H12",
valid_nozzle_maps=ValidNozzleMaps(
maps={
"Full": sum(
[
NINETY_SIX_ROWS["A"],
NINETY_SIX_ROWS["B"],
NINETY_SIX_ROWS["C"],
NINETY_SIX_ROWS["D"],
NINETY_SIX_ROWS["E"],
NINETY_SIX_ROWS["F"],
NINETY_SIX_ROWS["G"],
NINETY_SIX_ROWS["H"],
],
[],
)
}
),
)
decoy.when(mock_instrument_core.get_nozzle_map()).then_return(nozzle_map)
decoy.when(mock_instrument_core.get_active_channels()).then_return(96)
assert subject._96_tip_config_valid() is True

0 comments on commit d572ce3

Please sign in to comment.