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

Method test_xml_import_additional_ns

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

Source from the content-addressed store, hash-verified

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
53
54 # "tests/custom_nodes.xml" isn't created with namespaces in mind, provide new test file
55 self.opc.import_xml("tests/custom_nodesns.xml") # the ns=1 in to file now should be mapped to ns=2
56
57 ns = self.opc.get_namespace_index("http://examples.freeopcua.github.io/")
58 o = self.opc.get_objects_node()
59
60 o2 = o.get_child(["{0:d}:MyBaseObject".format(ns)])
61
62 self.assertIsNotNone(o2)
63
64 v1 = o.get_child(["{0:d}:MyBaseObject".format(ns), "{0:d}:MyVar".format(ns)])
65 self.assertIsNotNone(v1)
66
67 r1 = o2.get_references(refs=ua.ObjectIds.HasComponent)[0]
68 self.assertEqual(r1.NodeId.NamespaceIndex, ns)
69
70 r3 = v1.get_references(refs=ua.ObjectIds.HasComponent)[0]
71 self.assertEqual(r3.NodeId.NamespaceIndex, ns)
72
73 def test_xml_method(self):
74 self.opc.register_namespace("tititi")

Callers

nothing calls this directly

Calls 6

get_childMethod · 0.80
get_referencesMethod · 0.80
register_namespaceMethod · 0.45
import_xmlMethod · 0.45
get_namespace_indexMethod · 0.45
get_objects_nodeMethod · 0.45

Tested by

no test coverage detected