Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tango/pyaml/controlsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def _attach(self, devs: list[DeviceAccess]) -> list[DeviceAccess]:
newDevs.append(None)
return newDevs

def get_device(self, ref: str | BaseModel | None) -> DeviceAccess | None:
def get_device_access(self, ref: str | BaseModel | None) -> DeviceAccess | None:
"""
Resolve a public device reference for this Tango control system.

Expand All @@ -129,7 +129,7 @@ def get_device(self, ref: str | BaseModel | None) -> DeviceAccess | None:

if isinstance(ref, DeviceAccess):
raise PyAMLException(
"TangoControlSystem.get_device() expects a catalog key, Tango "
"TangoControlSystem.get_device_access() expects a catalog key, Tango "
"ConfigModel, or None. Use attach() for already constructed "
"DeviceAccess objects."
)
Expand Down Expand Up @@ -174,7 +174,7 @@ def get_device(self, ref: str | BaseModel | None) -> DeviceAccess | None:
)

raise PyAMLException(
f"TangoControlSystem.get_device() cannot resolve references of type "
f"TangoControlSystem.get_device_access() cannot resolve references of type "
f"{type(ref).__name__}; expected str, Tango ConfigModel, or None."
)

Expand Down
20 changes: 10 additions & 10 deletions tests/test_controlsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def test_catalog_can_be_configured_and_resolved():
)
)

resolved = cs.get_device("BPM_C01-01/x")
resolved = cs.get_device_access("BPM_C01-01/x")

assert cs.get_catalog() is catalog
assert catalog.resolve("BPM_C01-01/x") is device
Expand All @@ -85,7 +85,7 @@ def test_get_device_builds_attribute_from_config_model():
ConfigModel(name="test_tango_cs", tango_host="tangodb:10000")
)

resolved = cs.get_device(
resolved = cs.get_device_access(
AttributeConfigModel(attribute="sys/tg_test/1/float_scalar", unit="A")
)

Expand All @@ -99,7 +99,7 @@ def test_get_device_builds_read_only_attribute_from_config_model():
ConfigModel(name="test_tango_cs", tango_host="tangodb:10000")
)

resolved = cs.get_device(
resolved = cs.get_device_access(
AttributeReadOnlyConfigModel(attribute="sys/tg_test/1/float_scalar", unit="A")
)

Expand All @@ -113,7 +113,7 @@ def test_get_device_builds_attribute_list_from_config_model():
ConfigModel(name="test_tango_cs", tango_host="tangodb:10000")
)

resolved = cs.get_device(
resolved = cs.get_device_access(
AttributeListConfigModel(
name="group",
attributes=[
Expand All @@ -139,7 +139,7 @@ def test_get_device_builds_read_only_attribute_list_from_config_model():
ConfigModel(name="test_tango_cs", tango_host="tangodb:10000")
)

resolved = cs.get_device(
resolved = cs.get_device_access(
AttributeListReadOnlyConfigModel(
name="group",
attributes=[
Expand All @@ -162,21 +162,21 @@ def test_get_device_builds_read_only_attribute_list_from_config_model():
def test_get_device_none_returns_none():
cs = TangoControlSystem(ConfigModel(name="test_tango_cs"))

assert cs.get_device(None) is None
assert cs.get_device_access(None) is None


def test_get_device_rejects_preconstructed_device_access(config):
cs = TangoControlSystem(ConfigModel(name="test_tango_cs"))

with pytest.raises(pyaml.PyAMLException, match="Use attach\\(\\)"):
cs.get_device(Attribute(config))
cs.get_device_access(Attribute(config))


def test_get_device_requires_catalog_for_string_key():
cs = TangoControlSystem(ConfigModel(name="test_tango_cs"))

with pytest.raises(pyaml.PyAMLException, match="has no catalog configured"):
cs.get_device("BPM_C01-01/x")
cs.get_device_access("BPM_C01-01/x")


def test_get_device_reports_unknown_catalog_key():
Expand All @@ -193,14 +193,14 @@ def test_get_device_reports_unknown_catalog_key():
cs = TangoControlSystem(ConfigModel(name="test_tango_cs", catalog=catalog))

with pytest.raises(pyaml.PyAMLException, match="cannot resolve key 'BPM_C01-02/x'"):
cs.get_device("BPM_C01-02/x")
cs.get_device_access("BPM_C01-02/x")


def test_get_device_rejects_unknown_reference_type():
cs = TangoControlSystem(ConfigModel(name="test_tango_cs"))

with pytest.raises(pyaml.PyAMLException, match="type int"):
cs.get_device(42)
cs.get_device_access(42)


def test_tango_control_system_exposes_tango_host():
Expand Down
8 changes: 4 additions & 4 deletions tests/test_static_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ def test_static_catalog_is_shared_across_control_systems():
assert live.get_catalog() is catalog
assert ops.get_catalog() is catalog
assert catalog.resolve("BPM/x") is device
assert live.get_device("BPM/x") is not device
assert ops.get_device("BPM/x") is not device
assert live.get_device("BPM/x") is not ops.get_device("BPM/x")
assert live.get_device_access("BPM/x") is not device
assert ops.get_device_access("BPM/x") is not device
assert live.get_device_access("BPM/x") is not ops.get_device_access("BPM/x")


# --- Integration with DeviceAccess types ---
Expand All @@ -124,7 +124,7 @@ def test_static_catalog_can_be_used_through_tango_control_system():
catalog = make_catalog(entries=[make_entry("BPM/x", device=device)])
control_system = TangoControlSystem(TangoControlSystemConfigModel(name="live", catalog=catalog))

resolved = control_system.get_device("BPM/x")
resolved = control_system.get_device_access("BPM/x")

assert resolved is not device
assert resolved.name() == "sr/bpm/c01-01/x"
6 changes: 3 additions & 3 deletions tests/test_tango_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ def attribute_proxy(attr_full_name):
return MockedAttributeProxy(attr_full_name, attr_configs[attr_full_name])

with patch("tango.AttributeProxy", side_effect=attribute_proxy) as attr_proxy:
live_device = live.get_device(key)
ops_device = ops.get_device(key)
live_device = live.get_device_access(key)
ops_device = ops.get_device_access(key)

assert attr_proxy.call_args_list == [
call("//live-db:10000/domain/family/member/current"),
Expand All @@ -153,7 +153,7 @@ def test_tango_catalog_can_be_used_through_tango_control_system():
catalog = TangoCatalog(ConfigModel(disconnected=True))
control_system = TangoControlSystem(TangoControlSystemConfigModel(name="live", catalog=catalog))

device = control_system.get_device("domain/family/member/attribute")
device = control_system.get_device_access("domain/family/member/attribute")

assert isinstance(device, Attribute)
assert control_system.get_catalog() is catalog
Expand Down
Loading