|
5 | 5 | from bluesky import plan_stubs as bps
|
6 | 6 | from bluesky.run_engine import RunEngine
|
7 | 7 | from ophyd_async.core import init_devices, observe_value
|
| 8 | +from ophyd_async.epics.motor import MotorLimitsException |
8 | 9 | from ophyd_async.testing import get_mock_put, set_mock_value
|
9 | 10 |
|
10 | 11 | from dodal.devices.smargon import CombinedMove, DeferMoves, Smargon, StubPosition
|
@@ -87,6 +88,52 @@ async def test_given_center_disp_low_when_stub_offsets_set_to_center_and_moved_t
|
87 | 88 | assert await smargon.stub_offsets.to_robot_load.proc.get_value() == 0
|
88 | 89 |
|
89 | 90 |
|
| 91 | +@pytest.mark.parametrize( |
| 92 | + "test_x, test_y, test_z, test_omega, test_chi, test_phi", |
| 93 | + [ |
| 94 | + (2000, 20, 30, 5, 15, 25), # x goes beyond upper limit |
| 95 | + (-2000, 20, 30, 5, 15, 25), # x goes beyond lower limit |
| 96 | + (10, 2000, 30, 5, 15, 25), # y goes beyond upper limit |
| 97 | + (10, -2000, 30, 5, 15, 25), # y goes beyond lower limit |
| 98 | + (10, 20, 2000, 5, 15, 25), # z goes beyond upper limit |
| 99 | + (10, 20, -2000, 5, 15, 25), # z goes beyond lower limit |
| 100 | + (10, 20, 30, 2000, 15, 25), # omega goes beyond upper limit |
| 101 | + (10, 20, 30, -2000, 15, 25), # omega goes beyond lower limit |
| 102 | + (10, 20, 30, 5, 2000, 25), # chi goes beyond upper limit |
| 103 | + (10, 20, 30, 5, -2000, 25), # chi goes beyond lower limit |
| 104 | + (10, 20, 30, 5, 15, 2000), # phi goes beyond upper limit |
| 105 | + (10, 20, 30, 5, 15, -2000), # phi goes beyond lower limit |
| 106 | + ], |
| 107 | +) |
| 108 | +async def test_given_set_with_value_outside_motor_limit( |
| 109 | + smargon: Smargon, test_x, test_y, test_z, test_omega, test_chi, test_phi |
| 110 | +): |
| 111 | + set_mock_value(smargon.x.low_limit_travel, -1999) |
| 112 | + set_mock_value(smargon.y.low_limit_travel, -1999) |
| 113 | + set_mock_value(smargon.z.low_limit_travel, -1999) |
| 114 | + set_mock_value(smargon.omega.low_limit_travel, -1999) |
| 115 | + set_mock_value(smargon.chi.low_limit_travel, -1999) |
| 116 | + set_mock_value(smargon.phi.low_limit_travel, -1999) |
| 117 | + set_mock_value(smargon.x.high_limit_travel, 1999) |
| 118 | + set_mock_value(smargon.y.high_limit_travel, 1999) |
| 119 | + set_mock_value(smargon.z.high_limit_travel, 1999) |
| 120 | + set_mock_value(smargon.omega.high_limit_travel, 1999) |
| 121 | + set_mock_value(smargon.chi.high_limit_travel, 1999) |
| 122 | + set_mock_value(smargon.phi.high_limit_travel, 1999) |
| 123 | + |
| 124 | + with pytest.raises(MotorLimitsException): |
| 125 | + await smargon.set( |
| 126 | + CombinedMove( |
| 127 | + x=test_x, |
| 128 | + y=test_y, |
| 129 | + z=test_z, |
| 130 | + omega=test_omega, |
| 131 | + chi=test_chi, |
| 132 | + phi=test_phi, |
| 133 | + ) |
| 134 | + ) |
| 135 | + |
| 136 | + |
90 | 137 | async def test_given_set_with_single_value_then_that_motor_moves(smargon: Smargon):
|
91 | 138 | await smargon.set(CombinedMove(x=10))
|
92 | 139 |
|
|
0 commit comments