예제 #1
0
def test_unknown_extension_object():
    obj = ua.ExtensionObject()
    obj.Body = b'example of data in custom format'
    obj.TypeId = ua.NodeId.from_string('ns=3;i=42')
    data = ua.utils.Buffer(extensionobject_to_binary(obj))
    obj2 = extensionobject_from_binary(data)
    assert type(obj2) == ua.ExtensionObject
    assert obj2.TypeId == obj.TypeId
    assert obj2.Body == b'example of data in custom format'
예제 #2
0
def test_extension_object():
    obj = ua.UserNameIdentityToken()
    obj.UserName = "******"
    obj.Password = b"pass"
    obj2 = extensionobject_from_binary(ua.utils.Buffer(extensionobject_to_binary(obj)))
    assert type(obj) == type(obj2)
    assert obj.UserName == obj2.UserName
    assert obj.Password == obj2.Password
    v1 = ua.Variant(obj)
    v2 = variant_from_binary(ua.utils.Buffer(variant_to_binary(v1)))
    assert type(v1) == type(v2)
    assert v1.VariantType == v2.VariantType
예제 #3
0
def test_empty_extension_object():
    obj = ua.ExtensionObject()
    obj2 = extensionobject_from_binary(
        ua.utils.Buffer(extensionobject_to_binary(obj)))
    assert type(obj) == type(obj2)
    assert obj == obj2