diff --git a/ophyd_devices/interfaces/base_classes/psi_detector_base.py b/ophyd_devices/interfaces/base_classes/psi_detector_base.py index 816be92..6f643db 100644 --- a/ophyd_devices/interfaces/base_classes/psi_detector_base.py +++ b/ophyd_devices/interfaces/base_classes/psi_detector_base.py @@ -219,11 +219,17 @@ class PSIDetectorBase(Device): self.scaninfo.load_scan_metadata() def _update_service_config(self) -> None: - """Update service config from BEC service config""" + """Update service config from BEC service config + + If bec services are not running and SERVICE_CONFIG is NONE, we fall back to the current directory. + """ # pylint: disable=import-outside-toplevel from bec_lib.bec_service import SERVICE_CONFIG - self.service_cfg = SERVICE_CONFIG.config["service_config"]["file_writer"] + if SERVICE_CONFIG: + self.service_cfg = SERVICE_CONFIG.config["service_config"]["file_writer"] + return + self.service_cfg = {"base_path": os.path.abspath(".")} def check_scan_id(self) -> None: """Checks if scan_id has changed and set stopped flagged to True if it has.""" diff --git a/tests/test_simulation.py b/tests/test_simulation.py index 570ab8a..185b847 100644 --- a/tests/test_simulation.py +++ b/tests/test_simulation.py @@ -43,20 +43,10 @@ def monitor(name="monitor"): def camera(name="camera"): """Fixture for SimCamera.""" dm = DMMock() - with ( - mock.patch( - "ophyd_devices.interfaces.base_classes.psi_detector_base.PSIDetectorBase._update_service_config", - mock.MagicMock(), - ) as mock_update_service_config, - mock.patch( - "ophyd_devices.interfaces.base_classes.psi_detector_base.PSIDetectorBase._update_filewriter", - mock.MagicMock(), - ) as mock_update_filewriter, - ): - cam = SimCamera(name=name, device_manager=dm) - cam.filewriter = mock.MagicMock() - cam.filewriter.compile_full_filename.return_value = "" - yield cam + cam = SimCamera(name=name, device_manager=dm) + cam.filewriter = mock.MagicMock() + cam.filewriter.compile_full_filename.return_value = "" + yield cam @pytest.fixture(scope="function")