当前位置: 首页>>代码示例>>Python>>正文


Python UserNotificationServiceClient.create_detection_filter方法代码示例

本文整理汇总了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
开发者ID:dstuebe,项目名称:coi-services,代码行数:70,代码来源:user_notification_test.py


注:本文中的interface.services.dm.iuser_notification_service.UserNotificationServiceClient.create_detection_filter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。