Skip to content

Commit

Permalink
Add aborted test
Browse files Browse the repository at this point in the history
  • Loading branch information
noemifrisina committed Jul 12, 2024
1 parent bd139c9 commit 45f6827
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,7 @@ def run_main_extruder_plan(
ABORTED = False


def run_aborted_plan(
zebra: Zebra, shutter: HutchShutter, detector_name: str
) -> MsgGenerator:
def run_aborted_plan(zebra: Zebra, detector_name: str) -> MsgGenerator:
"""A plan to tidy up things in case the collection is aborted before the end."""
global ABORTED
ABORTED = True
Expand All @@ -393,7 +391,6 @@ def run_aborted_plan(
elif detector_name == "eiger":
caput(pv.eiger_acquire, 0)
sleep(1.0)
yield from bps.null()


def tidy_up_at_collection_end_plan(
Expand All @@ -402,7 +399,7 @@ def tidy_up_at_collection_end_plan(
parameters: ExtruderParameters,
dcid: DCID,
) -> MsgGenerator:
"""A plan to tidy up at the end of a collection.
"""A plan to tidy up at the end of a collection, successful or aborted.
Args:
zebra (Zebra): The Zebra device.
Expand Down Expand Up @@ -478,7 +475,7 @@ def run_extruder_plan(
start_time,
),
except_plan=lambda e: (
yield from run_aborted_plan(zebra, shutter, parameters.detector_name)
yield from run_aborted_plan(zebra, parameters.detector_name)
), # TODO complete
final_plan=lambda: (
yield from tidy_up_at_collection_end_plan(zebra, shutter, parameters, dcid)
Expand Down
11 changes: 11 additions & 0 deletions tests/I24/serial/extruder/test_extruder_collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
enter_hutch,
initialise_extruder,
laser_check,
run_aborted_plan,
run_main_extruder_plan,
tidy_up_at_collection_end_plan,
)
Expand Down Expand Up @@ -254,3 +255,13 @@ def test_tidy_up_at_collection_end_plan_with_eiger(
fake_caput.assert_has_calls(call_list)

fake_sup.eiger.assert_called_once_with("return-to-normal")


@patch("mx_bluesky.I24.serial.extruder.i24ssx_Extruder_Collect_py3v2.sleep")
@patch("mx_bluesky.I24.serial.extruder.i24ssx_Extruder_Collect_py3v2.caput")
@patch("mx_bluesky.I24.serial.extruder.i24ssx_Extruder_Collect_py3v2.disarm_zebra")
def test_run_aborted_plan_with_pilatus(mock_disarm, fake_caput, fake_sleep, RE, zebra):
RE(run_aborted_plan(zebra, "pilatus"))

mock_disarm.assert_called_once()
fake_caput.assert_has_calls([call(ANY, 0)])

0 comments on commit 45f6827

Please sign in to comment.