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


Python LiveActionDB.description方法代码示例

本文整理汇总了Python中st2common.models.db.liveaction.LiveActionDB.description方法的典型用法代码示例。如果您正苦于以下问题:Python LiveActionDB.description方法的具体用法?Python LiveActionDB.description怎么用?Python LiveActionDB.description使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在st2common.models.db.liveaction.LiveActionDB的用法示例。


在下文中一共展示了LiveActionDB.description方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_notify_triggers_end_timestamp_none

# 需要导入模块: from st2common.models.db.liveaction import LiveActionDB [as 别名]
# 或者: from st2common.models.db.liveaction.LiveActionDB import description [as 别名]
    def test_notify_triggers_end_timestamp_none(self):
        liveaction_db = LiveActionDB(action='core.local')
        liveaction_db.id = bson.ObjectId()
        liveaction_db.description = ''
        liveaction_db.status = 'succeeded'
        liveaction_db.parameters = {}
        on_success = NotificationSubSchema(message='Action succeeded.')
        on_failure = NotificationSubSchema(message='Action failed.')
        liveaction_db.notify = NotificationSchema(on_success=on_success,
                                                  on_failure=on_failure)
        liveaction_db.start_timestamp = date_utils.get_datetime_utc_now()

        # This tests for end_timestamp being set to None, which can happen when a policy cancels
        # a request.
        # The assertions within "MockDispatcher.dispatch" will validate that the underlying code
        # handles this properly, so all we need to do is keep the call to "notifier.process" below
        liveaction_db.end_timestamp = None
        LiveAction.add_or_update(liveaction_db)

        execution = MOCK_EXECUTION
        execution.liveaction = vars(LiveActionAPI.from_model(liveaction_db))
        execution.status = liveaction_db.status

        dispatcher = NotifierTestCase.MockDispatcher(self)
        notifier = Notifier(connection=None, queues=[], trigger_dispatcher=dispatcher)
        notifier.process(execution)
开发者ID:nzlosh,项目名称:st2,代码行数:28,代码来源:test_notifier.py

示例2: test_notify_triggers_jinja_patterns

# 需要导入模块: from st2common.models.db.liveaction import LiveActionDB [as 别名]
# 或者: from st2common.models.db.liveaction.LiveActionDB import description [as 别名]
    def test_notify_triggers_jinja_patterns(self, dispatch):
        liveaction_db = LiveActionDB(action='core.local')
        liveaction_db.id = bson.ObjectId()
        liveaction_db.description = ''
        liveaction_db.status = 'succeeded'
        liveaction_db.parameters = {'cmd': 'mamma mia', 'runner_foo': 'foo'}
        on_success = NotificationSubSchema(message='Command {{action_parameters.cmd}} succeeded.',
                                           data={'stdout': '{{action_results.stdout}}'})
        liveaction_db.notify = NotificationSchema(on_success=on_success)
        liveaction_db.start_timestamp = date_utils.get_datetime_utc_now()
        liveaction_db.end_timestamp = \
            (liveaction_db.start_timestamp + datetime.timedelta(seconds=50))

        LiveAction.add_or_update(liveaction_db)

        execution = MOCK_EXECUTION
        execution.liveaction = vars(LiveActionAPI.from_model(liveaction_db))
        execution.status = liveaction_db.status

        notifier = Notifier(connection=None, queues=[])
        notifier.process(execution)
        exp = {'status': 'succeeded',
               'start_timestamp': isotime.format(liveaction_db.start_timestamp),
               'route': 'notify.default', 'runner_ref': 'local-shell-cmd',
               'channel': 'notify.default', 'message': u'Command mamma mia succeeded.',
               'data': {'result': '{}', 'stdout': 'stuff happens'},
               'action_ref': u'core.local',
               'execution_id': str(MOCK_EXECUTION.id),
               'end_timestamp': isotime.format(liveaction_db.end_timestamp)}
        dispatch.assert_called_once_with('core.st2.generic.notifytrigger', payload=exp,
                                         trace_context={})
        notifier.process(execution)
开发者ID:nzlosh,项目名称:st2,代码行数:34,代码来源:test_notifier.py

示例3: test_liveaction_create_with_notify_on_success_only

# 需要导入模块: from st2common.models.db.liveaction import LiveActionDB [as 别名]
# 或者: from st2common.models.db.liveaction.LiveActionDB import description [as 别名]
    def test_liveaction_create_with_notify_on_success_only(self):
        created = LiveActionDB()
        created.action = 'core.local'
        created.description = ''
        created.status = 'running'
        created.parameters = {}
        notify_db = NotificationSchema()
        notify_sub_schema = NotificationSubSchema()
        notify_sub_schema.message = 'Action succeeded.'
        notify_sub_schema.data = {
            'foo': 'bar',
            'bar': 1,
            'baz': {'k1': 'v1'}
        }
        notify_db.on_success = notify_sub_schema
        created.notify = notify_db
        saved = LiveActionModelTest._save_liveaction(created)
        retrieved = LiveAction.get_by_id(saved.id)
        self.assertEqual(saved.action, retrieved.action,
                         'Same triggertype was not returned.')

        # Assert notify settings saved are right.
        self.assertEqual(notify_sub_schema.message,
                         retrieved.notify.on_success.message)
        self.assertDictEqual(notify_sub_schema.data, retrieved.notify.on_success.data)
        self.assertListEqual(notify_sub_schema.routes, retrieved.notify.on_success.routes)
        self.assertEqual(retrieved.notify.on_failure, None)
        self.assertEqual(retrieved.notify.on_complete, None)
