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


Python TriggerType.get_all方法代码示例

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


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

示例1: test_register_triggers_from_pack

# 需要导入模块: from st2common.persistence.trigger import TriggerType [as 别名]
# 或者: from st2common.persistence.trigger.TriggerType import get_all [as 别名]
    def test_register_triggers_from_pack(self):
        base_path = get_fixtures_base_path()
        pack_dir = os.path.join(base_path, 'dummy_pack_1')

        trigger_type_dbs = TriggerType.get_all()
        self.assertEqual(len(trigger_type_dbs), 0)

        count = triggers_registrar.register_triggers(pack_dir=pack_dir)
        self.assertEqual(count, 2)

        # Verify TriggerTypeDB and corresponding TriggerDB objects have been created
        trigger_type_dbs = TriggerType.get_all()
        trigger_dbs = Trigger.get_all()
        self.assertEqual(len(trigger_type_dbs), 2)
        self.assertEqual(len(trigger_dbs), 2)

        self.assertEqual(trigger_type_dbs[0].name, 'event_handler')
        self.assertEqual(trigger_type_dbs[0].pack, 'dummy_pack_1')
        self.assertEqual(trigger_dbs[0].name, 'event_handler')
        self.assertEqual(trigger_dbs[0].pack, 'dummy_pack_1')
        self.assertEqual(trigger_dbs[0].type, 'dummy_pack_1.event_handler')

        self.assertEqual(trigger_type_dbs[1].name, 'head_sha_monitor')
        self.assertEqual(trigger_type_dbs[1].pack, 'dummy_pack_1')
        self.assertEqual(trigger_type_dbs[1].payload_schema['type'], 'object')
开发者ID:ddevalco,项目名称:st2,代码行数:27,代码来源:test_triggers_registrar.py

示例2: test_register_all_triggers

# 需要导入模块: from st2common.persistence.trigger import TriggerType [as 别名]
# 或者: from st2common.persistence.trigger.TriggerType import get_all [as 别名]
    def test_register_all_triggers(self):
        trigger_type_dbs = TriggerType.get_all()
        self.assertEqual(len(trigger_type_dbs), 0)

        packs_base_path = get_fixtures_base_path()
        count = triggers_registrar.register_triggers(packs_base_paths=[packs_base_path])
        self.assertEqual(count, 3)

        trigger_type_dbs = TriggerType.get_all()
        self.assertEqual(len(trigger_type_dbs), 3)
开发者ID:E-LLP,项目名称:st2,代码行数:12,代码来源:test_triggers_registrar.py

示例3: test_register_all_triggers

# 需要导入模块: from st2common.persistence.trigger import TriggerType [as 别名]
# 或者: from st2common.persistence.trigger.TriggerType import get_all [as 别名]
    def test_register_all_triggers(self):
        trigger_type_dbs = TriggerType.get_all()
        self.assertEqual(len(trigger_type_dbs), 0)

        packs_base_path = get_fixtures_base_path()
        count = triggers_registrar.register_triggers(packs_base_paths=[packs_base_path])
        self.assertEqual(count, 3)

        # Verify TriggerTypeDB and corresponding TriggerDB objects have been created
        trigger_type_dbs = TriggerType.get_all()
        trigger_dbs = Trigger.get_all()
        self.assertEqual(len(trigger_type_dbs), 3)
        self.assertEqual(len(trigger_dbs), 3)
开发者ID:ddevalco,项目名称:st2,代码行数:15,代码来源:test_triggers_registrar.py

示例4: test_existing_rules_are_loaded_on_start

# 需要导入模块: from st2common.persistence.trigger import TriggerType [as 别名]
# 或者: from st2common.persistence.trigger.TriggerType import get_all [as 别名]
    def test_existing_rules_are_loaded_on_start(self):
        # Assert that we dispatch message for every existing Trigger object
        St2Timer._handle_create_trigger = mock.Mock()

        timer = St2Timer()
        timer._scheduler = mock.Mock()
        timer._trigger_watcher.run = mock.Mock()

        # Verify there are no Trigger and TriggerType in the db wh:w
        self.assertItemsEqual(Trigger.get_all(), [])
        self.assertItemsEqual(TriggerType.get_all(), [])

        # Add a dummy timer Trigger object
        type_ = TIMER_TRIGGER_TYPES.keys()[0]
        parameters = {'unit': 'seconds', 'delta': 1000}
        trigger_db = TriggerDB(id=bson.ObjectId(), name='test_trigger_1', pack='dummy',
                               type=type_, parameters=parameters)
        trigger_db = Trigger.add_or_update(trigger_db)

        # Verify object has been added
        self.assertEqual(len(Trigger.get_all()), 1)

        timer.start()
        timer._trigger_watcher._load_thread.wait()

        # Verify handlers are called
        timer._handle_create_trigger.assert_called_with(trigger_db)
开发者ID:jonico,项目名称:st2,代码行数:29,代码来源:test_timer.py

示例5: test_trigger_types_are_registered_on_start

