Skip to content

Commit

Permalink
Fix tests where ua.NodeId#from_string was called with trailing semico…
Browse files Browse the repository at this point in the history
…lons

These tests should have asserted that the semicolon was actually part of the resulting NodeId as per OPC-UA spec, because string identifiers may contain arbitrary characters except Unicode control characters (e.g. semicolons).
  • Loading branch information
Galaxy102 authored and oroulet committed Feb 21, 2024
1 parent 2b1edb7 commit 85b56c7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ async def test_add_numeric_variable(opc):

async def test_add_string_variable(opc):
objects = opc.opc.nodes.objects
v = await objects.add_variable("ns=3;s=stringid;", "3:stringnodefromstring", [68])
v = await objects.add_variable("ns=3;s=stringid", "3:stringnodefromstring", [68])
nid = ua.NodeId("stringid", 3)
qn = ua.QualifiedName("stringnodefromstring", 3)
assert nid == v.nodeid
Expand Down Expand Up @@ -612,7 +612,7 @@ async def test_variable_data_type(opc):

async def test_add_string_array_variable(opc):
objects = opc.opc.nodes.objects
v = await objects.add_variable("ns=3;s=stringarrayid;", "9:stringarray", ["l", "b"])
v = await objects.add_variable("ns=3;s=stringarrayid", "9:stringarray", ["l", "b"])
nid = ua.NodeId("stringarrayid", 3)
qn = ua.QualifiedName("stringarray", 9)
assert nid == v.nodeid
Expand Down
4 changes: 2 additions & 2 deletions tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,13 +612,13 @@ def test_numeric_nodeid():


def test_qualifiedstring_nodeid():
nid = ua.NodeId.from_string('ns=2;s=PLC1.Manufacturer;')
nid = ua.NodeId.from_string('ns=2;s=PLC1.Manufacturer')
assert nid.NamespaceIndex == 2
assert nid.Identifier == 'PLC1.Manufacturer'


def test_strrepr_nodeid():
nid = ua.NodeId.from_string('ns=2;s=PLC1.Manufacturer;')
nid = ua.NodeId.from_string('ns=2;s=PLC1.Manufacturer')
assert nid.to_string() == 'ns=2;s=PLC1.Manufacturer'
# assert repr(nid) == 'ns=2;s=PLC1.Manufacturer;'

Expand Down

0 comments on commit 85b56c7

Please sign in to comment.