本文整理匯總了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