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

Method test_instantiate_string_nodeid

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

Source from the content-addressed store, hash-verified

801 prop_parent = mydevicederived.get_child(["0:sensor_id"])
802
803 def test_instantiate_string_nodeid(self):
804 # Create device type
805 dev_t = self.opc.nodes.base_object_type.add_object_type(0, "MyDevice2")
806 v_t = dev_t.add_variable(0, "sensor", 1.0)
807 v_t.set_modelling_rule(True)
808 p_t = dev_t.add_property(0, "sensor_id", "0340")
809 p_t.set_modelling_rule(True)
810 ctrl_t = dev_t.add_object(0, "controller")
811 ctrl_t.set_modelling_rule(True)
812 prop_t = ctrl_t.add_property(0, "state", "Running")
813 prop_t.set_modelling_rule(True)
814
815 # instanciate device
816 nodes = instantiate(self.opc.nodes.objects, dev_t, nodeid=ua.NodeId("InstDevice", 2, ua.NodeIdType.String), bname="2:InstDevice")
817 mydevice = nodes[0]
818
819 self.assertEqual(mydevice.get_node_class(), ua.NodeClass.Object)
820 self.assertEqual(mydevice.get_type_definition(), dev_t.nodeid)
821 obj = mydevice.get_child(["0:controller"])
822 obj_nodeid_ident = obj.nodeid.Identifier
823 prop = mydevice.get_child(["0:controller", "0:state"])
824 self.assertEqual(obj_nodeid_ident, "InstDevice.controller")
825 self.assertEqual(prop.get_type_definition().Identifier, ua.ObjectIds.PropertyType)
826 self.assertEqual(prop.get_value(), "Running")
827 self.assertNotEqual(prop.nodeid, prop_t.nodeid)
828
829 def test_variable_with_datatype(self):
830 v1 = self.opc.nodes.objects.add_variable(3, 'VariableEnumType1', ua.ApplicationType.ClientAndServer, datatype=ua.NodeId(ua.ObjectIds.ApplicationType))

Callers

nothing calls this directly

Calls 10

instantiateFunction · 0.90
set_modelling_ruleMethod · 0.80
get_node_classMethod · 0.80
get_type_definitionMethod · 0.80
get_childMethod · 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