Skip to content

Commit

Permalink
raise test wip
Browse files Browse the repository at this point in the history
  • Loading branch information
TamarZanzouri committed Dec 20, 2024
1 parent 773174a commit 66fac26
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async def execute(self, params: CloseLidParams) -> SuccessData[CloseLidResult]:
hardware_lid_status = AbsorbanceReaderLidStatus.OFF
if not self._state_view.config.use_virtual_modules:
abs_reader = self._equipment.get_module_hardware_api(mod_substate.module_id)

print(abs_reader)
if abs_reader is not None:
hardware_lid_status = await abs_reader.get_current_lid_status()
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
)
from opentrons.hardware_control.modules import AbsorbanceReader
from opentrons.protocol_engine import ModuleModel, DeckSlotLocation
from opentrons.protocol_engine.errors import CannotPerformModuleAction

from opentrons.protocol_engine.execution import EquipmentHandler, LabwareMovementHandler
from opentrons.protocol_engine.state import update_types
Expand Down Expand Up @@ -47,23 +48,31 @@ def absorbance_def() -> LabwareDefinition:
)


@pytest.fixture
def subject(
state_view: StateView,
equipment: EquipmentHandler,
labware_movement: LabwareMovementHandler,
) -> CloseLidImpl:
"""Subject fixture."""
return CloseLidImpl(
state_view=state_view, equipment=equipment, labware_movement=labware_movement
)


@pytest.mark.parametrize(
"hardware_lid_status",
(AbsorbanceReaderLidStatus.ON, AbsorbanceReaderLidStatus.OFF),
)
async def test_absorbance_reader_implementation(
async def test_absorbance_reader_close_lid_implementation(
decoy: Decoy,
subject: CloseLidImpl,
state_view: StateView,
equipment: EquipmentHandler,
labware_movement: LabwareMovementHandler,
hardware_lid_status: AbsorbanceReaderLidStatus,
absorbance_def: LabwareDefinition,
) -> None:
"""It should validate, find hardware module if not virtualized, and disengage."""
subject = CloseLidImpl(
state_view=state_view, equipment=equipment, labware_movement=labware_movement
)

"""It should validate, find hardware module if not virtualized, and close lid."""
params = CloseLidParams(
moduleId="unverified-module-id",
)
Expand Down Expand Up @@ -129,3 +138,25 @@ async def test_absorbance_reader_implementation(
),
),
)


async def test_close_lid_raises_no_module(decoy: Decoy, state_view: StateView, equipment: EquipmentHandler, subject: CloseLidImpl) -> None:
"""Should raise an error that the hardware module not found."""
params = CloseLidParams(
moduleId="unverified-module-id",
)

mabsorbance_module_substate = decoy.mock(cls=AbsorbanceReaderSubState)
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(
None
)
with pytest.raises(CannotPerformModuleAction):
await subject.execute(params=params)

0 comments on commit 66fac26

Please sign in to comment.