本文整理汇总了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'])
示例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'])