Skip to content

Commit

Permalink
added tests for raising
Browse files Browse the repository at this point in the history
  • Loading branch information
TamarZanzouri committed Dec 23, 2024
1 parent 66fac26 commit 73b249e
Showing 1 changed file with 64 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,45 @@ async def test_absorbance_reader_close_lid_implementation(
)


async def test_close_lid_raises_no_module(decoy: Decoy, state_view: StateView, equipment: EquipmentHandler, subject: CloseLidImpl) -> None:
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(state_view.config.use_virtual_modules).then_return(False)
decoy.when(equipment.get_module_hardware_api(verified_module_id)).then_return(None)
with pytest.raises(CannotPerformModuleAction):
await subject.execute(params=params)


async def test_close_lid_raises_no_gripper_offset(
decoy: Decoy,
state_view: StateView,
equipment: EquipmentHandler,
subject: CloseLidImpl,
absorbance_def: LabwareDefinition,
) -> None:
"""Should raise an error that the hardware module not found."""
params = CloseLidParams(
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(
Expand All @@ -156,7 +188,35 @@ async def test_close_lid_raises_no_module(decoy: Decoy, state_view: StateView, e
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
absorbance_module_hw
)
with pytest.raises(CannotPerformModuleAction):
await subject.execute(params=params)

decoy.when(await absorbance_module_hw.get_current_lid_status()).then_return(
AbsorbanceReaderLidStatus.OFF
)
decoy.when(state_view.modules.get_requested_model(params.moduleId)).then_return(
ModuleModel.ABSORBANCE_READER_V1
)

decoy.when(state_view.labware.get_absorbance_reader_lid_definition()).then_return()

decoy.when(state_view.modules.get_location(params.moduleId)).then_return(
DeckSlotLocation(slotName=DeckSlotName.SLOT_D3)
)
decoy.when(
state_view.modules.ensure_and_convert_module_fixture_location(
DeckSlotName.SLOT_D3, ModuleModel.ABSORBANCE_READER_V1
)
).then_return("absorbanceReaderV1D3")

decoy.when(state_view.labware.get_absorbance_reader_lid_definition()).then_return(
absorbance_def
)
decoy.when(
state_view.labware.get_child_gripper_offsets(
labware_definition=absorbance_def,
slot_name=None,
)
).then_return(None)
with pytest.raises(ValueError):
await subject.execute(params=params)

0 comments on commit 73b249e

Please sign in to comment.