Skip to content

Commit

Permalink
Add test_birmorph.py with test_move_slits
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-fernandes committed Jan 17, 2025
1 parent 9f3b9f7 commit 9782433
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions tests/plans/test_bimorph.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from unittest.mock import ANY

import pytest
from bluesky.run_engine import RunEngine
from bluesky.utils import Msg
from ophyd_async.core import DeviceCollector
from ophyd_async.testing import callback_on_mock_put, set_mock_value

from dodal.devices.slits import Slits
from dodal.plans.bimorph import SlitDimension, move_slits


@pytest.fixture
def slits(RE: RunEngine) -> Slits:
with DeviceCollector(mock=True):
slits = Slits("FAKE-PREFIX:")

for motor in [slits.x_gap, slits.y_gap, slits.x_centre, slits.y_centre]:

def callback(value, wait=False, signal=motor.user_readback):
breakpoint()
set_mock_value(signal, value)

callback_on_mock_put(motor.user_setpoint, callback)
return slits


@pytest.mark.parametrize("dimension", [SlitDimension.X, SlitDimension.Y])
@pytest.mark.parametrize("gap", [1.0])
@pytest.mark.parametrize("center", [2.0])
async def test_move_slits(
slits: Slits,
dimension: SlitDimension,
gap: float,
center: float,
):
messages = list(move_slits(slits, dimension, gap, center))

if dimension == SlitDimension.X:
gap_signal = slits.x_gap
centre_signal = slits.x_centre
else:
gap_signal = slits.y_gap
centre_signal = slits.y_centre

assert [
Msg("set", gap_signal, gap, group=ANY),
Msg("wait", None, group=ANY),
Msg("set", centre_signal, center, group=ANY),
Msg("wait", None, group=ANY),
] == messages

0 comments on commit 9782433

Please sign in to comment.