-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test_birmorph.py with test_move_slits
- Loading branch information
1 parent
9f3b9f7
commit 9782433
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |