本文整理汇总了Python中st2common.persistence.trigger.Trigger.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Trigger.get_by_id方法的具体用法?Python Trigger.get_by_id怎么用?Python Trigger.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类st2common.persistence.trigger.Trigger
的用法示例。
在下文中一共展示了Trigger.get_by_id方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_trigger_crud
# 需要导入模块: from st2common.persistence.trigger import Trigger [as 别名]
# 或者: from st2common.persistence.trigger.Trigger import get_by_id [as 别名]
def test_trigger_crud(self):
triggertype = ReactorModelTest._create_save_triggertype()
saved = ReactorModelTest._create_save_trigger(triggertype)
retrieved = Trigger.get_by_id(saved.id)
self.assertEqual(saved.name, retrieved.name, "Same trigger was not returned.")
# test update
self.assertEqual(retrieved.description, "")
retrieved.description = DUMMY_DESCRIPTION
saved = Trigger.add_or_update(retrieved)
retrieved = Trigger.get_by_id(saved.id)
self.assertEqual(retrieved.description, DUMMY_DESCRIPTION, "Update to trigger failed.")
# cleanup
ReactorModelTest._delete([retrieved, triggertype])
try:
retrieved = Trigger.get_by_id(saved.id)
except StackStormDBObjectNotFoundError:
retrieved = None
self.assertIsNone(retrieved, "managed to retrieve after failure.")
示例2: test_trigger_crud
# 需要导入模块: from st2common.persistence.trigger import Trigger [as 别名]
# 或者: from st2common.persistence.trigger.Trigger import get_by_id [as 别名]
def test_trigger_crud(self):
triggertype = ReactorModelTest._create_save_triggertype()
saved = ReactorModelTest._create_save_trigger(triggertype)
retrieved = Trigger.get_by_id(saved.id)
self.assertEqual(saved.name, retrieved.name,
'Same trigger was not returned.')
# test update
self.assertEqual(retrieved.description, '')
retrieved.description = DUMMY_DESCRIPTION
saved = Trigger.add_or_update(retrieved)
retrieved = Trigger.get_by_id(saved.id)
self.assertEqual(retrieved.description, DUMMY_DESCRIPTION, 'Update to trigger failed.')
# cleanup
ReactorModelTest._delete([retrieved, triggertype])
try:
retrieved = Trigger.get_by_id(saved.id)
except ValueError:
retrieved = None
self.assertIsNone(retrieved, 'managed to retrieve after failure.')
示例3: get_trigger_db_by_id
# 需要导入模块: from st2common.persistence.trigger import Trigger [as 别名]
# 或者: from st2common.persistence.trigger.Trigger import get_by_id [as 别名]
def get_trigger_db_by_id(id):
"""
Returns the trigger object from db given a trigger id.
:param ref: Reference to the trigger db object.
:type ref: ``str``
:rtype: ``object``
"""
try:
return Trigger.get_by_id(id)
except StackStormDBObjectNotFoundError as e:
LOG.debug('Database lookup for id="%s" resulted in exception : %s.', id, e, exc_info=True)
return None
示例4: test_create_trigger_db_from_rule_duplicate
# 需要导入模块: from st2common.persistence.trigger import Trigger [as 别名]
# 或者: from st2common.persistence.trigger.Trigger import get_by_id [as 别名]
def test_create_trigger_db_from_rule_duplicate(self):
test_fixtures = {
'rules': ['cron_timer_rule_1.yaml', 'cron_timer_rule_2.yaml']
}
loader = FixturesLoader()
fixtures = loader.load_fixtures(fixtures_pack='generic', fixtures_dict=test_fixtures)
rules = fixtures['rules']
trigger_db_ret_1 = trigger_service.create_trigger_db_from_rule(
RuleAPI(**rules['cron_timer_rule_1.yaml']))
self.assertTrue(trigger_db_ret_1 is not None)
trigger_db_ret_2 = trigger_service.create_trigger_db_from_rule(
RuleAPI(**rules['cron_timer_rule_2.yaml']))
self.assertTrue(trigger_db_ret_2 is not None)
self.assertEqual(trigger_db_ret_1, trigger_db_ret_2, 'Should reuse same trigger.')
trigger_db = Trigger.get_by_id(trigger_db_ret_1.id)
self.assertDictEqual(trigger_db.parameters,
rules['cron_timer_rule_1.yaml']['trigger']['parameters'])
示例5: __get_by_id
# 需要导入模块: from st2common.persistence.trigger import Trigger [as 别名]
# 或者: from st2common.persistence.trigger.Trigger import get_by_id [as 别名]
def __get_by_id(trigger_id):
try:
return Trigger.get_by_id(trigger_id)
except (ValueError, ValidationError):
LOG.exception('Database lookup for id="%s" resulted in exception.', trigger_id)
abort(http_client.NOT_FOUND)