Skip to content

Commit

Permalink
monkeypatch the class instead of getter
Browse files Browse the repository at this point in the history
  • Loading branch information
sanni-t committed Dec 19, 2024
1 parent 40dd2e9 commit c3cc384
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 24 deletions.
4 changes: 2 additions & 2 deletions api/src/opentrons/protocol_api/core/engine/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ def aspirate_liquid_class(
liquid=0,
air_gap=0,
)
components_executor = tx_comps_executor.get_transfer_components_executor(
components_executor = tx_comps_executor.TransferComponentsExecutor(
instrument_core=self,
transfer_properties=transfer_properties,
target_location=aspirate_location,
Expand Down Expand Up @@ -1092,7 +1092,7 @@ def dispense_liquid_class(
liquid=0,
air_gap=0,
)
components_executor = tx_comps_executor.get_transfer_components_executor(
components_executor = tx_comps_executor.TransferComponentsExecutor(
instrument_core=self,
transfer_properties=transfer_properties,
target_location=dispense_location,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,25 +506,6 @@ def _remove_air_gap(self, location: Location) -> None:
self._instrument.delay(dispense_delay.duration)


def get_transfer_components_executor(
instrument_core: InstrumentCore,
transfer_properties: TransferProperties,
target_location: Location,
target_well: WellCore,
tip_state: TipState,
transfer_type: TransferType,
) -> TransferComponentsExecutor:
"""Get a TransferComponentsExecutor."""
return TransferComponentsExecutor(
instrument_core=instrument_core,
transfer_properties=transfer_properties,
target_location=target_location,
target_well=target_well,
tip_state=tip_state,
transfer_type=transfer_type,
)


def absolute_point_from_position_reference_and_offset(
well: WellCore,
position_reference: PositionReference,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,13 @@ def mock_transfer_components_executor(
def patch_mock_transfer_components_executor(
decoy: Decoy,
monkeypatch: pytest.MonkeyPatch,
mock_transfer_components_executor: TransferComponentsExecutor,
) -> None:
"""Replace transfer_components_executor functions with mocks."""
monkeypatch.setattr(
transfer_components_executor,
"get_transfer_components_executor",
decoy.mock(func=transfer_components_executor.get_transfer_components_executor),
"TransferComponentsExecutor",
mock_transfer_components_executor,
)
monkeypatch.setattr(
transfer_components_executor,
Expand Down Expand Up @@ -1616,7 +1617,7 @@ def test_aspirate_liquid_class(
)
).then_return(Point(1, 2, 3))
decoy.when(
transfer_components_executor.get_transfer_components_executor(
transfer_components_executor.TransferComponentsExecutor(
instrument_core=subject,
transfer_properties=test_transfer_properties,
target_location=Location(Point(1, 2, 3), labware=None),
Expand Down

0 comments on commit c3cc384

Please sign in to comment.