Skip to content

Commit

Permalink
Add PipettingHandler unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
SyntaxColoring committed Jan 10, 2024
1 parent 1f1d34a commit 26e9a38
Showing 1 changed file with 36 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,15 @@ async def test_virtual_validate_aspirated_volume_raises(

subject = VirtualPipettingHandler(state_view=mock_state_view)

ok_volume = 1.0000000000001
not_ok_volume = 1.01
await subject.aspirate_in_place( # Should not raise.
pipette_id="pipette-id", volume=ok_volume, flow_rate=1
)
with pytest.raises(InvalidAspirateVolumeError):
await subject.aspirate_in_place(pipette_id="pipette-id", volume=4, flow_rate=1)
await subject.aspirate_in_place(
pipette_id="pipette-id", volume=not_ok_volume, flow_rate=1
)


async def test_virtual_blow_out_in_place(
Expand Down Expand Up @@ -393,9 +400,8 @@ async def test_virtual_dispense_in_place_raises_invalid_push_out(
)


@pytest.mark.parametrize("aspirated_volume", [(None), (1)])
async def test_virtual_dispense_in_place_raises_invalid_dispense(
decoy: Decoy, mock_state_view: StateView, aspirated_volume: Optional[float]
async def test_virtual_dispense_in_place_raises_no_tip(
decoy: Decoy, mock_state_view: StateView
) -> None:
"""Should raise an InvalidDispenseVolumeError."""
subject = VirtualPipettingHandler(state_view=mock_state_view)
Expand All @@ -405,7 +411,7 @@ async def test_virtual_dispense_in_place_raises_invalid_dispense(
)

decoy.when(mock_state_view.pipettes.get_aspirated_volume("pipette-id")).then_return(
aspirated_volume
None
)

with pytest.raises(InvalidDispenseVolumeError):
Expand All @@ -414,6 +420,31 @@ async def test_virtual_dispense_in_place_raises_invalid_dispense(
)


async def test_virtual_dispense_in_place_raises_invalid_volume(
decoy: Decoy, mock_state_view: StateView
) -> None:
"""Should raise an InvalidDispenseVolumeError."""
subject = VirtualPipettingHandler(state_view=mock_state_view)

decoy.when(mock_state_view.pipettes.get_attached_tip("pipette-id")).then_return(
TipGeometry(length=1, diameter=2, volume=3)
)

decoy.when(mock_state_view.pipettes.get_aspirated_volume("pipette-id")).then_return(
1
)

ok_volume = 1.0000000000001
not_ok_volume = 1.01
await subject.dispense_in_place(
pipette_id="pipette-id", volume=ok_volume, flow_rate=5, push_out=7
)
with pytest.raises(InvalidDispenseVolumeError):
await subject.dispense_in_place(
pipette_id="pipette-id", volume=not_ok_volume, flow_rate=5, push_out=7
)


async def test_virtual_aspirate_validate_tip_attached(
mock_state_view: StateView, decoy: Decoy
) -> None:
Expand Down

0 comments on commit 26e9a38

Please sign in to comment.