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

Method test_xml_import

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

Source from the content-addressed store, hash-verified

24 assertEqual = dir
25
26 def test_xml_import(self):
27 self.opc.import_xml("tests/custom_nodes.xml")
28 o = self.opc.get_objects_node()
29 v = o.get_child(["1:MyXMLFolder", "1:MyXMLObject", "1:MyXMLVariable"])
30 val = v.get_value()
31 self.assertEqual(val, "StringValue")
32
33 node_path = ["Types", "DataTypes", "BaseDataType", "Enumeration",
34 "1:MyEnum", "0:EnumStrings"]
35 o = self.opc.get_root_node().get_child(node_path)
36 self.assertEqual(len(o.get_value()), 3)
37
38 # Check if method is imported
39 node_path = ["Types", "ObjectTypes", "BaseObjectType",
40 "1:MyObjectType", "1:MyMethod"]
41 o = self.opc.get_root_node().get_child(node_path)
42 self.assertEqual(len(o.get_referenced_nodes()), 4)
43
44 # Check if InputArgs are imported and can be read
45 node_path = ["Types", "ObjectTypes", "BaseObjectType",
46 "1:MyObjectType", "1:MyMethod", "InputArguments"]
47 o = self.opc.get_root_node().get_child(node_path)
48 input_arg = o.get_data_value().Value.Value[0]
49 self.assertEqual(input_arg.Name, 'Context')
50
51 def test_xml_import_additional_ns(self):
52 self.srv.register_namespace('http://placeholder.toincrease.nsindex') # if not already shift the new namespaces

Callers

nothing calls this directly

Calls 7

get_childMethod · 0.80
get_valueMethod · 0.80
get_referenced_nodesMethod · 0.80
get_data_valueMethod · 0.80
import_xmlMethod · 0.45
get_objects_nodeMethod · 0.45
get_root_nodeMethod · 0.45

Tested by

no test coverage detected