Commit 1194bb75 authored by Matias Guijarro's avatar Matias Guijarro
Browse files

Merge branch...

Merge branch '2845-bliss-tango-database-emulation-device-set-attribute-broken-in-a-particular-case' into 'master'

Resolve "Bliss tango database emulation -> device set attribute broken (in a particular case?)"

Closes #2845

See merge request !3846
parents 0e983a1e 98e0fd03
Pipeline #49873 passed with stages
in 132 minutes and 24 seconds
......@@ -1099,8 +1099,9 @@ class beacon:
break
old_properties = property_node
if old_properties is None:
properties = static.ConfigNode(device_node, key=["properties"])
properties = static.ConfigNode(device_node, path=["properties"])
device_node["properties"] = properties
device_node.save()
else:
properties = old_properties
......
......@@ -556,6 +556,23 @@ def dummy_tango_server(ports, beacon):
yield device_fqdn, dev_proxy
@pytest.fixture
def dummy_tango_server2(ports, beacon):
device_name = "id00/tango/dummy2"
device_fqdn = "tango://localhost:{}/{}".format(ports.tango_port, device_name)
with start_tango_server(
sys.executable,
"-u",
os.path.join(os.path.dirname(__file__), "dummy_tg_server.py"),
"dummy2",
device_fqdn=device_fqdn,
state=DevState.CLOSE,
) as dev_proxy:
yield device_fqdn, dev_proxy
@pytest.fixture
def wago_tango_server(ports, default_session, wago_emulator):
device_name = "1/1/wagodummy"
......
......@@ -5,7 +5,7 @@
# Copyright (c) 2015-2020 Beamline Control Unit, ESRF
# Distributed under the GNU LGPLv3. See LICENSE for more info.
from bliss.config.conductor import client
from bliss.common.tango import Database
......@@ -19,12 +19,13 @@ def test_tangodb_getters(beacon, dummy_tango_server):
name = "dummy"
class_name = "Dummy"
server = "dummy_tg_server"
server_instance = "dummy"
dev_name = f"{domain}.{family}.{name}"
obj_name = f"{domain}/{family}/{name}"
server_instances = ["dummy", "dummy2"]
server_name = f"{server}/{name}"
obj_names = [f"{domain}/{family}/{name}" for name in server_instances]
dev_name = [f"{domain}.{family}.{name}" for name in server_instances]
alias = "dummy_alias"
serv_name = f"{server}/{server_instance}"
dserver_name = f"dserver/{serv_name}"
serv_names = [f"{server}/{server_instance}" for server_instance in server_instances]
dserver_names = [f"dserver/{serv_name}" for serv_name in serv_names]
properties = {"dummy_property1": "dummy_value1", "dummy_property2": ""}
cls_properties = {
"dummy_cls_property1": "dummy_cls_value1",
......@@ -46,23 +47,24 @@ def test_tangodb_getters(beacon, dummy_tango_server):
assert server in result
result = db.get_server_list()
assert serv_name in result
assert all(serv_name in result for serv_name in serv_names)
result = db.get_host_server_list(host)
assert list(result) == [serv_name]
assert list(result) == [server_name]
result = db.get_host_server_list("*")
assert len(result) == 1
assert list(result) == [serv_name]
assert list(result) == [server_name]
result = db.get_instance_name_list(server)
assert list(result) == [server_instance]
assert list(result) == server_instances
result = db.get_instance_name_list("*")
assert server_instance in result
assert all(serv_instance in result for serv_instance in server_instances)
result = db.get_server_class_list(serv_name)
assert list(result) == [class_name]
for serv_name in serv_names:
result = db.get_server_class_list(serv_name)
assert list(result) == [class_name]
result = db.get_server_class_list("*")
assert class_name in result
......@@ -75,33 +77,34 @@ def test_tangodb_getters(beacon, dummy_tango_server):
assert class_name in result
assert "DServer" in result
result = db.get_device_class_list(serv_name)
assert list(result) == [obj_name, class_name]
for i, serv_name in enumerate(serv_names):
obj_name = obj_names[i]
result = db.get_device_class_list(serv_name)
assert list(result) == [obj_name, class_name]
result = db.get_device_name(serv_name, class_name)
assert list(result) == [obj_name]
result = db.get_device_name(serv_name, "*")
assert list(result) == [obj_name]
result = db.get_device_class_list("*")
assert not result
result = db.get_device_name(serv_name, class_name)
assert list(result) == [obj_name]
result = db.get_device_name("*", class_name)
assert list(result) == [obj_name]
result = db.get_device_name(serv_name, "*")
assert list(result) == [obj_name]
assert all(obj_name in result for obj_name in obj_names)
result = db.get_device_name("*", "*")
assert obj_name in result
assert all(obj_name in result for obj_name in obj_names)
result = db.get_device_exported_for_class(class_name)
assert list(result) == [obj_name]
assert list(result) == [obj_names[0]] # only first dummy server is started
result = db.get_device_exported_for_class("*")
assert obj_name in result
assert obj_names[0] in result
result = db.get_device_exported("*")
assert len(result) == 2
assert set(result) == {obj_name, dserver_name}
assert set(result) == {obj_names[0], dserver_names[0]}
result = db.get_device_family("*")
assert family in result
......@@ -109,6 +112,10 @@ def test_tangodb_getters(beacon, dummy_tango_server):
result = db.get_device_domain("*")
assert domain in result
# in next checks, only first dummy server is used
obj_name = obj_names[0]
serv_name = serv_names[0]
result = db.get_class_for_device(obj_name)
assert result == class_name
......@@ -201,3 +208,29 @@ def test_tangodb_setters(beacon, dummy_tango_server):
# db.delete_class_property(class_name, "dummy_cls_property1")
# result = db.get_class_property(class_name, "dummy_cls_property1")
# assert not result["dummy_cls_property1"]
def test_issue2845(beacon, beacon_directory, dummy_tango_server2):
device_fqdn, dev_proxy = dummy_tango_server2
db = Database()
# Dummy device info
domain = "id00"
family = "tango"
name = "dummy2"
obj_name = f"{domain}/{family}/{name}"
assert not db.get_device_property(obj_name, "dummy_property1")["dummy_property1"]
test_file_contents = client.get_text_file("tango/dummy.yml")
assert test_file_contents.endswith(
"tango_name: id00/tango/dummy2\n properties:\n personal_name: dummy2\n server: dummy_tg_server\n"
)
db.put_device_property(obj_name, {"dummy_property1": "test"})
result = db.get_device_property(obj_name, "dummy_property1")
assert list(result["dummy_property1"]) == ["test"]
test_file_contents = client.get_text_file("tango/dummy.yml")
assert test_file_contents.endswith(
"tango_name: id00/tango/dummy2\n properties:\n dummy_property1: test\n personal_name: dummy2\n server: dummy_tg_server\n"
)
......@@ -13,3 +13,10 @@
alias: dummy_alias
personal_name: dummy
server: dummy_tg_server
-
device:
- class: Dummy
tango_name: id00/tango/dummy2
properties:
personal_name: dummy2
server: dummy_tg_server
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment