async def test_create_custom_event_type_node(server): etype = await server.create_custom_event_type(2, 'MyEvent1', asyncua.Node(server.iserver.isession, ua.NodeId(ua.ObjectIds.BaseEventType)), [('PropertyNum', ua.VariantType.Int32), ('PropertyString', ua.VariantType.String)]) await check_custom_type(etype, ua.ObjectIds.BaseEventType, server) await server.delete_nodes([etype])
async def test_eventgenerator_source_collision(server): objects = server.get_objects_node() o = await objects.add_object(3, 'MyObject') event = BaseEvent(sourcenode=o.nodeid) evgen = await server.get_event_generator(event, ua.ObjectIds.Server) await check_eventgenerator_base_event(evgen, server) await check_event_generator_object(evgen, o, emitting_node=asyncua.Node(server.iserver.isession, ua.ObjectIds.Server))
async def test_get_event_from_type_node_BaseEvent(server): """ This should work for following BaseEvent tests to work (maybe to write it a bit differentlly since they are not independent) """ ev = await asyncua.common.events.get_event_obj_from_type_node( asyncua.Node(server.iserver.isession, ua.NodeId(ua.ObjectIds.BaseEventType))) check_base_event(ev)
async def check_custom_type(type, base_type, server: Server): base = asyncua.Node(server.iserver.isession, ua.NodeId(base_type)) assert type in await base.get_children() nodes = await type.get_referenced_nodes(refs=ua.ObjectIds.HasSubtype, direction=ua.BrowseDirection.Inverse, includesubtypes=True) assert base == nodes[0] properties = await type.get_properties() assert properties is not None assert len(properties) == 2 assert await type.get_child("2:PropertyNum") in properties assert (await(await type.get_child("2:PropertyNum")).get_data_value()).Value.VariantType == ua.VariantType.Int32 assert await type.get_child("2:PropertyString") in properties assert (await(await type.get_child("2:PropertyString")).get_data_value()).Value.VariantType == ua.VariantType.String
async def test_get_event_from_type_node_Inhereted_AuditEvent(server): ev = await asyncua.common.events.get_event_obj_from_type_node( asyncua.Node(server.iserver.isession, ua.NodeId(ua.ObjectIds.AuditEventType))) # we did not receive event assert ev is not None assert isinstance(ev, BaseEvent) assert isinstance(ev, AuditEvent) assert ev.EventType == ua.NodeId(ua.ObjectIds.AuditEventType) assert ev.Severity == 1 assert ev.ActionTimeStamp is None assert ev.Status == False assert ev.ServerId is None assert ev.ClientAuditEntryId is None assert ev.ClientUserId is None
async def test_get_event_from_type_node_MultiInhereted_AuditOpenSecureChannelEvent(server): ev = await asyncua.common.events.get_event_obj_from_type_node( asyncua.Node(server.iserver.isession, ua.NodeId(ua.ObjectIds.AuditOpenSecureChannelEventType)) ) assert ev is not None assert isinstance(ev, BaseEvent) assert isinstance(ev, AuditEvent) assert isinstance(ev, AuditSecurityEvent) assert isinstance(ev, AuditChannelEvent) assert isinstance(ev, AuditOpenSecureChannelEvent) assert ev.EventType == ua.NodeId(ua.ObjectIds.AuditOpenSecureChannelEventType) assert ev.Severity == 1 assert ev.ClientCertificate is None assert ev.ClientCertificateThumbprint is None assert ev.RequestType is None assert ev.SecurityPolicyUri is None assert ev.SecurityMode is None assert ev.RequestedLifetime is None
async def test_eventgenerator_sourceServer_Node(server): evgen = await server.get_event_generator(emitting_node=asyncua.Node( server.iserver.isession, ua.NodeId(ua.ObjectIds.Server))) await check_eventgenerator_base_event(evgen, server) await check_eventgenerator_source_server(evgen, server)
async def test_eventgenerator_BaseEvent_Node(server): evgen = await server.get_event_generator( asyncua.Node(server.iserver.isession, ua.NodeId(ua.ObjectIds.BaseEventType))) await check_eventgenerator_base_event(evgen, server) await check_eventgenerator_source_server(evgen, server)