diff --git a/tango/pyaml/controlsystem.py b/tango/pyaml/controlsystem.py index 14a4300..eb77043 100644 --- a/tango/pyaml/controlsystem.py +++ b/tango/pyaml/controlsystem.py @@ -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. @@ -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." ) @@ -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." ) diff --git a/tests/test_controlsystem.py b/tests/test_controlsystem.py index 1ec828e..c2d2d29 100644 --- a/tests/test_controlsystem.py +++ b/tests/test_controlsystem.py @@ -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 @@ -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") ) @@ -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") ) @@ -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=[ @@ -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=[ @@ -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(): @@ -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(): diff --git a/tests/test_static_catalog.py b/tests/test_static_catalog.py index 0b903ed..0d1ba19 100644 --- a/tests/test_static_catalog.py +++ b/tests/test_static_catalog.py @@ -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 --- @@ -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" diff --git a/tests/test_tango_catalog.py b/tests/test_tango_catalog.py index 272bdc2..bce87cf 100644 --- a/tests/test_tango_catalog.py +++ b/tests/test_tango_catalog.py @@ -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"), @@ -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