Skip to content

Commit

Permalink
Tidy up some code that wasn't being properly tested
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicOram committed Nov 29, 2024
1 parent 94e38cd commit d31bf9b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
7 changes: 0 additions & 7 deletions src/dodal/devices/aperture.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,3 @@ def __init__(self, prefix: str, name: str = "") -> None:
self.medium = epics_signal_r(float, prefix + "Y:MEDIUM_CALC")
self.large = epics_signal_r(float, prefix + "Y:LARGE_CALC")
super().__init__(name)

async def in_position(self):
return (
await self.small.get_value()
or await self.medium.get_value()
or await self.large.get_value()
)
10 changes: 5 additions & 5 deletions system_tests/test_aperturescatterguard_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async def test_aperturescatterguard_move_in_plan(
assert ap_sg._loaded_positions is not None
large = ap_sg._loaded_positions[ApertureValue.LARGE]

await ap_sg.aperture.z.set(large.aperture_z)
await ap_sg._aperture.z.set(large.aperture_z)

RE(move_to_large)
RE(move_to_medium)
Expand All @@ -91,7 +91,7 @@ async def test_aperturescatterguard_move_in_plan(
async def test_move_fails_when_not_in_good_starting_pos(
ap_sg: ApertureScatterguard, move_to_large, RE
):
await ap_sg.aperture.z.set(0)
await ap_sg._aperture.z.set(0)

with pytest.raises(InvalidApertureMove):
RE(move_to_large)
Expand Down Expand Up @@ -148,12 +148,12 @@ async def test_aperturescatterguard_moves_in_correct_order(
RE = RunEngine({})
RE.subscribe(cb)

await ap_sg.aperture.z.set(pos1.aperture_z)
await ap_sg._aperture.z.set(pos1.aperture_z)

def monitor_and_moves():
yield from bps.open_run()
yield from bps.monitor(ap_sg.aperture.y.motor_done_move, name="ap_y")
yield from bps.monitor(ap_sg.scatterguard.y.motor_done_move, name="sg_y")
yield from bps.monitor(ap_sg._aperture.y.motor_done_move, name="ap_y")
yield from bps.monitor(ap_sg._scatterguard.y.motor_done_move, name="sg_y")
yield from bps.mv(ap_sg, pos1) # type: ignore # See: https://github.com/DiamondLightSource/dodal/issues/827
yield from bps.mv(ap_sg, pos2) # type: ignore # See: https://github.com/DiamondLightSource/dodal/issues/827
yield from bps.close_run()
Expand Down
11 changes: 8 additions & 3 deletions tests/devices/unit_tests/test_aperture_scatterguard.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,6 @@ async def test_aperture_positions_robot_load_unsafe(
await ap_sg.read()


@pytest.mark.skip(
"Curently not working, see https://github.com/DiamondLightSource/dodal/issues/782"
)
async def test_given_aperture_not_set_through_device_but_motors_in_position_when_device_read_then_position_returned(
aperture_in_medium_pos: ApertureScatterguard,
aperture_positions: dict[ApertureValue, AperturePosition],
Expand Down Expand Up @@ -501,3 +498,11 @@ async def test_given_out_and_aperture_selected_when_move_in_then_correct_y_selec
await ap_sg.set(selected_aperture)
await assert_all_positions_other_than_y(ap_sg, aperture_position)
assert await y_setpoint.get_value() == aperture_position.aperture_y


async def test_given_aperture_z_still_moving_when_aperture_scatterguard_moved_then_raises(
ap_sg: ApertureScatterguard,
):
set_mock_value(ap_sg._aperture.z.motor_done_move, 0)
with pytest.raises(InvalidApertureMove):
await ap_sg.set(ApertureValue.SMALL)

0 comments on commit d31bf9b

Please sign in to comment.