diff --git a/tests/plans/test_bimorph.py b/tests/plans/test_bimorph.py new file mode 100644 index 0000000000..77bbdbf341 --- /dev/null +++ b/tests/plans/test_bimorph.py @@ -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