Skip to content

Commit

Permalink
Fixed tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
canismarko committed Oct 9, 2024
1 parent 298cde5 commit c29cde4
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 15 deletions.
5 changes: 0 additions & 5 deletions src/firefly/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/firefly/tests/test_energy_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
Expand Down
2 changes: 1 addition & 1 deletion src/haven/_iconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/haven/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/haven/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/haven/preprocessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()}",
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/haven/tests/test_iconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]


# -----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/haven/tests/test_preprocessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit c29cde4

Please sign in to comment.