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


Python Trigger.get_by_id方法代码示例

本文整理汇总了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.")
开发者ID:rlugojr,项目名称:st2,代码行数:20,代码来源:test_db.py

示例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.')
开发者ID:azamsheriff,项目名称:st2,代码行数:21,代码来源:test_db.py

示例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
开发者ID:rlugojr,项目名称:st2,代码行数:17,代码来源:triggers.py

示例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'])
开发者ID:lyandut,项目名称:st2,代码行数:20,代码来源:test_trigger_services.py

示例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)
开发者ID:StackStorm,项目名称:st2,代码行数:8,代码来源:triggers.py


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