From c3cc384ca757174496850466c0f67c98fbc012b6 Mon Sep 17 00:00:00 2001 From: Sanniti Date: Thu, 19 Dec 2024 13:33:23 -0500 Subject: [PATCH] monkeypatch the class instead of getter --- .../protocol_api/core/engine/instrument.py | 4 ++-- .../engine/transfer_components_executor.py | 19 ------------------- .../core/engine/test_instrument_core.py | 7 ++++--- 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/api/src/opentrons/protocol_api/core/engine/instrument.py b/api/src/opentrons/protocol_api/core/engine/instrument.py index acf35ca8014..5769d5908ad 100644 --- a/api/src/opentrons/protocol_api/core/engine/instrument.py +++ b/api/src/opentrons/protocol_api/core/engine/instrument.py @@ -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, @@ -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, diff --git a/api/src/opentrons/protocol_api/core/engine/transfer_components_executor.py b/api/src/opentrons/protocol_api/core/engine/transfer_components_executor.py index 02a78517150..e564fb7df4a 100644 --- a/api/src/opentrons/protocol_api/core/engine/transfer_components_executor.py +++ b/api/src/opentrons/protocol_api/core/engine/transfer_components_executor.py @@ -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, diff --git a/api/tests/opentrons/protocol_api/core/engine/test_instrument_core.py b/api/tests/opentrons/protocol_api/core/engine/test_instrument_core.py index 8bb9f95e35e..b2fc7a9cccd 100644 --- a/api/tests/opentrons/protocol_api/core/engine/test_instrument_core.py +++ b/api/tests/opentrons/protocol_api/core/engine/test_instrument_core.py @@ -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, @@ -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),