(self)
| 59 | self.assertEqual(k, a.__class__.__name__) |
| 60 | |
| 61 | def test_custom_structs(self): |
| 62 | xmlpath = "tests/example.bsd" |
| 63 | c = StructGenerator() |
| 64 | c.make_model_from_file(xmlpath) |
| 65 | c.save_to_file("tests/structures.py") |
| 66 | import structures as s |
| 67 | |
| 68 | # test with default values |
| 69 | v = s.ScalarValueDataType() |
| 70 | data = struct_to_binary(v) |
| 71 | v2 = struct_from_binary(s.ScalarValueDataType, ua.utils.Buffer(data)) |
| 72 | |
| 73 | |
| 74 | # set some values |
| 75 | v = s.ScalarValueDataType() |
| 76 | v.SbyteValue = 1 |
| 77 | v.ByteValue = 2 |
| 78 | v.Int16Value = 3 |
| 79 | v.UInt16Value = 4 |
| 80 | v.Int32Value = 5 |
| 81 | v.UInt32Value = 6 |
| 82 | v.Int64Value = 7 |
| 83 | v.UInt64Value = 8 |
| 84 | v.FloatValue = 9.0 |
| 85 | v.DoubleValue = 10.0 |
| 86 | v.StringValue = "elleven" |
| 87 | v.DateTimeValue = datetime.utcnow() |
| 88 | #self.GuidValue = uuid.uudib"14" |
| 89 | v.ByteStringValue = b"fifteen" |
| 90 | v.XmlElementValue = ua.XmlElement("<toto>titi</toto>") |
| 91 | v.NodeIdValue = ua.NodeId.from_string("ns=4;i=9999") |
| 92 | #self.ExpandedNodeIdValue = |
| 93 | #self.QualifiedNameValue = |
| 94 | #self.LocalizedTextValue = |
| 95 | #self.StatusCodeValue = |
| 96 | #self.VariantValue = |
| 97 | #self.EnumerationValue = |
| 98 | #self.StructureValue = |
| 99 | #self.Number = |
| 100 | #self.Integer = |
| 101 | #self.UInteger = |
| 102 | |
| 103 | |
| 104 | data = struct_to_binary(v) |
| 105 | v2 = struct_from_binary(s.ScalarValueDataType, ua.utils.Buffer(data)) |
| 106 | self.assertEqual(v.NodeIdValue, v2.NodeIdValue) |
| 107 | |
| 108 | def test_custom_structs_array(self): |
| 109 | xmlpath = "tests/example.bsd" |
nothing calls this directly
no test coverage detected