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


Python DummyOperator.render_template方法代码示例

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


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

示例1: test_render_template_field_undefined_strict

# 需要导入模块: from airflow.operators.dummy_operator import DummyOperator [as 别名]
# 或者: from airflow.operators.dummy_operator.DummyOperator import render_template [as 别名]
    def test_render_template_field_undefined_strict(self):
        """Tests if render_template from a field works"""

        dag = DAG('test-dag',
                  start_date=DEFAULT_DATE,
                  template_undefined=jinja2.StrictUndefined)

        with dag:
            task = DummyOperator(task_id='op1')

        with self.assertRaises(jinja2.UndefinedError):
            task.render_template('', '{{ foo }}', {})
开发者ID:alrolorojas,项目名称:airflow,代码行数:14,代码来源:test_dag.py

示例2: test_render_template_field

# 需要导入模块: from airflow.operators.dummy_operator import DummyOperator [as 别名]
# 或者: from airflow.operators.dummy_operator.DummyOperator import render_template [as 别名]
    def test_render_template_field(self):
        """Tests if render_template from a field works"""

        dag = DAG('test-dag',
                  start_date=DEFAULT_DATE)

        with dag:
            task = DummyOperator(task_id='op1')

        result = task.render_template('', '{{ foo }}', dict(foo='bar'))
        self.assertEqual(result, 'bar')
开发者ID:ludovicc,项目名称:airflow,代码行数:13,代码来源:models.py

示例3: test_render_template_field_macro

# 需要导入模块: from airflow.operators.dummy_operator import DummyOperator [as 别名]
# 或者: from airflow.operators.dummy_operator.DummyOperator import render_template [as 别名]
    def test_render_template_field_macro(self):
        """ Tests if render_template from a field works,
            if a custom filter was defined"""

        dag = DAG('test-dag',
                  start_date=DEFAULT_DATE,
                  user_defined_macros = dict(foo='bar'))

        with dag:
            task = DummyOperator(task_id='op1')

        result = task.render_template('', '{{ foo }}', dict())
        self.assertEqual(result, 'bar')
开发者ID:ludovicc,项目名称:airflow,代码行数:15,代码来源:models.py

示例4: test_render_template_datetime_field

# 需要导入模块: from airflow.operators.dummy_operator import DummyOperator [as 别名]
# 或者: from airflow.operators.dummy_operator.DummyOperator import render_template [as 别名]
    def test_render_template_datetime_field(self):
        """Tests if render_template from a datetime field works"""

        dag = DAG('test-dag',
                  start_date=DEFAULT_DATE)

        with dag:
            task = DummyOperator(task_id='op1')

        self.assertEqual(
            task.render_template('', datetime.datetime(2018, 12, 6, 10, 55), {'foo': 'bar'}),
            datetime.datetime(2018, 12, 6, 10, 55)
        )
开发者ID:alrolorojas,项目名称:airflow,代码行数:15,代码来源:test_dag.py

示例5: test_render_template_dict_field

# 需要导入模块: from airflow.operators.dummy_operator import DummyOperator [as 别名]
# 或者: from airflow.operators.dummy_operator.DummyOperator import render_template [as 别名]
    def test_render_template_dict_field(self):
        """Tests if render_template from a dict field works"""

        dag = DAG('test-dag',
                  start_date=DEFAULT_DATE)

        with dag:
            task = DummyOperator(task_id='op1')

        self.assertDictEqual(
            task.render_template('', {'key1': '{{ foo }}_1', 'key2': '{{ foo }}_2'}, {'foo': 'bar'}),
            {'key1': 'bar_1', 'key2': 'bar_2'}
        )
开发者ID:alrolorojas,项目名称:airflow,代码行数:15,代码来源:test_dag.py

示例6: test_render_template_list_field

# 需要导入模块: from airflow.operators.dummy_operator import DummyOperator [as 别名]
# 或者: from airflow.operators.dummy_operator.DummyOperator import render_template [as 别名]
    def test_render_template_list_field(self):
        """Tests if render_template from a list field works"""

        dag = DAG('test-dag',
                  start_date=DEFAULT_DATE)

        with dag:
            task = DummyOperator(task_id='op1')

        self.assertListEqual(
            task.render_template('', ['{{ foo }}_1', '{{ foo }}_2'], {'foo': 'bar'}),
            ['bar_1', 'bar_2']
        )
开发者ID:alrolorojas,项目名称:airflow,代码行数:15,代码来源:test_dag.py

示例7: test_render_template_object_field

# 需要导入模块: from airflow.operators.dummy_operator import DummyOperator [as 别名]
# 或者: from airflow.operators.dummy_operator.DummyOperator import render_template [as 别名]
    def test_render_template_object_field(self):
        """Tests if render_template from an object field works"""

        dag = DAG('test-dag',
                  start_date=DEFAULT_DATE)

        with dag:
            task = DummyOperator(task_id='op1')

        test_object = object()
        self.assertIs(
            task.render_template('', test_object, {'foo': 'bar'}),
            test_object
        )
开发者ID:alrolorojas,项目名称:airflow,代码行数:16,代码来源:test_dag.py

示例8: test_render_template_UUID_field

# 需要导入模块: from airflow.operators.dummy_operator import DummyOperator [as 别名]
# 或者: from airflow.operators.dummy_operator.DummyOperator import render_template [as 别名]
    def test_render_template_UUID_field(self):
        """Tests if render_template from a UUID field works"""

        dag = DAG('test-dag',
                  start_date=DEFAULT_DATE)

        with dag:
            task = DummyOperator(task_id='op1')

        random_uuid = uuid.uuid4()
        self.assertIs(
            task.render_template('', random_uuid, {'foo': 'bar'}),
            random_uuid
        )
开发者ID:alrolorojas,项目名称:airflow,代码行数:16,代码来源:test_dag.py

示例9: test_render_template_dict_field_with_templated_keys

# 需要导入模块: from airflow.operators.dummy_operator import DummyOperator [as 别名]
# 或者: from airflow.operators.dummy_operator.DummyOperator import render_template [as 别名]
    def test_render_template_dict_field_with_templated_keys(self):
        """Tests if render_template from a dict field works as expected:
        dictionary keys are not templated"""

        dag = DAG('test-dag',
                  start_date=DEFAULT_DATE)

        with dag:
            task = DummyOperator(task_id='op1')

        self.assertDictEqual(
            task.render_template('', {'key_{{ foo }}_1': 1, 'key_2': '{{ foo }}_2'}, {'foo': 'bar'}),
            {'key_{{ foo }}_1': 1, 'key_2': 'bar_2'}
        )
开发者ID:alrolorojas,项目名称:airflow,代码行数:16,代码来源:test_dag.py

示例10: test_render_template_field_filter

# 需要导入模块: from airflow.operators.dummy_operator import DummyOperator [as 别名]
# 或者: from airflow.operators.dummy_operator.DummyOperator import render_template [as 别名]
    def test_render_template_field_filter(self):
        """ Tests if render_template from a field works,
            if a custom filter was defined"""

        def jinja_udf(name):
            return 'Hello %s' %name

        dag = DAG('test-dag',
                  start_date=DEFAULT_DATE,
                  user_defined_filters = dict(hello=jinja_udf))

        with dag:
            task = DummyOperator(task_id='op1')

        result = task.render_template('', "{{ 'world' | hello}}", dict())
        self.assertEqual(result, 'Hello world')
开发者ID:ludovicc,项目名称:airflow,代码行数:18,代码来源:models.py


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