anishgirianish commented on code in PR #64614:
URL: https://github.com/apache/airflow/pull/64614#discussion_r3043090837
##########
task-sdk/tests/task_sdk/execution_time/test_task_runner.py:
##########
@@ -2106,6 +2106,30 @@ def mock_send_side_effect(*args, **kwargs):
),
)
+ def test_xcom_pull_default_respected_when_no_map_indexes(
+ self,
+ create_runtime_ti,
+ mock_supervisor_comms,
+ ):
+ """Test that ``default`` is returned when map_indexes is not specified
and no XCom is found.
+
+ Previously, ``xcoms.append(None)`` was used unconditionally on the
no-map-indexes
+ path, so a user-supplied ``default`` was silently ignored.
+ """
+
+ class CustomOperator(BaseOperator):
+ def execute(self, context):
+ pass
+
+ task = CustomOperator(task_id="pull_task")
+ runtime_ti = create_runtime_ti(task=task)
+
+ with patch.object(XCom, "get_all") as mock_get_all:
+ mock_get_all.return_value = None
+ result = runtime_ti.xcom_pull(key="missing_key",
task_ids="task_a", default="fallback_value")
+
+ assert result == "fallback_value"
+
Review Comment:
nit: might be nice to also test with a couple of task_ids, one that has
xcom, one that doesn't, just to see default show up in the right spot in the
list
--
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]