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

Method test_copy_node

tests/tests_common.py:732–753  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

730 self.assertTrue(endpoints[0].EndpointUrl.startswith("opc.tcp://"))
731
732 def test_copy_node(self):
733 dev_t = self.opc.nodes.base_data_type.add_object_type(0, "MyDevice")
734 v_t = dev_t.add_variable(0, "sensor", 1.0)
735 p_t = dev_t.add_property(0, "sensor_id", "0340")
736 ctrl_t = dev_t.add_object(0, "controller")
737 prop_t = ctrl_t.add_property(0, "state", "Running")
738 # Create device sutype
739 devd_t = dev_t.add_object_type(0, "MyDeviceDervived")
740 v_t = devd_t.add_variable(0, "childparam", 1.0)
741 p_t = devd_t.add_property(0, "sensorx_id", "0340")
742
743
744 nodes = copy_node(self.opc.nodes.objects, dev_t)
745 mydevice = nodes[0]
746
747 self.assertEqual(mydevice.get_node_class(), ua.NodeClass.ObjectType)
748 self.assertEqual(len(mydevice.get_children()), 4)
749 obj = mydevice.get_child(["0:controller"])
750 prop = mydevice.get_child(["0:controller", "0:state"])
751 self.assertEqual(prop.get_type_definition().Identifier, ua.ObjectIds.PropertyType)
752 self.assertEqual(prop.get_value(), "Running")
753 self.assertNotEqual(prop.nodeid, prop_t.nodeid)
754
755 def test_instantiate_1(self):
756 # Create device type

Callers

nothing calls this directly

Calls 10

copy_nodeFunction · 0.90
get_node_classMethod · 0.80
get_childrenMethod · 0.80
get_childMethod · 0.80
get_type_definitionMethod · 0.80
get_valueMethod · 0.80
add_object_typeMethod · 0.45
add_variableMethod · 0.45
add_propertyMethod · 0.45
add_objectMethod · 0.45

Tested by

no test coverage detected