Skip to content

Commit

Permalink
modify instrument context tests to account for version when using noz…
Browse files Browse the repository at this point in the history
…zle map
  • Loading branch information
CaseyBatten committed Mar 12, 2024
1 parent 38c69ed commit 6940253
Showing 1 changed file with 40 additions and 33 deletions.
73 changes: 40 additions & 33 deletions api/tests/opentrons/protocol_api/test_instrument_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,30 +508,39 @@ def test_blow_out_raises_no_location(
subject.blow_out(location=None)


MOCK_MAP = NozzleMap.build(
physical_nozzles=OrderedDict({"A1": Point(0, 0, 0)}),
physical_rows=OrderedDict({"A": ["A1"]}),
physical_columns=OrderedDict({"1": ["A1"]}),
starting_nozzle="A1",
back_left_nozzle="A1",
front_right_nozzle="A1",
)


@pytest.mark.parametrize(
argnames=["api_version", "mock_map"],
argvalues=[(APIVersion(2, 18), MOCK_MAP), (APIVersion(2, 17), None)],
)
def test_pick_up_tip_from_labware(
decoy: Decoy, mock_instrument_core: InstrumentCore, subject: InstrumentContext
decoy: Decoy,
mock_instrument_core: InstrumentCore,
subject: InstrumentContext,
mock_map: Optional[NozzleMap],
) -> None:
"""It should pick up the next tip from a given labware."""
mock_tip_rack = decoy.mock(cls=Labware)
mock_well = decoy.mock(cls=Well)
top_location = Location(point=Point(1, 2, 3), labware=mock_well)
mock_map = NozzleMap.build(
physical_nozzles=OrderedDict({"A1": Point(0, 0, 0)}),
physical_rows=OrderedDict({"A": ["A1"]}),
physical_columns=OrderedDict({"1": ["A1"]}),
starting_nozzle="A1",
back_left_nozzle="A1",
front_right_nozzle="A1",
)

decoy.when(mock_instrument_core.get_active_channels()).then_return(123)
decoy.when(mock_instrument_core.get_nozzle_map()).then_return(mock_map)
decoy.when(mock_instrument_core.get_nozzle_map()).then_return(MOCK_MAP)
decoy.when(
labware.next_available_tip(
starting_tip=None,
tip_racks=[mock_tip_rack],
channels=123,
nozzle_map=None,
nozzle_map=mock_map,
)
).then_return((mock_tip_rack, mock_well))
decoy.when(mock_well.top()).then_return(top_location)
Expand Down Expand Up @@ -571,31 +580,30 @@ def test_pick_up_tip_from_well_location(
)


@pytest.mark.parametrize(
argnames=["api_version", "mock_map"],
argvalues=[(APIVersion(2, 18), MOCK_MAP), (APIVersion(2, 17), None)],
)
def test_pick_up_tip_from_labware_location(
decoy: Decoy, mock_instrument_core: InstrumentCore, subject: InstrumentContext
decoy: Decoy,
mock_instrument_core: InstrumentCore,
subject: InstrumentContext,
mock_map: Optional[NozzleMap],
) -> None:
"""It should pick up the next tip from a given labware-based Location."""
mock_tip_rack = decoy.mock(cls=Labware)
mock_well = decoy.mock(cls=Well)
location = Location(point=Point(1, 2, 3), labware=mock_tip_rack)
top_location = Location(point=Point(1, 2, 3), labware=mock_well)
mock_map = NozzleMap.build(
physical_nozzles=OrderedDict({"A1": Point(0, 0, 0)}),
physical_rows=OrderedDict({"A": ["A1"]}),
physical_columns=OrderedDict({"1": ["A1"]}),
starting_nozzle="A1",
back_left_nozzle="A1",
front_right_nozzle="A1",
)

decoy.when(mock_instrument_core.get_active_channels()).then_return(123)
decoy.when(mock_instrument_core.get_nozzle_map()).then_return(mock_map)
decoy.when(mock_instrument_core.get_nozzle_map()).then_return(MOCK_MAP)
decoy.when(
labware.next_available_tip(
starting_tip=None,
tip_racks=[mock_tip_rack],
channels=123,
nozzle_map=None,
nozzle_map=mock_map,
)
).then_return((mock_tip_rack, mock_well))
decoy.when(mock_well.top()).then_return(top_location)
Expand All @@ -614,33 +622,32 @@ def test_pick_up_tip_from_labware_location(
)


@pytest.mark.parametrize(
argnames=["api_version", "mock_map"],
argvalues=[(APIVersion(2, 18), MOCK_MAP), (APIVersion(2, 17), None)],
)
def test_pick_up_from_associated_tip_racks(
decoy: Decoy, mock_instrument_core: InstrumentCore, subject: InstrumentContext
decoy: Decoy,
mock_instrument_core: InstrumentCore,
subject: InstrumentContext,
mock_map: Optional[NozzleMap],
) -> None:
"""It should pick up from its associated tip racks."""
mock_tip_rack_1 = decoy.mock(cls=Labware)
mock_tip_rack_2 = decoy.mock(cls=Labware)
mock_starting_tip = decoy.mock(cls=Well)
mock_well = decoy.mock(cls=Well)
top_location = Location(point=Point(1, 2, 3), labware=mock_well)
mock_map = NozzleMap.build(
physical_nozzles=OrderedDict({"A1": Point(0, 0, 0)}),
physical_rows=OrderedDict({"A": ["A1"]}),
physical_columns=OrderedDict({"1": ["A1"]}),
starting_nozzle="A1",
back_left_nozzle="A1",
front_right_nozzle="A1",
)

decoy.when(mock_instrument_core.is_tip_tracking_available()).then_return(True)
decoy.when(mock_instrument_core.get_active_channels()).then_return(123)
decoy.when(mock_instrument_core.get_nozzle_map()).then_return(mock_map)
decoy.when(mock_instrument_core.get_nozzle_map()).then_return(MOCK_MAP)
decoy.when(
labware.next_available_tip(
starting_tip=mock_starting_tip,
tip_racks=[mock_tip_rack_1, mock_tip_rack_2],
channels=123,
nozzle_map=None,
nozzle_map=mock_map,
)
).then_return((mock_tip_rack_2, mock_well))
decoy.when(mock_well.top()).then_return(top_location)
Expand Down

0 comments on commit 6940253

Please sign in to comment.