Example #1
0
    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)
Example #2
0
    def test_get_1_level_descendants_sorted(self):
        root_execution = self.MODELS['executions']['root_execution.yaml']
        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)
Example #3
0
    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,
            )
Example #4
0
 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]
Example #5
0
 def _get_children(self, id_, depth=-1):
     # 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)
     return [
         self.model.from_model(descendant) for descendant in descendants
     ]
Example #6
0
    def _get_children(self, id_, requester_user, depth=-1, result_fmt=None, show_secrets=False):
        # 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)

        mask_secrets = self._get_mask_secrets(requester_user, show_secrets=show_secrets)
        return [self.model.from_model(descendant, mask_secrets=mask_secrets) for
                descendant in descendants]
Example #7
0
    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)
        from_model_kwargs = self._get_from_model_kwargs_for_request(request=pecan.request)
        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, from_model_kwargs) for
                descendant in descendants]
Example #8
0
    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)
Example #9
0
    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)
Example #10
0
    def test_get_1_level_descendants(self):
        root_execution = self.MODELS['executions']['root_execution.json']
        all_descendants = executions_util.get_descendants(str(
            root_execution.id),
                                                          descendant_depth=1)

        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)
    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)
Example #12
0
    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)