From 8571fee94f60bbc36c3e713861cf2a34dc1fcc6b Mon Sep 17 00:00:00 2001 From: David Perl Date: Thu, 29 Feb 2024 08:55:35 +0000 Subject: [PATCH] DiamondLightSource/hyperion#1192 fix some tests --- src/hyperion/__main__.py | 6 +- .../panda_flyscan_xray_centre_plan.py | 2 +- .../callbacks/zocalo_callback.py | 1 + .../experiment_plans/test_fgs_plan.py | 6 +- .../test_ispyb_dev_connection.py | 2 +- .../test_zocalo_system.py | 49 ++++---- tests/unit_tests/experiment_plans/conftest.py | 4 +- .../callbacks/test_plan_reactive_callback.py | 8 +- .../callbacks/test_rotation_callbacks.py | 12 +- .../callbacks/xray_centre/conftest.py | 8 +- .../test_xraycentre_callback_collection.py | 6 +- .../xray_centre/test_zocalo_handler.py | 108 ------------------ 12 files changed, 46 insertions(+), 166 deletions(-) delete mode 100644 tests/unit_tests/external_interaction/callbacks/xray_centre/test_zocalo_handler.py diff --git a/src/hyperion/__main__.py b/src/hyperion/__main__.py index 0e1527e7e..a53354284 100755 --- a/src/hyperion/__main__.py +++ b/src/hyperion/__main__.py @@ -155,11 +155,7 @@ def wait_on_queue(self): if command.experiment is None: raise ValueError("No experiment provided for START") try: - if ( - not self.use_external_callbacks - and command.callbacks - and (cbs := list(command.callbacks.setup())) - ): + if command.callbacks and (cbs := list(command.callbacks())): LOGGER.info( f"Using callbacks for this plan: {not self.use_external_callbacks} - {cbs}" ) diff --git a/src/hyperion/experiment_plans/panda_flyscan_xray_centre_plan.py b/src/hyperion/experiment_plans/panda_flyscan_xray_centre_plan.py index fc307155d..dc734130e 100755 --- a/src/hyperion/experiment_plans/panda_flyscan_xray_centre_plan.py +++ b/src/hyperion/experiment_plans/panda_flyscan_xray_centre_plan.py @@ -306,7 +306,7 @@ def run_gridscan_and_move_and_tidy(fgs_composite, params): ) parameters = GridscanInternalParameters(**external_parameters.from_file()) - subscriptions = XrayCentreCallbackCollection.setup() + subscriptions = XrayCentreCallbackCollection() context = setup_context(wait_for_connection=True) composite = create_devices(context) diff --git a/src/hyperion/external_interaction/callbacks/zocalo_callback.py b/src/hyperion/external_interaction/callbacks/zocalo_callback.py index 568e14474..b1a3e8fa9 100644 --- a/src/hyperion/external_interaction/callbacks/zocalo_callback.py +++ b/src/hyperion/external_interaction/callbacks/zocalo_callback.py @@ -29,6 +29,7 @@ def _reset_state(self): self.run_uid: Optional[str] = None self.triggering_plan: Optional[str] = None self.ispyb_ids: Optional[tuple[int]] = None + self.zocalo_interactor: Optional[ZocaloTrigger] = None def __init__( self, diff --git a/tests/system_tests/experiment_plans/test_fgs_plan.py b/tests/system_tests/experiment_plans/test_fgs_plan.py index aa8970c37..665761b7d 100644 --- a/tests/system_tests/experiment_plans/test_fgs_plan.py +++ b/tests/system_tests/experiment_plans/test_fgs_plan.py @@ -174,7 +174,7 @@ def test_full_plan_tidies_at_end( params: GridscanInternalParameters, RE: RunEngine, ): - callbacks = XrayCentreCallbackCollection.setup() + callbacks = XrayCentreCallbackCollection() callbacks.nexus_handler.nexus_writer_1 = MagicMock() callbacks.nexus_handler.nexus_writer_2 = MagicMock() callbacks.ispyb_handler.ispyb_ids = IspybIds( @@ -230,7 +230,7 @@ def test_GIVEN_scan_invalid_WHEN_plan_run_THEN_ispyb_entry_made_but_no_zocalo_en # Currently s03 calls anything with z_steps > 1 invalid params.experiment_params.z_steps = 100 - callbacks = XrayCentreCallbackCollection.setup() + callbacks = XrayCentreCallbackCollection() callbacks.ispyb_handler.ispyb.ISPYB_CONFIG_PATH = ISPYB_CONFIG mock_start_zocalo = MagicMock() callbacks.zocalo_handler.zocalo_interactor.run_start = mock_start_zocalo @@ -272,7 +272,7 @@ def test_WHEN_plan_run_THEN_move_to_centre_returned_from_zocalo_expected_centre( fgs_composite.eiger.stage = MagicMock() fgs_composite.eiger.unstage = MagicMock() - callbacks = XrayCentreCallbackCollection.setup() + callbacks = XrayCentreCallbackCollection() callbacks.ispyb_handler.ispyb.ISPYB_CONFIG_PATH = ISPYB_CONFIG RE(flyscan_xray_centre(fgs_composite, params)) diff --git a/tests/system_tests/external_interaction/test_ispyb_dev_connection.py b/tests/system_tests/external_interaction/test_ispyb_dev_connection.py index 6dfee55f7..bcc6cade5 100644 --- a/tests/system_tests/external_interaction/test_ispyb_dev_connection.py +++ b/tests/system_tests/external_interaction/test_ispyb_dev_connection.py @@ -167,7 +167,7 @@ def test_ispyb_deposition_in_rotation_plan( ) os.environ["ISPYB_CONFIG_PATH"] = DEV_ISPYB_DATABASE_CFG - callbacks = RotationCallbackCollection.setup() + callbacks = RotationCallbackCollection() for cb in list(callbacks): RE.subscribe(cb) diff --git a/tests/system_tests/external_interaction/test_zocalo_system.py b/tests/system_tests/external_interaction/test_zocalo_system.py index 4ee45f7ce..2aaea7f95 100644 --- a/tests/system_tests/external_interaction/test_zocalo_system.py +++ b/tests/system_tests/external_interaction/test_zocalo_system.py @@ -14,7 +14,7 @@ from hyperion.external_interaction.callbacks.xray_centre.callback_collection import ( XrayCentreCallbackCollection, ) -from hyperion.external_interaction.ispyb.ispyb_store import IspybIds +from hyperion.external_interaction.callbacks.zocalo_callback import ZocaloCallback from hyperion.parameters.constants import GRIDSCAN_OUTER_PLAN from hyperion.parameters.plan_specific.gridscan_internal_params import ( GridscanInternalParameters, @@ -53,16 +53,9 @@ async def zocalo_device(): async def test_when_running_start_stop_then_get_expected_returned_results( dummy_params, zocalo_env, zocalo_device: ZocaloResults, RE: RunEngine ): - start_doc = { - "subplan_name": GRIDSCAN_OUTER_PLAN, - "hyperion_internal_parameters": dummy_params.json(), - } - zc = XrayCentreCallbackCollection.setup().zocalo_handler - zc.activity_gated_start(start_doc) dcids = (1, 2) - zc.ispyb.ispyb_ids = IspybIds( - data_collection_ids=dcids, data_collection_group_id=4, grid_ids=(0,) - ) + zc = ZocaloCallback() + zc.start({}) # TODO for dcid in dcids: zc.zocalo_interactor.run_start(dcid) for dcid in dcids: @@ -81,14 +74,12 @@ def run_zocalo_with_dev_ispyb( ): async def inner(sample_name="", fallback=np.array([0, 0, 0])): dummy_params.hyperion_params.detector_params.prefix = sample_name - cbs = XrayCentreCallbackCollection.setup() - zc = cbs.zocalo_handler - zc.active = True + cbs = XrayCentreCallbackCollection() ispyb = cbs.ispyb_handler ispyb.ispyb_config = dummy_ispyb_3d.ISPYB_CONFIG_PATH ispyb.active = True + assert isinstance(zc := ispyb.emit_cb, ZocaloCallback) - RE.subscribe(zc) RE.subscribe(ispyb) @bpp.set_run_key_decorator("testing123") @@ -103,12 +94,12 @@ def plan(): ) def inner_plan(): yield from bps.sleep(0) - zc.ispyb.ispyb_ids = zc.ispyb.ispyb.begin_deposition() - assert isinstance(zc.ispyb.ispyb_ids.data_collection_ids, tuple) - for dcid in zc.ispyb.ispyb_ids.data_collection_ids: + ispyb.ispyb_ids = ispyb.ispyb.begin_deposition() + assert isinstance(ispyb.ispyb_ids.data_collection_ids, tuple) + for dcid in ispyb.ispyb_ids.data_collection_ids: zc.zocalo_interactor.run_start(dcid) - zc.ispyb._processing_start_time = time() - for dcid in zc.ispyb.ispyb_ids.data_collection_ids: + ispyb._processing_start_time = time() + for dcid in ispyb.ispyb_ids.data_collection_ids: zc.zocalo_interactor.run_end(dcid) yield from inner_plan() @@ -123,7 +114,7 @@ def inner_plan(): else: centre = centre[0] - return zc, centre + return ispyb, zc, centre return inner @@ -134,7 +125,7 @@ async def test_given_a_result_with_no_diffraction_when_zocalo_called_then_move_t run_zocalo_with_dev_ispyb, zocalo_env ): fallback = np.array([1, 2, 3]) - zc, centre = await run_zocalo_with_dev_ispyb("NO_DIFF", fallback) + _, _, centre = await run_zocalo_with_dev_ispyb("NO_DIFF", fallback) assert np.allclose(centre, fallback) @@ -143,9 +134,9 @@ async def test_given_a_result_with_no_diffraction_when_zocalo_called_then_move_t async def test_given_a_result_with_no_diffraction_ispyb_comment_updated( run_zocalo_with_dev_ispyb, zocalo_env, fetch_comment ): - zc, _ = await run_zocalo_with_dev_ispyb("NO_DIFF") + ispyb, zc, _ = await run_zocalo_with_dev_ispyb("NO_DIFF") - comment = fetch_comment(zc.ispyb.ispyb_ids.data_collection_ids[0]) + comment = fetch_comment(ispyb.ispyb_ids.data_collection_ids[0]) assert "Zocalo found no crystals in this gridscan." in comment @@ -154,9 +145,9 @@ async def test_given_a_result_with_no_diffraction_ispyb_comment_updated( async def test_zocalo_adds_nonzero_comment_time( run_zocalo_with_dev_ispyb, zocalo_env, fetch_comment ): - zc, _ = await run_zocalo_with_dev_ispyb() + ispyb, zc, _ = await run_zocalo_with_dev_ispyb() - comment = fetch_comment(zc.ispyb.ispyb_ids.data_collection_ids[0]) + comment = fetch_comment(ispyb.ispyb_ids.data_collection_ids[0]) assert comment[156:178] == "Zocalo processing took" assert float(comment[179:184]) > 0 assert float(comment[179:184]) < 180 @@ -167,8 +158,8 @@ async def test_zocalo_adds_nonzero_comment_time( async def test_given_a_single_crystal_result_ispyb_comment_updated( run_zocalo_with_dev_ispyb, zocalo_env, fetch_comment ): - zc, _ = await run_zocalo_with_dev_ispyb() - comment = fetch_comment(zc.ispyb.ispyb_ids.data_collection_ids[0]) + ispyb, zc, _ = await run_zocalo_with_dev_ispyb() + comment = fetch_comment(ispyb.ispyb_ids.data_collection_ids[0]) assert "Crystal 1" in comment assert "Strength" in comment assert "Size (grid boxes)" in comment @@ -179,9 +170,9 @@ async def test_given_a_single_crystal_result_ispyb_comment_updated( async def test_given_a_result_with_multiple_crystals_ispyb_comment_updated( run_zocalo_with_dev_ispyb, zocalo_env, fetch_comment ): - zc, _ = await run_zocalo_with_dev_ispyb("MULTI_X") + ispyb, zc, _ = await run_zocalo_with_dev_ispyb("MULTI_X") - comment = fetch_comment(zc.ispyb.ispyb_ids.data_collection_ids[0]) + comment = fetch_comment(ispyb.ispyb_ids.data_collection_ids[0]) assert "Crystal 1" and "Crystal 2" in comment assert "Strength" in comment assert "Position (grid boxes)" in comment diff --git a/tests/unit_tests/experiment_plans/conftest.py b/tests/unit_tests/experiment_plans/conftest.py index a9adec324..1f2b81f40 100644 --- a/tests/unit_tests/experiment_plans/conftest.py +++ b/tests/unit_tests/experiment_plans/conftest.py @@ -147,7 +147,7 @@ def mock_subscriptions(test_fgs_params): ) ), ): - subscriptions = XrayCentreCallbackCollection.setup() + subscriptions = XrayCentreCallbackCollection() subscriptions.ispyb_handler.ispyb = MagicMock(spec=Store3DGridscanInIspyb) start_doc = { "subplan_name": GRIDSCAN_OUTER_PLAN, @@ -171,7 +171,7 @@ def mock_rotation_subscriptions(test_rotation_params): "hyperion.external_interaction.callbacks.rotation.callback_collection.ZocaloCallback", autospec=True, ): - subscriptions = RotationCallbackCollection.setup() + subscriptions = RotationCallbackCollection() return subscriptions diff --git a/tests/unit_tests/external_interaction/callbacks/test_plan_reactive_callback.py b/tests/unit_tests/external_interaction/callbacks/test_plan_reactive_callback.py index abc704eac..007627e1b 100644 --- a/tests/unit_tests/external_interaction/callbacks/test_plan_reactive_callback.py +++ b/tests/unit_tests/external_interaction/callbacks/test_plan_reactive_callback.py @@ -152,10 +152,10 @@ def test_emit_called_correctly(): receiving_cb.active = True test_cb.start(start_doc) - receiving_cb.activity_gated_start.assert_called_with(start_doc) + receiving_cb.activity_gated_start.assert_called_once_with(start_doc) test_cb.descriptor(desc_doc) - receiving_cb.activity_gated_descriptor.assert_called_with(desc_doc) + receiving_cb.activity_gated_descriptor.assert_called_once_with(desc_doc) test_cb.event(event_doc) - receiving_cb.activity_gated_event.assert_called_with(event_doc) + receiving_cb.activity_gated_event.assert_called_once_with(event_doc) test_cb.stop(stop_doc) - receiving_cb.activity_gated_stop.assert_called_with(stop_doc) + receiving_cb.activity_gated_stop.assert_called_once_with(stop_doc) diff --git a/tests/unit_tests/external_interaction/callbacks/test_rotation_callbacks.py b/tests/unit_tests/external_interaction/callbacks/test_rotation_callbacks.py index cf41f3c87..2c6a21c03 100644 --- a/tests/unit_tests/external_interaction/callbacks/test_rotation_callbacks.py +++ b/tests/unit_tests/external_interaction/callbacks/test_rotation_callbacks.py @@ -128,7 +128,7 @@ def test_nexus_handler_gets_documents_in_mock_plan( "hyperion.external_interaction.callbacks.rotation.callback_collection.RotationISPyBCallback", autospec=True, ): - cb = RotationCallbackCollection.setup() + cb = RotationCallbackCollection() activate_callbacks(cb) cb.nexus_handler.activity_gated_event = MagicMock(autospec=True) cb.nexus_handler.activity_gated_start = MagicMock(autospec=True) @@ -169,7 +169,7 @@ def test_nexus_handler_only_writes_once( "hyperion.external_interaction.callbacks.rotation.callback_collection.ZocaloCallback", autospec=True, ): - cb = RotationCallbackCollection.setup() + cb = RotationCallbackCollection() activate_callbacks(cb) cb.ispyb_handler.activity_gated_start = MagicMock(autospec=True) cb.ispyb_handler.activity_gated_event = MagicMock(autospec=True) @@ -197,7 +197,7 @@ def test_nexus_handler_triggers_write_file_when_told( "hyperion.external_interaction.callbacks.rotation.callback_collection.ZocaloCallback", autospec=True, ): - cb = RotationCallbackCollection.setup() + cb = RotationCallbackCollection() activate_callbacks(cb) cb.ispyb_handler.activity_gated_start = MagicMock(autospec=True) cb.ispyb_handler.activity_gated_stop = MagicMock(autospec=True) @@ -219,7 +219,7 @@ def test_nexus_handler_triggers_write_file_when_told( def test_zocalo_start_and_end_not_triggered_if_ispyb_ids_not_present( zocalo, RE: RunEngine, params: RotationInternalParameters, test_outer_start_doc ): - cb = RotationCallbackCollection.setup() + cb = RotationCallbackCollection() activate_callbacks(cb) cb.nexus_handler.activity_gated_start = MagicMock(autospec=True) cb.ispyb_handler.activity_gated_start = MagicMock(autospec=True) @@ -258,7 +258,7 @@ def test_ispyb_starts_on_opening_and_zocalo_on_main_so_ispyb_triggered_before_zo mock_store_in_ispyb_class.return_value = mock_store_in_ispyb_instance nexus_writer.return_value.full_filename = "test_full_filename" - cb = RotationCallbackCollection.setup() + cb = RotationCallbackCollection() activate_callbacks(cb) def after_open_do(callbacks: RotationCallbackCollection): @@ -282,7 +282,7 @@ def after_main_do(callbacks: RotationCallbackCollection): def test_ispyb_handler_grabs_uid_from_main_plan_and_not_first_start_doc( zocalo, RE: RunEngine, params: RotationInternalParameters, test_outer_start_doc ): - cb = RotationCallbackCollection.setup() + cb = RotationCallbackCollection() activate_callbacks(cb) cb.nexus_handler.activity_gated_event = MagicMock(autospec=True) cb.nexus_handler.activity_gated_start = MagicMock(autospec=True) diff --git a/tests/unit_tests/external_interaction/callbacks/xray_centre/conftest.py b/tests/unit_tests/external_interaction/callbacks/xray_centre/conftest.py index dc9b46f8e..0270a02ad 100644 --- a/tests/unit_tests/external_interaction/callbacks/xray_centre/conftest.py +++ b/tests/unit_tests/external_interaction/callbacks/xray_centre/conftest.py @@ -2,7 +2,7 @@ import pytest from dodal.devices.zocalo.zocalo_results import ZOCALO_READING_PLAN_NAME -from event_model.documents import Event, EventDescriptor, RunStop +from event_model.documents import Event, EventDescriptor, RunStart, RunStop from hyperion.external_interaction.callbacks.xray_centre.ispyb_callback import ( GridscanISPyBCallback, @@ -82,7 +82,7 @@ class TestData: DUMMY_TIME_STRING: str = "1970-01-01 00:00:00" GOOD_ISPYB_RUN_STATUS: str = "DataCollection Successful" BAD_ISPYB_RUN_STATUS: str = "DataCollection Unsuccessful" - test_start_document = { + test_start_document: RunStart = { # type: ignore "uid": "d8bee3ee-f614-4e7a-a516-25d6b9e87ef3", "time": 1666604299.6149616, "versions": {"ophyd": "1.6.4.post76+g0895f9f", "bluesky": "1.8.3"}, @@ -92,7 +92,7 @@ class TestData: "subplan_name": GRIDSCAN_OUTER_PLAN, "hyperion_internal_parameters": dummy_params().json(), } - test_run_gridscan_start_document = { + test_run_gridscan_start_document: RunStart = { # type: ignore "uid": "d8bee3ee-f614-4e7a-a516-25d6b9e87ef3", "time": 1666604299.6149616, "versions": {"ophyd": "1.6.4.post76+g0895f9f", "bluesky": "1.8.3"}, @@ -101,7 +101,7 @@ class TestData: "plan_name": GRIDSCAN_AND_MOVE, "subplan_name": GRIDSCAN_MAIN_PLAN, } - test_do_fgs_start_document = { + test_do_fgs_start_document: RunStart = { # type: ignore "uid": "d8bee3ee-f614-4e7a-a516-25d6b9e87ef3", "time": 1666604299.6149616, "versions": {"ophyd": "1.6.4.post76+g0895f9f", "bluesky": "1.8.3"}, diff --git a/tests/unit_tests/external_interaction/callbacks/xray_centre/test_xraycentre_callback_collection.py b/tests/unit_tests/external_interaction/callbacks/xray_centre/test_xraycentre_callback_collection.py index 8fece68db..c9b056710 100644 --- a/tests/unit_tests/external_interaction/callbacks/xray_centre/test_xraycentre_callback_collection.py +++ b/tests/unit_tests/external_interaction/callbacks/xray_centre/test_xraycentre_callback_collection.py @@ -10,12 +10,12 @@ def test_callback_collection_init(): - callbacks = XrayCentreCallbackCollection.setup() + callbacks = XrayCentreCallbackCollection() assert len(list(callbacks)) == 3 def test_callback_collection_list(): - callbacks = XrayCentreCallbackCollection.setup() + callbacks = XrayCentreCallbackCollection() callback_list = list(callbacks) assert len(callback_list) == 3 assert callbacks.ispyb_handler in callback_list @@ -24,7 +24,7 @@ def test_callback_collection_list(): def test_subscribe_in_plan(): - callbacks = XrayCentreCallbackCollection.setup() + callbacks = XrayCentreCallbackCollection() document_event_mock = MagicMock() callbacks.ispyb_handler.start = document_event_mock callbacks.ispyb_handler.activity_gated_stop = document_event_mock diff --git a/tests/unit_tests/external_interaction/callbacks/xray_centre/test_zocalo_handler.py b/tests/unit_tests/external_interaction/callbacks/xray_centre/test_zocalo_handler.py deleted file mode 100644 index 721dbe8bd..000000000 --- a/tests/unit_tests/external_interaction/callbacks/xray_centre/test_zocalo_handler.py +++ /dev/null @@ -1,108 +0,0 @@ -from unittest.mock import MagicMock, call, patch - -import pytest - -from hyperion.external_interaction.callbacks.xray_centre.callback_collection import ( - XrayCentreCallbackCollection, -) -from hyperion.external_interaction.exceptions import ISPyBDepositionNotMade -from hyperion.external_interaction.ispyb.ispyb_store import IspybIds -from hyperion.parameters.external_parameters import from_file as default_raw_params -from hyperion.parameters.plan_specific.gridscan_internal_params import ( - GridscanInternalParameters, -) - -from ....experiment_plans.conftest import modified_store_grid_scan_mock -from ....external_interaction.callbacks.xray_centre.conftest import TestData - -EXPECTED_DCID = 100 -EXPECTED_RUN_START_MESSAGE = {"event": "start", "ispyb_dcid": EXPECTED_DCID} -EXPECTED_RUN_END_MESSAGE = { - "event": "end", - "ispyb_dcid": EXPECTED_DCID, - "ispyb_wait_for_runstatus": "1", -} - -td = TestData() - - -@pytest.fixture -def dummy_params(): - return GridscanInternalParameters(**default_raw_params()) - - -def init_cbs_with_docs_and_mock_zocalo_and_ispyb( - callbacks: XrayCentreCallbackCollection, dcids=(0, 0), dcgid=4 -): - with patch( - "hyperion.external_interaction.callbacks.xray_centre.ispyb_callback.Store3DGridscanInIspyb", - lambda _, __: modified_store_grid_scan_mock(dcids=dcids, dcgid=dcgid), - ): - callbacks.ispyb_handler.activity_gated_start(td.test_start_document) - - -@patch( - "hyperion.external_interaction.callbacks.zocalo_callback.ZocaloTrigger", - new=MagicMock(), -) -class TestZocaloHandler: - def test_execution_of_run_gridscan_triggers_zocalo_calls( - self, - mock_ispyb_update_time_and_status: MagicMock, - mock_ispyb_get_time: MagicMock, - mock_ispyb_store_grid_scan: MagicMock, - nexus_writer: MagicMock, - dummy_params, - ): - dc_ids = (1, 2) - dcg_id = 4 - - mock_ispyb_store_grid_scan.return_value = IspybIds( - data_collection_ids=dc_ids, grid_ids=None, data_collection_group_id=dcg_id - ) - mock_ispyb_get_time.return_value = td.DUMMY_TIME_STRING - mock_ispyb_update_time_and_status.return_value = None - - callbacks = XrayCentreCallbackCollection.setup() - init_cbs_with_docs_and_mock_zocalo_and_ispyb(callbacks, dc_ids, dcg_id) - callbacks.ispyb_handler.activity_gated_start( - td.test_run_gridscan_start_document - ) # type: ignore - callbacks.ispyb_handler.activity_gated_descriptor( - td.test_descriptor_document_pre_data_collection - ) # type: ignore - callbacks.ispyb_handler.activity_gated_event( - td.test_event_document_pre_data_collection - ) - callbacks.ispyb_handler.activity_gated_descriptor( - td.test_descriptor_document_during_data_collection # type: ignore - ) - callbacks.ispyb_handler.activity_gated_event( - td.test_event_document_during_data_collection - ) - callbacks.zocalo_handler.activity_gated_start(td.test_do_fgs_start_document) - callbacks.ispyb_handler.activity_gated_stop(td.test_stop_document) - callbacks.zocalo_handler.activity_gated_stop(td.test_stop_document) - - callbacks.zocalo_handler.zocalo_interactor.run_start.assert_has_calls( - [call(x) for x in dc_ids] - ) - assert callbacks.zocalo_handler.zocalo_interactor.run_start.call_count == len( - dc_ids - ) - - callbacks.zocalo_handler.zocalo_interactor.run_end.assert_has_calls( - [call(x) for x in dc_ids] - ) - assert callbacks.zocalo_handler.zocalo_interactor.run_end.call_count == len( - dc_ids - ) - - def test_GIVEN_ispyb_not_started_WHEN_trigger_zocalo_handler_THEN_raises_exception( - self, - dummy_params, - ): - callbacks = XrayCentreCallbackCollection.setup() - - with pytest.raises(ISPyBDepositionNotMade): - callbacks.zocalo_handler.activity_gated_start(td.test_do_fgs_start_document)