Skip to content

Commit

Permalink
read simple test
Browse files Browse the repository at this point in the history
  • Loading branch information
TamarZanzouri committed Dec 19, 2024
1 parent 238f675 commit 3cf89ba
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ async def execute( # noqa: C901
"Plate Reader data cannot be requested with a module that has not been initialized."
)

state_update.set_absorbance_reader_data(
module_id=params.moduleId, read_result=asbsorbance_result
)
# TODO (cb, 10-17-2024): FILE PROVIDER - Some day we may want to break the file provider behavior into a seperate API function.
# When this happens, we probably will to have the change the command results handler we utilize to track file IDs in engine.
# Today, the action handler for the FileStore looks for a ReadAbsorbanceResult command action, this will need to be delinked.
Expand All @@ -158,10 +161,6 @@ async def execute( # noqa: C901
else "VIRTUAL_SERIAL",
)

state_update.set_absorbance_reader_data(
module_id=params.moduleId, read_result=asbsorbance_result
)

if isinstance(plate_read_result, PlateReaderData):
# Write a CSV file for each of the measurements taken
for measurement in plate_read_result.read_results:
Expand Down
9 changes: 4 additions & 5 deletions api/src/opentrons/protocol_engine/state/update_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,12 +613,11 @@ def set_absorbance_reader_data(
self, module_id: str, read_result: typing.Dict[int, typing.Dict[str, float]]
) -> Self:
"""Update an absorbance reader's read data. See `AbsorbanceReaderReadDataUpdate`."""
# consolidate together

self.module_state_update = ModuleStateUpdate(
module_id=module_id, module_type="absorbanceReaderType"
)
self.absorbance_reader_data = AbsorbanceReaderDataUpdate(
read_result=read_result
module_id=module_id,
module_type="absorbanceReaderType",
absorbance_reader_data=AbsorbanceReaderDataUpdate(read_result=read_result),
)
return self

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""Test absorbance reader initilize command."""
import pytest
from decoy import Decoy
from typing import List
from typing import List, Dict

from opentrons.drivers.types import ABSMeasurementMode
from opentrons.drivers.types import ABSMeasurementMode, ABSMeasurementConfig
from opentrons.hardware_control.modules import AbsorbanceReader

from opentrons.protocol_engine.execution import EquipmentHandler
Expand Down Expand Up @@ -42,6 +42,7 @@ async def test_absorbance_reader_implementation(
mabsorbance_module_substate = decoy.mock(cls=AbsorbanceReaderSubState)
absorbance_module_hw = decoy.mock(cls=AbsorbanceReader)
verified_module_id = AbsorbanceReaderId("module-id")
asbsorbance_result = {1: {"A1": 1.2}}

decoy.when(
state_view.modules.get_absorbance_reader_substate("unverified-module-id")
Expand All @@ -53,19 +54,33 @@ async def test_absorbance_reader_implementation(
absorbance_module_hw
)

decoy.when(await absorbance_module_hw.start_measure()).then_return([[1.2, 1.3]])
decoy.when(absorbance_module_hw._measurement_config).then_return(
ABSMeasurementConfig(
measure_mode=ABSMeasurementMode.SINGLE,
sample_wavelengths=[1, 2],
reference_wavelength=None,
)
)
decoy.when(
state_view.modules.convert_absorbance_reader_data_points([1.2, 1.3])
).then_return({"A1": 1.2})

result = await subject.execute(params=params)

decoy.verify(
await absorbance_module_hw.start_measure(),
times=1,
)
assert result == SuccessData(
public=ReadAbsorbanceResult(),
public=ReadAbsorbanceResult(
data=asbsorbance_result,
fileIds=[],
),
state_update=update_types.StateUpdate(
files_added=update_types.FilesAddedUpdate(file_ids=[]),
module_state_update=update_types.ModuleStateUpdate(
module_id="unverified-module-id",
module_type="absorbanceReaderType",
absorbance_reader_data=update_types.AbsorbanceReaderDataUpdate(),
)
absorbance_reader_data=update_types.AbsorbanceReaderDataUpdate(
read_result=asbsorbance_result
),
),
),
)

0 comments on commit 3cf89ba

Please sign in to comment.