diff --git a/api/tests/opentrons/protocol_engine/commands/absorbance_reader/test_initialize.py b/api/tests/opentrons/protocol_engine/commands/absorbance_reader/test_initialize.py index 393e41c259c..5f965f4ab48 100644 --- a/api/tests/opentrons/protocol_engine/commands/absorbance_reader/test_initialize.py +++ b/api/tests/opentrons/protocol_engine/commands/absorbance_reader/test_initialize.py @@ -38,7 +38,7 @@ async def test_absorbance_reader_implementation( params = InitializeParams( moduleId="unverified-module-id", - measureMode=input_measure_mode, + measureMode=input_measure_mode, # type: ignore[arg-type] sampleWavelengths=input_sample_wave_length, ) @@ -75,7 +75,7 @@ async def test_absorbance_reader_implementation( module_id="unverified-module-id", module_type="absorbanceReaderType", initialize_absorbance_reader_update=update_types.AbsorbanceReaderInitializeUpdate( - measure_mode=input_measure_mode, + measure_mode=input_measure_mode, # type: ignore[arg-type] sample_wave_lengths=input_sample_wave_length, reference_wave_length=None, ), diff --git a/api/tests/opentrons/protocol_engine/commands/absorbance_reader/test_read.py b/api/tests/opentrons/protocol_engine/commands/absorbance_reader/test_read.py new file mode 100644 index 00000000000..c8d68368e38 --- /dev/null +++ b/api/tests/opentrons/protocol_engine/commands/absorbance_reader/test_read.py @@ -0,0 +1,71 @@ +"""Test absorbance reader initilize command.""" +import pytest +from decoy import Decoy +from typing import List + +from opentrons.drivers.types import ABSMeasurementMode +from opentrons.hardware_control.modules import AbsorbanceReader + +from opentrons.protocol_engine.execution import EquipmentHandler +from opentrons.protocol_engine.resources import FileProvider +from opentrons.protocol_engine.state import update_types +from opentrons.protocol_engine.state.state import StateView +from opentrons.protocol_engine.state.module_substates import ( + AbsorbanceReaderSubState, + AbsorbanceReaderId, +) +from opentrons.protocol_engine.commands.command import SuccessData +from opentrons.protocol_engine.commands.absorbance_reader import ( + ReadAbsorbanceResult, + ReadAbsorbanceParams, +) +from opentrons.protocol_engine.commands.absorbance_reader.read import ( + ReadAbsorbanceImpl, +) + + +async def test_absorbance_reader_implementation( + decoy: Decoy, + state_view: StateView, + equipment: EquipmentHandler, + file_provider: FileProvider, +) -> None: + """It should validate, find hardware module if not virtualized, and disengage.""" + subject = ReadAbsorbanceImpl( + state_view=state_view, equipment=equipment, file_provider=file_provider + ) + + params = ReadAbsorbanceParams( + moduleId="unverified-module-id", + ) + + mabsorbance_module_substate = decoy.mock(cls=AbsorbanceReaderSubState) + absorbance_module_hw = decoy.mock(cls=AbsorbanceReader) + verified_module_id = AbsorbanceReaderId("module-id") + + decoy.when( + state_view.modules.get_absorbance_reader_substate("unverified-module-id") + ).then_return(mabsorbance_module_substate) + + decoy.when(mabsorbance_module_substate.module_id).then_return(verified_module_id) + + decoy.when(equipment.get_module_hardware_api(verified_module_id)).then_return( + absorbance_module_hw + ) + + result = await subject.execute(params=params) + + decoy.verify( + await absorbance_module_hw.start_measure(), + times=1, + ) + assert result == SuccessData( + public=ReadAbsorbanceResult(), + state_update=update_types.StateUpdate( + module_state_update=update_types.ModuleStateUpdate( + module_id="unverified-module-id", + module_type="absorbanceReaderType", + absorbance_reader_data=update_types.AbsorbanceReaderDataUpdate(), + ) + ), + ) diff --git a/api/tests/opentrons/protocol_engine/commands/conftest.py b/api/tests/opentrons/protocol_engine/commands/conftest.py index 1d27dea0536..cf2d36b092e 100644 --- a/api/tests/opentrons/protocol_engine/commands/conftest.py +++ b/api/tests/opentrons/protocol_engine/commands/conftest.py @@ -15,6 +15,7 @@ TipHandler, GantryMover, ) +from opentrons.protocol_engine.resources import FileProvider from opentrons.protocol_engine.resources.model_utils import ModelUtils from opentrons.protocol_engine.state.state import StateView @@ -83,3 +84,9 @@ def status_bar(decoy: Decoy) -> StatusBarHandler: def gantry_mover(decoy: Decoy) -> GantryMover: """Get a mocked out GantryMover.""" return decoy.mock(cls=GantryMover) + + +@pytest.fixture +def file_provider(decoy: Decoy) -> FileProvider: + """Get a mocked out StateView.""" + return decoy.mock(cls=FileProvider)