本文整理汇总了Python中interface.services.dm.iuser_notification_service.UserNotificationServiceClient.create_detection_filter方法的典型用法代码示例。如果您正苦于以下问题:Python UserNotificationServiceClient.create_detection_filter方法的具体用法?Python UserNotificationServiceClient.create_detection_filter怎么用?Python UserNotificationServiceClient.create_detection_filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类interface.services.dm.iuser_notification_service.UserNotificationServiceClient
的用法示例。
在下文中一共展示了UserNotificationServiceClient.create_detection_filter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: UserNotificationIntTest
# 需要导入模块: from interface.services.dm.iuser_notification_service import UserNotificationServiceClient [as 别名]
# 或者: from interface.services.dm.iuser_notification_service.UserNotificationServiceClient import create_detection_filter [as 别名]
#.........这里部分代码省略.........
# these IndexError exceptions happen only because the message sometimes
# has successive /r/n (i.e. new lines) and therefore,
# the indexing goes out of range. These new lines
# can just be ignored. So we ignore the exceptions here.
pass
#-------------------------------------------------------
# make assertions
#-------------------------------------------------------
self.assertEquals(msg_tuple[1], '[email protected]' )
#self.assertEquals(msg_tuple[0], ION_NOTIFICATION_EMAIL_ADDRESS)
self.assertEquals(message_dict['Description'].rstrip('\r'), 'RLE test event')
@attr('LOCOINT')
@unittest.skipIf(os.getenv('CEI_LAUNCH_TEST', False), 'Skip test while in CEI LAUNCH mode')
def test_event_detection(self):
proc1 = self.container.proc_manager.procs_by_name['user_notification']
# Create a user and get the user_id
user = UserInfo(name = 'new_user')
user_id, _ = self.rrc.create(user)
# Create detection notification
dfilt = DetectionFilterConfig()
dfilt.processing['condition'] = 5
dfilt.processing['comparator'] = '>'
dfilt.processing['filter_field'] = 'voltage'
dfilt.delivery['message'] = 'I got my detection event!'
notification_id = self.unsc.create_detection_filter(event_type='ExampleDetectableEvent',
event_subtype=None,
origin='Some_Resource_Agent_ID1',
origin_type=None,
user_id=user_id,
filter_config=dfilt
)
#---------------------------------------------------------------------------------
# Create event subscription for resulting detection event
#---------------------------------------------------------------------------------
# Create an email notification so that when the DetectionEventProcessor
# detects an event and fires its own output event, this will caught by an
# EmailEventProcessor and an email will be sent to the user
notification_id_2 = self.unsc.create_email(event_type='DetectionEvent',
event_subtype=None,
origin='DetectionEventProcessor',
origin_type=None,
user_id=user_id,
email='[email protected]',
mode = DeliveryMode.UNFILTERED,
message_header='Detection event',
parser='parser',
period=1)
# Send event that is not detected
# publish an event for each notification to generate the emails
rle_publisher = EventPublisher("ExampleDetectableEvent")
# since the voltage field in this event is less than 5, it will not be detected