Skip to content

Commit 5ed3646

Browse files
authored
Hutch shutter raises an error on Open if not safe (#1285)
* Just a thought to get around I19 testing issue * Shutter only raise error for hutch not safe on open * Fix test * Add small test
1 parent e127570 commit 5ed3646

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

src/dodal/devices/hutch_shutter.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@ def __init__(self, prefix: str, name: str = "") -> None:
8181

8282
@AsyncStatus.wrap
8383
async def set(self, value: ShutterDemand):
84-
interlock_state = await self.interlock.shutter_safe_to_operate()
85-
if not interlock_state and not TEST_MODE:
86-
# If not in test mode, fail. If in test mode, the optics hutch may be open.
87-
raise ShutterNotSafeToOperateError(
88-
"The hutch has not been locked, not operating shutter."
89-
)
9084
if not TEST_MODE:
9185
if value == ShutterDemand.OPEN:
86+
interlock_state = await self.interlock.shutter_safe_to_operate()
87+
if not interlock_state:
88+
# If not in test mode, fail. If in test mode, the optics hutch may be open.
89+
raise ShutterNotSafeToOperateError(
90+
"The hutch has not been locked, not operating shutter."
91+
)
9292
await self.control.set(ShutterDemand.RESET, wait=True)
9393
await self.control.set(value, wait=True)
9494
return await wait_for_value(

tests/devices/unit_tests/test_hutch_shutter.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,23 @@ def test_shutter_can_be_created(fake_shutter: HutchShutter):
3535
assert isinstance(fake_shutter, HutchShutter)
3636

3737

38-
async def test_shutter_raises_error_on_set_if_hutch_not_interlocked(
38+
async def test_shutter_raises_error_on_set_if_hutch_not_interlocked_on_open(
3939
fake_shutter: HutchShutter,
4040
):
4141
set_mock_value(fake_shutter.interlock.status, 1)
4242
assert await fake_shutter.interlock.shutter_safe_to_operate() is False
4343

4444
with pytest.raises(ShutterNotSafeToOperateError):
45-
await fake_shutter.set(ShutterDemand.CLOSE)
45+
await fake_shutter.set(ShutterDemand.OPEN)
46+
47+
48+
async def test_shutter_does_not_error_on_close_even_if_hutch_not_interlocked(
49+
fake_shutter: HutchShutter,
50+
):
51+
set_mock_value(fake_shutter.interlock.status, 1)
52+
assert await fake_shutter.interlock.shutter_safe_to_operate() is False
53+
54+
await fake_shutter.set(ShutterDemand.CLOSE)
4655

4756

4857
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)