You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Taragolis (via GitHub)" <gi...@apache.org> on 2023/02/17 10:37:56 UTC

[GitHub] [airflow] Taragolis commented on a diff in pull request #29586: fix template_fields in the decorator `task.docker`

Taragolis commented on code in PR #29586:
URL: https://github.com/apache/airflow/pull/29586#discussion_r1109602056


##########
tests/providers/docker/decorators/test_docker.py:
##########
@@ -60,6 +60,21 @@ def f(num_results):
         assert isinstance(result, list)
         assert len(result) == 50
 
+    def test_basic_docker_operator_with_template_fields(self, dag_maker):
+        @task.docker(image="python:3.9-slim", container_name='python_{{macros.datetime.now() | ts_nodash}}')
+        def f():
+            import random
+
+            return [random.random() for _ in range(100)]
+
+        with dag_maker():
+            ret = f()
+
+        dr = dag_maker.create_dagrun()
+        ret.operator.run(start_date=dr.execution_date, end_date=dr.execution_date)
+        ti = dr.get_task_instances()[0]
+        assert len(ti.xcom_pull()) == 100
+        

Review Comment:
   We do not test here that python_{{macros.datetime.now() | ts_nodash}}` evaluated to `python_2018-01-01T00:00:00+00:00`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org