fix: fixed psi_detector_base to allow init with mocked device_manager
This commit is contained in:
parent
5a591ce024
commit
e566c7f982
@ -219,11 +219,17 @@ class PSIDetectorBase(Device):
|
|||||||
self.scaninfo.load_scan_metadata()
|
self.scaninfo.load_scan_metadata()
|
||||||
|
|
||||||
def _update_service_config(self) -> None:
|
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
|
# pylint: disable=import-outside-toplevel
|
||||||
from bec_lib.bec_service import SERVICE_CONFIG
|
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:
|
def check_scan_id(self) -> None:
|
||||||
"""Checks if scan_id has changed and set stopped flagged to True if it has."""
|
"""Checks if scan_id has changed and set stopped flagged to True if it has."""
|
||||||
|
@ -43,20 +43,10 @@ def monitor(name="monitor"):
|
|||||||
def camera(name="camera"):
|
def camera(name="camera"):
|
||||||
"""Fixture for SimCamera."""
|
"""Fixture for SimCamera."""
|
||||||
dm = DMMock()
|
dm = DMMock()
|
||||||
with (
|
cam = SimCamera(name=name, device_manager=dm)
|
||||||
mock.patch(
|
cam.filewriter = mock.MagicMock()
|
||||||
"ophyd_devices.interfaces.base_classes.psi_detector_base.PSIDetectorBase._update_service_config",
|
cam.filewriter.compile_full_filename.return_value = ""
|
||||||
mock.MagicMock(),
|
yield cam
|
||||||
) 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
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="function")
|
@pytest.fixture(scope="function")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user