From c29cde43a952f9420cf8c4bdb3b52619266f0562 Mon Sep 17 00:00:00 2001 From: Mark Wolfman Date: Wed, 9 Oct 2024 15:03:31 -0500 Subject: [PATCH] Fixed tests. --- src/firefly/controller.py | 5 ----- src/firefly/tests/test_energy_display.py | 2 +- src/haven/_iconfig.py | 2 +- src/haven/device.py | 2 +- src/haven/instrument.py | 2 +- src/haven/preprocessors.py | 4 ++-- src/haven/tests/test_iconfig.py | 6 +++--- src/haven/tests/test_preprocessors.py | 2 +- 8 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/firefly/controller.py b/src/firefly/controller.py index 163f7f02..1737a3fc 100644 --- a/src/firefly/controller.py +++ b/src/firefly/controller.py @@ -87,11 +87,6 @@ def _setup_window_action( setattr(self, action_name, action) return action - def reload_instrument(self, load_instrument=True): - """(Re)load all the instrument devices.""" - await beamline.load() - self.registry_changed.emit(self.registry) - async def setup_instrument(self, load_instrument=True): """Set up the application to use a previously loaded instrument. diff --git a/src/firefly/tests/test_energy_display.py b/src/firefly/tests/test_energy_display.py index c396b058..e583fb8f 100644 --- a/src/firefly/tests/test_energy_display.py +++ b/src/firefly/tests/test_energy_display.py @@ -19,7 +19,7 @@ @pytest.fixture() def energy_positioner(sim_registry): energy = FakeEnergyPositioner( - mono_prefix="mono_ioc:", + monochromator_prefix="mono_ioc:", undulator_prefix="id_ioc:", name="energy", ) diff --git a/src/haven/_iconfig.py b/src/haven/_iconfig.py index c2827afa..5c35a7f9 100644 --- a/src/haven/_iconfig.py +++ b/src/haven/_iconfig.py @@ -107,7 +107,7 @@ def beamline_connected(is_connected=True): # Set temporary value if "beamline" not in _local_overrides.keys(): _local_overrides["beamline"] = {} - _local_overrides["beamline"]["is_connected"] = is_connected + _local_overrides["beamline"]["hardware_is_present"] = is_connected # Return to enclosing code yield # Restore old value diff --git a/src/haven/device.py b/src/haven/device.py index 29345f16..c5339957 100644 --- a/src/haven/device.py +++ b/src/haven/device.py @@ -133,7 +133,7 @@ def make_device(DeviceClass, *args, FakeDeviceClass=None, **kwargs) -> Device: """ # Make a fake device if the beamline is not connected config = load_config() - if config["beamline"]["is_connected"]: + if config["beamline"]["hardware_is_present"]: Cls = DeviceClass else: # Make fake device diff --git a/src/haven/instrument.py b/src/haven/instrument.py index ffc52b19..ce6d8e31 100644 --- a/src/haven/instrument.py +++ b/src/haven/instrument.py @@ -6,7 +6,7 @@ import os import time from pathlib import Path -from typing import Mapping +from typing import Mapping, Sequence import tomlkit from ophyd import Device as ThreadedDevice diff --git a/src/haven/preprocessors.py b/src/haven/preprocessors.py index f1aa9dd1..889d7ac3 100644 --- a/src/haven/preprocessors.py +++ b/src/haven/preprocessors.py @@ -91,7 +91,7 @@ def _inject_md(msg): "EPICS_CA_MAX_ARRAY_BYTES": os.environ.get("EPICS_CA_MAX_ARRAY_BYTES"), # Facility "beamline_id": config["beamline"]["name"], - "facility_id": config["facility"]["name"], + "facility_id": ", ".join(cfg['name'] for cfg in config["synchrotron"]), "xray_source": xray_source, # Computer "login_id": f"{getpass.getuser()}@{socket.gethostname()}", @@ -106,7 +106,7 @@ def _inject_md(msg): try: bss = beamline.registry.find(name="bss") except ComponentNotFound: - if config["beamline"]["is_connected"]: + if config["beamline"]["hardware_is_present"]: wmsg = "Could not find bss device, metadata may be missing." warnings.warn(wmsg) log.warning(wmsg) diff --git a/src/haven/tests/test_iconfig.py b/src/haven/tests/test_iconfig.py index 0028d2a2..7d479dc1 100644 --- a/src/haven/tests/test_iconfig.py +++ b/src/haven/tests/test_iconfig.py @@ -58,12 +58,12 @@ def test_haven_config_cli(capsys): def test_beamline_connected(): """Check the context manager to temporarily connect the beamline.""" config = load_config() - assert not config["beamline"]["is_connected"] + assert not config["beamline"]["hardware_is_present"] with beamline_connected(): config = load_config() - assert config["beamline"]["is_connected"] + assert config["beamline"]["hardware_is_present"] config = load_config() - assert not config["beamline"]["is_connected"] + assert not config["beamline"]["hardware_is_present"] # ----------------------------------------------------------------------------- diff --git a/src/haven/tests/test_preprocessors.py b/src/haven/tests/test_preprocessors.py index ff48eedf..6ad8ec6c 100644 --- a/src/haven/tests/test_preprocessors.py +++ b/src/haven/tests/test_preprocessors.py @@ -168,7 +168,7 @@ def test_metadata(sim_registry, aps, monkeypatch): expected_data = { "EPICS_HOST_ARCH": "PDP11", "beamline_id": "SPC Beamline (sector unknown)", - "facility_id": "Advanced Photon Source", + "facility_id": "advanced_photon_source", "xray_source": "undulator: ID255ds:", "epics_libca": "/dev/null", "EPICS_CA_MAX_ARRAY_BYTES": "16",