本文整理汇总了Python中st2common.models.db.liveaction.LiveActionDB.end_timestamp方法的典型用法代码示例。如果您正苦于以下问题:Python LiveActionDB.end_timestamp方法的具体用法?Python LiveActionDB.end_timestamp怎么用?Python LiveActionDB.end_timestamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类st2common.models.db.liveaction.LiveActionDB
的用法示例。
在下文中一共展示了LiveActionDB.end_timestamp方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_notify_triggers_jinja_patterns
# 需要导入模块: from st2common.models.db.liveaction import LiveActionDB [as 别名]
# 或者: from st2common.models.db.liveaction.LiveActionDB import end_timestamp [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)
示例2: test_notify_triggers_end_timestamp_none
# 需要导入模块: from st2common.models.db.liveaction import LiveActionDB [as 别名]
# 或者: from st2common.models.db.liveaction.LiveActionDB import end_timestamp [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)
示例3: test_notify_triggers
# 需要导入模块: from st2common.models.db.liveaction import LiveActionDB [as 别名]
# 或者: from st2common.models.db.liveaction.LiveActionDB import end_timestamp [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()
liveaction.end_timestamp = liveaction.start_timestamp + datetime.timedelta(seconds=50)
dispatcher = NotifierTestCase.MockDispatcher(self)
notifier = Notifier(connection=None, queues=[], trigger_dispatcher=dispatcher)
notifier.process(liveaction)
示例4: test_notify_triggers
# 需要导入模块: from st2common.models.db.liveaction import LiveActionDB [as 别名]
# 或者: from st2common.models.db.liveaction.LiveActionDB import end_timestamp [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)