开发者ID:lyandut,项目名称:st2,代码行数:30,代码来源:test_db_liveaction.py

示例4: test_notify_triggers

# 需要导入模块: from st2common.models.db.liveaction import LiveActionDB [as 别名]
# 或者: from st2common.models.db.liveaction.LiveActionDB import description [as 别名]
    def test_notify_triggers(self):
        liveaction = LiveActionDB(action='core.local')
        liveaction.description = ''
        liveaction.status = 'succeeded'
        liveaction.parameters = {}
        on_success = NotificationSubSchema(message='Action succeeded.')
        on_failure = NotificationSubSchema(message='Action failed.')
        liveaction.notify = NotificationSchema(on_success=on_success,
                                               on_failure=on_failure)
        liveaction.start_timestamp = date_utils.get_datetime_utc_now()

        dispatcher = NotifierTestCase.MockDispatcher(self)
        notifier = Notifier(connection=None, queues=[], trigger_dispatcher=dispatcher)
        notifier.process(liveaction)
开发者ID:ipv1337,项目名称:st2,代码行数:16,代码来源:test_notifier.py

示例5: test_liveaction_create_with_notify_both_on_success_and_on_error

# 需要导入模块: from st2common.models.db.liveaction import LiveActionDB [as 别名]
# 或者: from st2common.models.db.liveaction.LiveActionDB import description [as 别名]
 def test_liveaction_create_with_notify_both_on_success_and_on_error(self):
     created = LiveActionDB()
     created.action = 'core.local'
     created.description = ''
     created.status = 'running'
     created.parameters = {}
     on_success = NotificationSubSchema(message='Action succeeded.')
     on_failure = NotificationSubSchema(message='Action failed.')
     created.notify = NotificationSchema(on_success=on_success,
                                         on_failure=on_failure)
     saved = LiveActionModelTest._save_liveaction(created)
     retrieved = LiveAction.get_by_id(saved.id)
     self.assertEqual(saved.action, retrieved.action,
                      'Same triggertype was not returned.')
     # Assert notify settings saved are right.
     self.assertEqual(on_success.message, retrieved.notify.on_success.message)
     self.assertEqual(on_failure.message, retrieved.notify.on_failure.message)
     self.assertEqual(retrieved.notify.on_complete, None)
开发者ID:lyandut,项目名称:st2,代码行数:20,代码来源:test_db_liveaction.py

示例6: test_notify_triggers

# 需要导入模块: from st2common.models.db.liveaction import LiveActionDB [as 别名]
# 或者: from st2common.models.db.liveaction.LiveActionDB import description [as 别名]
    def test_notify_triggers(self):
        liveaction_db = LiveActionDB(action='core.local')
        liveaction_db.id = bson.ObjectId()
        liveaction_db.description = ''
        liveaction_db.status = 'succeeded'
        liveaction_db.parameters = {}
        on_success = NotificationSubSchema(message='Action succeeded.')
        on_failure = NotificationSubSchema(message='Action failed.')
        liveaction_db.notify = NotificationSchema(on_success=on_success,
                                                  on_failure=on_failure)
        liveaction_db.start_timestamp = date_utils.get_datetime_utc_now()
        liveaction_db.end_timestamp = \
            (liveaction_db.start_timestamp + datetime.timedelta(seconds=50))
        LiveAction.add_or_update(liveaction_db)

        execution = MOCK_EXECUTION
        execution.liveaction = vars(LiveActionAPI.from_model(liveaction_db))
        execution.status = liveaction_db.status

        dispatcher = NotifierTestCase.MockDispatcher(self)
        notifier = Notifier(connection=None, queues=[], trigger_dispatcher=dispatcher)
        notifier.process(execution)
开发者ID:nzlosh,项目名称:st2,代码行数:24,代码来源:test_notifier.py

示例7: test_liveaction_crud_no_notify

# 需要导入模块: from st2common.models.db.liveaction import LiveActionDB [as 别名]
# 或者: from st2common.models.db.liveaction.LiveActionDB import description [as 别名]
    def test_liveaction_crud_no_notify(self):
        created = LiveActionDB()
        created.action = 'core.local'
        created.description = ''
        created.status = 'running'
        created.parameters = {}
        saved = LiveActionModelTest._save_liveaction(created)
        retrieved = LiveAction.get_by_id(saved.id)
        self.assertEqual(saved.action, retrieved.action,
                         'Same triggertype was not returned.')
        self.assertEqual(retrieved.notify, None)

        # Test update
        self.assertTrue(retrieved.end_timestamp is None)
        retrieved.end_timestamp = date_utils.get_datetime_utc_now()
        updated = LiveAction.add_or_update(retrieved)
        self.assertTrue(updated.end_timestamp == retrieved.end_timestamp)
        # Test delete
        LiveActionModelTest._delete([retrieved])
        try:
            retrieved = LiveAction.get_by_id(saved.id)
        except StackStormDBObjectNotFoundError:
            retrieved = None
        self.assertIsNone(retrieved, 'managed to retrieve after failure.')
开发者ID:lyandut,项目名称:st2,代码行数:26,代码来源:test_db_liveaction.py


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