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

Method test_custom_structs_array

tests/tests_unit.py:108–154  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

106 self.assertEqual(v.NodeIdValue, v2.NodeIdValue)
107
108 def test_custom_structs_array(self):
109 xmlpath = "tests/example.bsd"
110 c = StructGenerator()
111 c.make_model_from_file(xmlpath)
112 c.save_to_file("tests/structures.py")
113 import structures as s
114
115 # test with default values
116 v = s.ArrayValueDataType()
117 data = struct_to_binary(v)
118 v2 = struct_from_binary(s.ArrayValueDataType, ua.utils.Buffer(data))
119
120
121 # set some values
122 v = s.ArrayValueDataType()
123 v.SbyteValue = [1]
124 v.ByteValue = [2]
125 v.Int16Value = [3]
126 v.UInt16Value = [4]
127 v.Int32Value = [5]
128 v.UInt32Value = [6]
129 v.Int64Value = [7]
130 v.UInt64Value = [8]
131 v.FloatValue = [9.0]
132 v.DoubleValue = [10.0]
133 v.StringValue = ["elleven"]
134 v.DateTimeValue = [datetime.utcnow()]
135 #self.GuidValue = uuid.uudib"14"
136 v.ByteStringValue = [b"fifteen", b"sixteen"]
137 v.XmlElementValue = [ua.XmlElement("<toto>titi</toto>")]
138 v.NodeIdValue = [ua.NodeId.from_string("ns=4;i=9999"), ua.NodeId.from_string("i=6")]
139 #self.ExpandedNodeIdValue =
140 #self.QualifiedNameValue =
141 #self.LocalizedTextValue =
142 #self.StatusCodeValue =
143 #self.VariantValue =
144 #self.EnumerationValue =
145 #self.StructureValue =
146 #self.Number =
147 #self.Integer =
148 #self.UInteger =
149
150
151 data = struct_to_binary(v)
152 v2 = struct_from_binary(s.ArrayValueDataType, ua.utils.Buffer(data))
153 self.assertEqual(v.NodeIdValue, v2.NodeIdValue)
154 print(v2.NodeIdValue)
155
156 def test_nodeid_nsu(self):
157 n = ua.NodeId(100, 2)

Callers

nothing calls this directly

Calls 6

make_model_from_fileMethod · 0.95
save_to_fileMethod · 0.95
StructGeneratorClass · 0.90
struct_to_binaryFunction · 0.90
struct_from_binaryFunction · 0.90
from_stringMethod · 0.45

Tested by

no test coverage detected