potiuk commented on code in PR #60065:
URL: https://github.com/apache/airflow/pull/60065#discussion_r2667318209
##########
airflow-core/tests/unit/serialization/test_dag_serialization.py:
##########
@@ -1639,6 +1639,31 @@ def test_task_resources(self):
assert deserialized_task.resources == task.resources
assert isinstance(deserialized_task.resources, Resources)
+ def test_template_field_via_callable_serialization(self):
+ """
+ Test operator template fields serialization when provided as a
callable.
+ """
+
+ def fn_template_field_callable(context, jinja_env):
+ pass
+
+ def fn_returns_callable():
+ def get_arg(context, jinja_env):
+ pass
+
+ return get_arg
+
+ task = MockOperator(task_id="task1", arg1=fn_template_field_callable,
arg2=fn_returns_callable())
+ serialized_task = OperatorSerialization.serialize_operator(task)
+ assert (
+ serialized_task.get("arg1")
+ == "<function
unit.serialization.test_dag_serialization.TestStringifiedDAGs.test_template_field_via_callable_serialization.<locals>.fn_template_field_callable>"
Review Comment:
```suggestion
== "<callable
unit.serialization.test_dag_serialization.TestStringifiedDAGs.test_template_field_via_callable_serialization.<locals>.fn_template_field_callable>"
```
##########
airflow-core/tests/unit/serialization/test_dag_serialization.py:
##########
@@ -1639,6 +1639,31 @@ def test_task_resources(self):
assert deserialized_task.resources == task.resources
assert isinstance(deserialized_task.resources, Resources)
+ def test_template_field_via_callable_serialization(self):
+ """
+ Test operator template fields serialization when provided as a
callable.
+ """
+
+ def fn_template_field_callable(context, jinja_env):
+ pass
+
+ def fn_returns_callable():
+ def get_arg(context, jinja_env):
+ pass
+
+ return get_arg
+
+ task = MockOperator(task_id="task1", arg1=fn_template_field_callable,
arg2=fn_returns_callable())
+ serialized_task = OperatorSerialization.serialize_operator(task)
+ assert (
+ serialized_task.get("arg1")
+ == "<function
unit.serialization.test_dag_serialization.TestStringifiedDAGs.test_template_field_via_callable_serialization.<locals>.fn_template_field_callable>"
+ )
+ assert (
+ serialized_task.get("arg2")
+ == "<function
unit.serialization.test_dag_serialization.TestStringifiedDAGs.test_template_field_via_callable_serialization.<locals>.fn_returns_callable.<locals>.get_arg>"
Review Comment:
```suggestion
== "<callable
unit.serialization.test_dag_serialization.TestStringifiedDAGs.test_template_field_via_callable_serialization.<locals>.fn_returns_callable.<locals>.get_arg>"
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]