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


Python TaskHelper.prepare_action_log_kwargs方法代码示例

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


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

示例1: test_prepare_action_log_kwargs_with_web_ctx

# 需要导入模块: from nailgun.task.helpers import TaskHelper [as 别名]
# 或者: from nailgun.task.helpers.TaskHelper import prepare_action_log_kwargs [as 别名]
    def test_prepare_action_log_kwargs_with_web_ctx(self):
        cluster = self.env.create(
            nodes_kwargs=[
                {'roles': ['compute'], 'provisioning': True},
            ]
        )
        task = Task(name='provision', cluster_id=cluster.id)
        self.db.add(task)
        self.db.flush()

        actor_id = 'xx'
        with mock.patch.dict(web.ctx,
                             {'env': {'fuel.action.actor_id': actor_id}}):
            kwargs = TaskHelper.prepare_action_log_kwargs(task)
            self.assertIn('actor_id', kwargs)
            self.assertEqual(actor_id, kwargs['actor_id'])

        with mock.patch.dict(web.ctx, {'env': {}}):
            kwargs = TaskHelper.prepare_action_log_kwargs(task)
            self.assertIn('actor_id', kwargs)
            self.assertIsNone(kwargs['actor_id'])
开发者ID:ekorekin,项目名称:fuel-web,代码行数:23,代码来源:test_task_helpers.py

示例2: test_prepare_action_log_kwargs_without_web_ctx

# 需要导入模块: from nailgun.task.helpers import TaskHelper [as 别名]
# 或者: from nailgun.task.helpers.TaskHelper import prepare_action_log_kwargs [as 别名]
    def test_prepare_action_log_kwargs_without_web_ctx(self):
        self.env.create(
            nodes_kwargs=[
                {'roles': ['compute'], 'pending_addition': True},
                {'roles': ['controller'], 'pending_addition': True},
            ]
        )
        cluster = self.env.clusters[0]
        deployment_task = Task(name='deployment', cluster_id=cluster.id)
        self.db.add(deployment_task)
        self.db.flush()

        # Checking with task without parent
        kwargs = TaskHelper.prepare_action_log_kwargs(deployment_task)
        self.assertIn('actor_id', kwargs)
        self.assertIsNone(kwargs['actor_id'])

        # Checking with empty actor_id in ActionLog
        al_kwargs = TaskHelper.prepare_action_log_kwargs(deployment_task)
        al = objects.ActionLog.create(al_kwargs)

        check_task = Task(name='check_before_deployment',
                          cluster_id=cluster.id,
                          parent_id=deployment_task.id)
        self.db.add(check_task)
        self.db.flush()

        kwargs = TaskHelper.prepare_action_log_kwargs(check_task)
        self.assertIn('actor_id', kwargs)
        self.assertIsNone(kwargs['actor_id'])

        # Checking with actor_id is not None in ActionLog
        actor_id = 'xx'
        al.actor_id = actor_id
        self.db.flush()

        kwargs = TaskHelper.prepare_action_log_kwargs(check_task)
        self.assertIn('actor_id', kwargs)
        self.assertEqual(actor_id, kwargs['actor_id'])
开发者ID:MoArif,项目名称:fuel-web,代码行数:41,代码来源:test_task_helpers.py


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