# 需要导入模块: from st2common.persistence.trigger import TriggerType [as 别名]
# 或者: from st2common.persistence.trigger.TriggerType import get_all [as 别名]
    def test_trigger_types_are_registered_on_start(self):
        timer = St2Timer()
        timer._scheduler = mock.Mock()

        # Verify there are no TriggerType in the db when we start
        self.assertItemsEqual(TriggerType.get_all(), [])

        timer.start()

        # Verify TriggerType objects have been created
        trigger_type_dbs = TriggerType.get_all()
        self.assertEqual(len(trigger_type_dbs), len(TIMER_TRIGGER_TYPES))

        timer_trigger_type_refs = TIMER_TRIGGER_TYPES.keys()

        for trigger_type in trigger_type_dbs:
            ref = ResourceReference(pack=trigger_type.pack, name=trigger_type.name).ref
            self.assertTrue(ref in timer_trigger_type_refs)
开发者ID:jonico,项目名称:st2,代码行数:20,代码来源:test_timer.py

示例6: test_register_sensors

# 需要导入模块: from st2common.persistence.trigger import TriggerType [as 别名]
# 或者: from st2common.persistence.trigger.TriggerType import get_all [as 别名]
    def test_register_sensors(self):
        # Verify DB is empty at the beginning
        self.assertEqual(len(SensorType.get_all()), 0)
        self.assertEqual(len(TriggerType.get_all()), 0)
        self.assertEqual(len(Trigger.get_all()), 0)

        registrar = SensorsRegistrar()
        registrar.register_from_packs(base_dirs=[PACKS_DIR])

        # Verify objects have been created
        sensor_dbs = SensorType.get_all()
        trigger_type_dbs = TriggerType.get_all()
        trigger_dbs = Trigger.get_all()

        self.assertEqual(len(sensor_dbs), 2)
        self.assertEqual(len(trigger_type_dbs), 2)
        self.assertEqual(len(trigger_dbs), 2)

        self.assertEqual(sensor_dbs[0].name, 'TestSensor')
        self.assertEqual(sensor_dbs[0].poll_interval, 10)
        self.assertTrue(sensor_dbs[0].enabled)

        self.assertEqual(sensor_dbs[1].name, 'TestSensorDisabled')
        self.assertEqual(sensor_dbs[1].poll_interval, 10)
        self.assertFalse(sensor_dbs[1].enabled)

        self.assertEqual(trigger_type_dbs[0].name, 'trigger_type_1')
        self.assertEqual(trigger_type_dbs[0].pack, 'pack_with_sensor')
        self.assertEqual(len(trigger_type_dbs[0].tags), 0)
        self.assertEqual(trigger_type_dbs[1].name, 'trigger_type_2')
        self.assertEqual(trigger_type_dbs[1].pack, 'pack_with_sensor')
        self.assertEqual(len(trigger_type_dbs[1].tags), 2)
        self.assertEqual(trigger_type_dbs[1].tags[0].name, 'tag1name')
        self.assertEqual(trigger_type_dbs[1].tags[0].value, 'tag1 value')

        # Verify second call to registration doesn't create a duplicate objects
        registrar.register_from_packs(base_dirs=[PACKS_DIR])

        sensor_dbs = SensorType.get_all()
        trigger_type_dbs = TriggerType.get_all()
        trigger_dbs = Trigger.get_all()

        self.assertEqual(len(sensor_dbs), 2)
        self.assertEqual(len(trigger_type_dbs), 2)
        self.assertEqual(len(trigger_dbs), 2)

        self.assertEqual(sensor_dbs[0].name, 'TestSensor')
        self.assertEqual(sensor_dbs[0].poll_interval, 10)

        self.assertEqual(trigger_type_dbs[0].name, 'trigger_type_1')
        self.assertEqual(trigger_type_dbs[0].pack, 'pack_with_sensor')
        self.assertEqual(trigger_type_dbs[1].name, 'trigger_type_2')
        self.assertEqual(trigger_type_dbs[1].pack, 'pack_with_sensor')

        # Verify sensor and trigger data is updated on registration
        original_load = registrar._meta_loader.load

        def mock_load(*args, **kwargs):
            # Update poll_interval and trigger_type_2 description
            data = original_load(*args, **kwargs)
            data['poll_interval'] = 50
            data['trigger_types'][1]['description'] = 'test 2'
            return data
        registrar._meta_loader.load = mock_load

        registrar.register_from_packs(base_dirs=[PACKS_DIR])

        sensor_dbs = SensorType.get_all()
        trigger_type_dbs = TriggerType.get_all()
        trigger_dbs = Trigger.get_all()

        self.assertEqual(len(sensor_dbs), 2)
        self.assertEqual(len(trigger_type_dbs), 2)
        self.assertEqual(len(trigger_dbs), 2)

        self.assertEqual(sensor_dbs[0].name, 'TestSensor')
        self.assertEqual(sensor_dbs[0].poll_interval, 50)

        self.assertEqual(trigger_type_dbs[0].name, 'trigger_type_1')
        self.assertEqual(trigger_type_dbs[0].pack, 'pack_with_sensor')
        self.assertEqual(trigger_type_dbs[1].name, 'trigger_type_2')
        self.assertEqual(trigger_type_dbs[1].pack, 'pack_with_sensor')
        self.assertEqual(trigger_type_dbs[1].description, 'test 2')
开发者ID:LindsayHill,项目名称:st2,代码行数:85,代码来源:test_sensor_and_rule_registration.py


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