From c3bdbd3a061e01e7a2c47e679310030ac88be599 Mon Sep 17 00:00:00 2001 From: Gary Yendell Date: Tue, 18 Jun 2024 12:51:02 +0000 Subject: [PATCH] Fix GUI PVs with no attribute path --- src/fastcs/backends/epics/gui.py | 5 ++--- tests/backends/epics/test_gui.py | 11 +++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 tests/backends/epics/test_gui.py diff --git a/src/fastcs/backends/epics/gui.py b/src/fastcs/backends/epics/gui.py index 66473f0d..a7562920 100644 --- a/src/fastcs/backends/epics/gui.py +++ b/src/fastcs/backends/epics/gui.py @@ -50,9 +50,8 @@ def __init__(self, mapping: Mapping, pv_prefix: str) -> None: self._pv_prefix = pv_prefix def _get_pv(self, attr_path: list[str], name: str): - attr_prefix = ":".join(attr_path) - pv_prefix = ":".join((self._pv_prefix, attr_prefix)) - return f"{pv_prefix}:{name.title().replace('_', '')}" + attr_prefix = ":".join([self._pv_prefix] + attr_path) + return f"{attr_prefix}:{name.title().replace('_', '')}" @staticmethod def _get_read_widget(datatype: DataType) -> ReadWidget: diff --git a/tests/backends/epics/test_gui.py b/tests/backends/epics/test_gui.py new file mode 100644 index 00000000..53ab7c01 --- /dev/null +++ b/tests/backends/epics/test_gui.py @@ -0,0 +1,11 @@ +from fastcs.backends.epics.gui import EpicsGUI +from fastcs.controller import Controller +from fastcs.mapping import Mapping + + +def test_get_pv(): + gui = EpicsGUI(Mapping(Controller()), "DEVICE") + + assert gui._get_pv([], "A") == "DEVICE:A" + assert gui._get_pv(["B"], "C") == "DEVICE:B:C" + assert gui._get_pv(["D", "E"], "F") == "DEVICE:D:E:F"