diff --git a/src/hyperion/external_interaction/callbacks/ispyb_callback_base.py b/src/hyperion/external_interaction/callbacks/ispyb_callback_base.py index 4f19b61ff..a821cf03e 100644 --- a/src/hyperion/external_interaction/callbacks/ispyb_callback_base.py +++ b/src/hyperion/external_interaction/callbacks/ispyb_callback_base.py @@ -4,6 +4,8 @@ from collections.abc import Sequence from typing import TYPE_CHECKING, Any, Callable, Dict, Optional, TypeVar +from dodal.devices.synchrotron import SynchrotronMode + from hyperion.external_interaction.callbacks.common.ispyb_mapping import ( populate_data_collection_group, ) @@ -96,9 +98,13 @@ def activity_gated_event(self, doc: Event) -> Event: self._event_driven_data_collection_info.undulator_gap1 = doc["data"][ "undulator_current_gap" ] - self._event_driven_data_collection_info.synchrotron_mode = doc["data"][ - "synchrotron-synchrotron_mode" - ] + assert isinstance( + synchrotron_mode := doc["data"]["synchrotron-synchrotron_mode"], + SynchrotronMode, + ) + self._event_driven_data_collection_info.synchrotron_mode = ( + synchrotron_mode.value + ) self._event_driven_data_collection_info.slitgap_horizontal = doc["data"][ "s4_slit_gaps_xgap" ] diff --git a/tests/conftest.py b/tests/conftest.py index 15e4020cb..c22f51b3b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -539,6 +539,7 @@ def fake_fgs_composite( done_status, attenuator, xbpm_feedback, + synchrotron, aperture_scatterguard, zocalo, dcm, @@ -555,7 +556,7 @@ def fake_fgs_composite( s4_slit_gaps=i03.s4_slit_gaps(fake_with_ophyd_sim=True), smargon=smargon, undulator=i03.undulator(fake_with_ophyd_sim=True), - synchrotron=i03.synchrotron(fake_with_ophyd_sim=True), + synchrotron=synchrotron, xbpm_feedback=xbpm_feedback, zebra=i03.zebra(fake_with_ophyd_sim=True), zocalo=zocalo, diff --git a/tests/unit_tests/experiment_plans/conftest.py b/tests/unit_tests/experiment_plans/conftest.py index 0ff5d09c6..304b370ec 100644 --- a/tests/unit_tests/experiment_plans/conftest.py +++ b/tests/unit_tests/experiment_plans/conftest.py @@ -6,6 +6,7 @@ from bluesky.utils import Msg from dodal.devices.fast_grid_scan import FastGridScan from dodal.devices.oav.oav_detector import OAVConfigParams +from dodal.devices.synchrotron import SynchrotronMode from dodal.devices.zocalo import ZocaloResults, ZocaloTrigger from event_model import Event from ophyd.sim import make_fake_device @@ -43,7 +44,7 @@ def make_event_doc(data, descriptor="abc123") -> Event: BASIC_PRE_SETUP_DOC = { "undulator_current_gap": 0, - "synchrotron-synchrotron_mode": 0, + "synchrotron-synchrotron_mode": SynchrotronMode.USER, "s4_slit_gaps_xgap": 0, "s4_slit_gaps_ygap": 0, "robot-barcode": "BARCODE", diff --git a/tests/unit_tests/external_interaction/callbacks/conftest.py b/tests/unit_tests/external_interaction/callbacks/conftest.py index f81b383cc..e16ec25af 100644 --- a/tests/unit_tests/external_interaction/callbacks/conftest.py +++ b/tests/unit_tests/external_interaction/callbacks/conftest.py @@ -1,4 +1,5 @@ import pytest +from dodal.devices.synchrotron import SynchrotronMode from dodal.devices.zocalo.zocalo_results import ZOCALO_READING_PLAN_NAME from event_model.documents import Event, EventDescriptor, RunStart, RunStop @@ -61,21 +62,6 @@ class TestData: "uid": "2093c941-ded1-42c4-ab74-ea99980fbbfd", "subplan_name": CONST.PLAN.ROTATION_MAIN, } - test_rotation_event_document_pre_data_collection: Event = { - "descriptor": "bd45c2e5-2b85-4280-95d7-a9a15800a78b", - "time": 1666604299.828203, - "data": { - "s4_slit_gaps_xgap": 0.1234, - "s4_slit_gaps_ygap": 0.2345, - "synchrotron-synchrotron_mode": "test", - "undulator_current_gap": 1.234, - "robot-barcode": "BARCODE", - }, - "timestamps": {"det1": 1666604299.8220396, "det2": 1666604299.8235943}, - "seq_num": 1, - "uid": "2093c941-ded1-42c4-ab74-ea99980fbbfd", - "filled": {}, - } test_rotation_event_document_during_data_collection: Event = { "descriptor": "bd45c2e5-2b85-4280-95d7-a9a15800a78b", "time": 2666604299.928203, @@ -143,7 +129,7 @@ class TestData: "data": { "s4_slit_gaps_xgap": 0.1234, "s4_slit_gaps_ygap": 0.2345, - "synchrotron-synchrotron_mode": "test", + "synchrotron-synchrotron_mode": SynchrotronMode.USER, "undulator_current_gap": 1.234, "robot-barcode": "BARCODE", }, diff --git a/tests/unit_tests/external_interaction/callbacks/rotation/test_ispyb_callback.py b/tests/unit_tests/external_interaction/callbacks/rotation/test_ispyb_callback.py index 8b18765d8..c6bb5ca8f 100644 --- a/tests/unit_tests/external_interaction/callbacks/rotation/test_ispyb_callback.py +++ b/tests/unit_tests/external_interaction/callbacks/rotation/test_ispyb_callback.py @@ -98,9 +98,7 @@ def test_activity_gated_event( callback.activity_gated_descriptor( TestData.test_descriptor_document_pre_data_collection ) - callback.activity_gated_event( - TestData.test_rotation_event_document_pre_data_collection - ) + callback.activity_gated_event(TestData.test_event_document_pre_data_collection) callback.activity_gated_descriptor( TestData.test_descriptor_document_during_data_collection ) @@ -126,7 +124,7 @@ def test_activity_gated_event( "id": TEST_DATA_COLLECTION_IDS[0], "slitgaphorizontal": 0.1234, "slitgapvertical": 0.2345, - "synchrotronmode": "test", + "synchrotronmode": "User", "undulatorgap1": 1.234, "wavelength": 1.1164718451643736, "transmission": 98, diff --git a/tests/unit_tests/external_interaction/callbacks/xray_centre/test_ispyb_callback.py b/tests/unit_tests/external_interaction/callbacks/xray_centre/test_ispyb_callback.py index 73af6913f..ae284f08b 100644 --- a/tests/unit_tests/external_interaction/callbacks/xray_centre/test_ispyb_callback.py +++ b/tests/unit_tests/external_interaction/callbacks/xray_centre/test_ispyb_callback.py @@ -162,7 +162,7 @@ def test_activity_gated_event_2d(mock_ispyb_conn): "id": TEST_DATA_COLLECTION_IDS[0], "slitgaphorizontal": 0.1234, "slitgapvertical": 0.2345, - "synchrotronmode": "test", + "synchrotronmode": "User", "undulatorgap1": 1.234, "wavelength": 1.1164718451643736, "transmission": 100, @@ -262,7 +262,7 @@ def test_activity_gated_event_3d(mock_ispyb_conn): "id": TEST_DATA_COLLECTION_IDS[0], "slitgaphorizontal": 0.1234, "slitgapvertical": 0.2345, - "synchrotronmode": "test", + "synchrotronmode": "User", "undulatorgap1": 1.234, "wavelength": 1.1164718451643736, "transmission": 100,