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


Python executions.get_descendants函数代码示例

本文整理汇总了Python中st2common.services.executions.get_descendants函数的典型用法代码示例。如果您正苦于以下问题:Python get_descendants函数的具体用法?Python get_descendants怎么用?Python get_descendants使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: _get_children

 def _get_children(self, id_, depth=-1, result_fmt=None):
     # make sure depth is int. Url encoding will make it a string and needs to
     # be converted back in that case.
     depth = int(depth)
     LOG.debug('retrieving children for id: %s with depth: %s', id_, depth)
     descendants = execution_service.get_descendants(actionexecution_id=id_,
                                                     descendant_depth=depth,
                                                     result_fmt=result_fmt)
     return [self.model.from_model(descendant) for descendant in descendants]
开发者ID:SamMarkowitz,项目名称:st2,代码行数:9,代码来源:actionexecutions.py

示例2: test_get_all_descendants

    def test_get_all_descendants(self):
        root_execution = self.MODELS['executions']['root_execution.yaml']
        all_descendants = executions_util.get_descendants(str(root_execution.id))

        all_descendants_ids = [str(descendant.id) for descendant in all_descendants]
        all_descendants_ids.sort()

        # everything except the root_execution
        expected_ids = [str(v.id) for _, v in six.iteritems(self.MODELS['executions'])
                        if v.id != root_execution.id]
        expected_ids.sort()

        self.assertListEqual(all_descendants_ids, expected_ids)
开发者ID:ruslantum,项目名称:st2,代码行数:13,代码来源:test_executions_util.py

示例3: test_get_all_descendants_sorted

    def test_get_all_descendants_sorted(self):
        root_execution = self.MODELS['executions']['root_execution.yaml']
        all_descendants = executions_util.get_descendants(str(root_execution.id),
                                                          result_fmt='sorted')

        all_descendants_ids = [str(descendant.id) for descendant in all_descendants]
        all_descendants_ids.sort()

        # everything except the root_execution
        expected_ids = [str(v.id) for _, v in six.iteritems(self.MODELS['executions'])
                        if v.id != root_execution.id]
        expected_ids.sort()

        self.assertListEqual(all_descendants_ids, expected_ids)

        # verify sort order
        for idx in range(len(all_descendants) - 1):
            self.assertLess(all_descendants[idx].start_timestamp,
                            all_descendants[idx + 1].start_timestamp)
开发者ID:ruslantum,项目名称:st2,代码行数:19,代码来源:test_executions_util.py

示例4: test_get_1_level_descendants_sorted

    def test_get_1_level_descendants_sorted(self):
        root_execution = self.MODELS['executions']['root_execution.json']
        all_descendants = executions_util.get_descendants(str(root_execution.id),
                                                          descendant_depth=1,
                                                          result_fmt='sorted')

        all_descendants_ids = [str(descendant.id) for descendant in all_descendants]
        all_descendants_ids.sort()

        # All children of root_execution
        expected_ids = [str(v.id) for _, v in six.iteritems(self.MODELS['executions'])
                        if v.parent == str(root_execution.id)]
        expected_ids.sort()

        self.assertListEqual(all_descendants_ids, expected_ids)

        # verify sort order
        for idx in range(len(all_descendants) - 1):
            self.assertLess(all_descendants[idx].start_timestamp,
                            all_descendants[idx + 1].start_timestamp)
开发者ID:BlazeMediaGroup,项目名称:st2,代码行数:20,代码来源:test_executions_util.py

示例5: test_get_2_level_descendants_sorted

    def test_get_2_level_descendants_sorted(self):
        root_execution = self.MODELS['executions']['root_execution.yaml']
        all_descendants = executions_util.get_descendants(str(root_execution.id),
                                                          descendant_depth=2,
                                                          result_fmt='sorted')

        all_descendants_ids = [str(descendant.id) for descendant in all_descendants]
        all_descendants_ids.sort()

        # All children of root_execution
        root_execution = self.MODELS['executions']['root_execution.yaml']
        expected_ids = []
        traverse = [(child_id, 1) for child_id in root_execution.children]
        while traverse:
            node_id, level = traverse.pop(0)
            expected_ids.append(node_id)
            children = self._get_action_execution(node_id).children
            if children and level < 2:
                traverse.extend([(child_id, level + 1) for child_id in children])
        expected_ids.sort()

        self.assertListEqual(all_descendants_ids, expected_ids)
开发者ID:ruslantum,项目名称:st2,代码行数:22,代码来源:test_executions_util.py


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