|
4 | 4 |
|
5 | 5 | import pytest |
6 | 6 | from ophyd_async.core import init_devices |
| 7 | +from ophyd_async.testing import get_mock_put |
7 | 8 |
|
8 | 9 | from dodal.common.beamlines.beamline_parameters import GDABeamlineParameters |
9 | 10 | from dodal.devices.aperturescatterguard import ApertureScatterguard, ApertureValue |
@@ -40,6 +41,8 @@ async def scintillator_and_ap_sg( |
40 | 41 | with ExitStack() as motor_patch_stack: |
41 | 42 | for motor in [scintillator.y_mm, scintillator.z_mm]: |
42 | 43 | motor_patch_stack.enter_context(patch_motor(motor)) |
| 44 | + await scintillator.y_mm.set(5) |
| 45 | + await scintillator.z_mm.set(5) |
43 | 46 | yield scintillator, mock_ap_sg |
44 | 47 |
|
45 | 48 |
|
@@ -95,3 +98,20 @@ async def test_given_aperture_scatterguard_not_parked_when_set_to_out_position_t |
95 | 98 |
|
96 | 99 | with pytest.raises(ValueError): |
97 | 100 | await scintillator.selected_pos.set(InOut.OUT) |
| 101 | + |
| 102 | + |
| 103 | +async def test_given_scintillator_already_out_when_moved_out_then_does_nothing( |
| 104 | + scintillator_and_ap_sg: tuple[Scintillator, ApertureScatterguard], |
| 105 | +): |
| 106 | + scintillator, ap_sg = scintillator_and_ap_sg |
| 107 | + await scintillator.y_mm.set(0) |
| 108 | + await scintillator.z_mm.set(0) |
| 109 | + |
| 110 | + get_mock_put(scintillator.y_mm.user_setpoint).reset_mock() |
| 111 | + get_mock_put(scintillator.z_mm.user_setpoint).reset_mock() |
| 112 | + |
| 113 | + ap_sg.return_value.selected_aperture.get_value.return_value = ApertureValue.LARGE # type: ignore |
| 114 | + await scintillator.selected_pos.set(InOut.OUT) |
| 115 | + |
| 116 | + get_mock_put(scintillator.y_mm.user_setpoint).assert_not_called() |
| 117 | + get_mock_put(scintillator.z_mm.user_setpoint).assert_not_called() |
0 commit comments