MCPcopy Create free account
hub / github.com/FreeOpcUa/python-opcua / test_xml_method

Method test_xml_method

tests/tests_xml.py:73–99  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

71 self.assertEqual(r3.NodeId.NamespaceIndex, ns)
72
73 def test_xml_method(self):
74 self.opc.register_namespace("tititi")
75 self.opc.register_namespace("whatthefuck")
76 o = self.opc.nodes.objects.add_object(2, "xmlexportmethod")
77 m = o.add_method(2, "callme", func, [ua.VariantType.Double, ua.VariantType.String], [ua.VariantType.Float])
78 # set an arg dimension to a list to test list export
79 inputs = m.get_child("InputArguments")
80 val = inputs.get_value()
81 val[0].ArrayDimensions = [2, 2]
82 desc = "My nce description"
83 val[0].Description = ua.LocalizedText(desc)
84 inputs.set_value(val)
85
86 # get all nodes and export
87 nodes = [o, m]
88 nodes.extend(m.get_children())
89 self.opc.export_xml(nodes, "tmp_test_export.xml")
90
91 self.opc.delete_nodes(nodes)
92 self.opc.import_xml("tmp_test_export.xml")
93
94 # now see if our nodes are here
95 val = inputs.get_value()
96 self.assertEqual(len(val), 2)
97
98 self.assertEqual(val[0].ArrayDimensions, [2, 2])
99 self.assertEqual(val[0].Description.Text, desc)
100
101 def test_xml_vars(self):
102 self.opc.register_namespace("tititi")

Callers

nothing calls this directly

Calls 10

get_childMethod · 0.80
get_valueMethod · 0.80
set_valueMethod · 0.80
get_childrenMethod · 0.80
register_namespaceMethod · 0.45
add_objectMethod · 0.45
add_methodMethod · 0.45
export_xmlMethod · 0.45
delete_nodesMethod · 0.45
import_xmlMethod · 0.45

Tested by

no test coverage detected