本文整理汇总了Python中st2common.persistence.trigger.TriggerType.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python TriggerType.get_by_id方法的具体用法?Python TriggerType.get_by_id怎么用?Python TriggerType.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类st2common.persistence.trigger.TriggerType
的用法示例。
在下文中一共展示了TriggerType.get_by_id方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_add_trigger_type_with_params
# 需要导入模块: from st2common.persistence.trigger import TriggerType [as 别名]
# 或者: from st2common.persistence.trigger.TriggerType import get_by_id [as 别名]
def test_add_trigger_type_with_params(self):
MOCK_TRIGGER.type = 'system.test'
# Trigger type with params should not create a trigger.
PARAMETERS_SCHEMA = {
"type": "object",
"properties": {
"url": {"type": "string"}
},
"required": ['url'],
"additionalProperties": False
}
trig_type = {
'name': 'myawesometriggertype2',
'pack': 'my_pack_1',
'description': 'Words cannot describe how awesome I am.',
'parameters_schema': PARAMETERS_SCHEMA,
'payload_schema': {}
}
trigtype_dbs = trigger_service.add_trigger_models(trigger_types=[trig_type])
trigger_type, trigger = trigtype_dbs[0]
trigtype_db = TriggerType.get_by_id(trigger_type.id)
self.assertEqual(trigtype_db.pack, 'my_pack_1')
self.assertEqual(trigtype_db.name, trig_type.get('name'))
self.assertEqual(trigger, None)
示例2: test_triggertype_crud
# 需要导入模块: from st2common.persistence.trigger import TriggerType [as 别名]
# 或者: from st2common.persistence.trigger.TriggerType import get_by_id [as 别名]
def test_triggertype_crud(self):
saved = ReactorModelTest._create_save_triggertype()
retrieved = TriggerType.get_by_id(saved.id)
self.assertEqual(saved.name, retrieved.name, "Same triggertype was not returned.")
# test update
self.assertEqual(retrieved.description, "")
retrieved.description = DUMMY_DESCRIPTION
saved = TriggerType.add_or_update(retrieved)
retrieved = TriggerType.get_by_id(saved.id)
self.assertEqual(retrieved.description, DUMMY_DESCRIPTION, "Update to trigger failed.")
# cleanup
ReactorModelTest._delete([retrieved])
try:
retrieved = TriggerType.get_by_id(saved.id)
except StackStormDBObjectNotFoundError:
retrieved = None
self.assertIsNone(retrieved, "managed to retrieve after failure.")
示例3: test_triggertype_crud
# 需要导入模块: from st2common.persistence.trigger import TriggerType [as 别名]
# 或者: from st2common.persistence.trigger.TriggerType import get_by_id [as 别名]
def test_triggertype_crud(self):
saved = ReactorModelTest._create_save_triggertype()
retrieved = TriggerType.get_by_id(saved.id)
self.assertEqual(saved.name, retrieved.name,
'Same triggertype was not returned.')
# test update
self.assertEqual(retrieved.description, '')
retrieved.description = DUMMY_DESCRIPTION
saved = TriggerType.add_or_update(retrieved)
retrieved = TriggerType.get_by_id(saved.id)
self.assertEqual(retrieved.description, DUMMY_DESCRIPTION, 'Update to trigger failed.')
# cleanup
ReactorModelTest._delete([retrieved])
try:
retrieved = TriggerType.get_by_id(saved.id)
except ValueError:
retrieved = None
self.assertIsNone(retrieved, 'managed to retrieve after failure.')
示例4: test_add_trigger_type_no_params
# 需要导入模块: from st2common.persistence.trigger import TriggerType [as 别名]
# 或者: from st2common.persistence.trigger.TriggerType import get_by_id [as 别名]
def test_add_trigger_type_no_params(self):
# Trigger type with no params should create a trigger with same name as trigger type.
trig_type = {
'name': 'myawesometriggertype',
'pack': 'dummy_pack_1',
'description': 'Words cannot describe how awesome I am.',
'parameters_schema': {},
'payload_schema': {}
}
trigtype_dbs = trigger_service.add_trigger_models(trigger_types=[trig_type])
trigger_type, trigger = trigtype_dbs[0]
trigtype_db = TriggerType.get_by_id(trigger_type.id)
self.assertEqual(trigtype_db.pack, 'dummy_pack_1')
self.assertEqual(trigtype_db.name, trig_type.get('name'))
self.assertTrue(trigger is not None)
self.assertEqual(trigger.name, trigtype_db.name)
# Add duplicate
trigtype_dbs = trigger_service.add_trigger_models(trigger_types=[trig_type])
triggers = Trigger.get_all()
self.assertTrue(len(triggers) == 1)