Commit 0c6d1123 authored by oroulet's avatar oroulet Committed by oroulet

correctly import/export BytestringNodeId

parent dd351f57
......@@ -487,7 +487,7 @@ class NodeId:
identifier = uuid.UUID(f"urn:uuid:{v}")
elif k == "b":
ntype = NodeIdType.ByteString
identifier = v
identifier = bytes(v, 'utf-8')
elif k == "srv":
srv = int(v)
elif k == "nsu":
......@@ -502,6 +502,7 @@ class NodeId:
string = []
if self.NamespaceIndex != 0:
string.append(f"ns={self.NamespaceIndex}")
identifier = self.Identifier
ntype = None
if self.NodeIdType == NodeIdType.Numeric:
ntype = "i"
......@@ -515,7 +516,8 @@ class NodeId:
ntype = "g"
elif self.NodeIdType == NodeIdType.ByteString:
ntype = "b"
string.append(f"{ntype}={self.Identifier}")
identifier = identifier.decode()
string.append(f"{ntype}={identifier}")
return ";".join(string)
def to_binary(self):
......
......@@ -337,7 +337,15 @@ def test_nodeid_guid_string():
s = n.to_string()
n2 = ua.NodeId.from_string(s)
s2 = n2.to_string()
print(n, n2, s, s2)
assert n == n2
assert s == s2
def test_nodeid_bytestring():
n = ua.ByteStringNodeId(Identifier=b"qwerty", NamespaceIndex=1)
s = n.to_string()
n2 = ua.NodeId.from_string(s)
s2 = n2.to_string()
assert n == n2
assert s == s2
......
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