本文整理汇总了Python中airflow.contrib.operators.dataproc_operator.DataprocClusterCreateOperator.render_template方法的典型用法代码示例。如果您正苦于以下问题:Python DataprocClusterCreateOperator.render_template方法的具体用法?Python DataprocClusterCreateOperator.render_template怎么用?Python DataprocClusterCreateOperator.render_template使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类airflow.contrib.operators.dataproc_operator.DataprocClusterCreateOperator
的用法示例。
在下文中一共展示了DataprocClusterCreateOperator.render_template方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_cluster_name_log_sub
# 需要导入模块: from airflow.contrib.operators.dataproc_operator import DataprocClusterCreateOperator [as 别名]
# 或者: from airflow.contrib.operators.dataproc_operator.DataprocClusterCreateOperator import render_template [as 别名]
def test_cluster_name_log_sub(self):
with patch('airflow.contrib.operators.dataproc_operator.DataProcHook') as mock_hook:
mock_hook.return_value.get_conn = self.mock_conn
dataproc_task = DataprocClusterCreateOperator(
task_id=TASK_ID,
cluster_name='smoke-cluster-{{ ts_nodash }}',
project_id=PROJECT_ID,
num_workers=NUM_WORKERS,
zone=ZONE,
dag=self.dag
)
with patch.object(dataproc_task.log, 'info') as mock_info:
context = { 'ts_nodash' : 'testnodash'}
rendered = dataproc_task.render_template('cluster_name', getattr(dataproc_task,'cluster_name'), context)
setattr(dataproc_task, 'cluster_name', rendered)
with self.assertRaises(TypeError) as _:
dataproc_task.execute(None)
mock_info.assert_called_with('Creating cluster: %s', u'smoke-cluster-testnodash')