uranusjr commented on code in PR #76825:
URL: https://github.com/apache/airflow/pull/76825#discussion_r4599650675


##########
airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_xcoms.py:
##########
@@ -1380,6 +1381,36 @@ def 
test_parsing_attempt_id_is_not_treated_as_an_archived_task(
         assert "XCom" in response.json()["detail"]["message"]
 
 
+class TestTaskSdkClientGetXCom:
+    """The Task SDK client reads XComs from this tree's Execution API as both 
sides intend."""
+
+    @pytest.fixture(autouse=True)
+    def dag_run(self, dag_maker, session):
+        with dag_maker(dag_id="dag", serialized=True):
+            EmptyOperator(task_id="plain")
+            PythonOperator.partial(task_id="mapped", 
python_callable=str).expand(op_args=[[1], [2]])
+        dag_run = dag_maker.create_dagrun(run_id="runid")
+        for ti in dag_run.get_task_instances(session=session):
+            value = "plain" if ti.task_id == "plain" else ti.region_index
+            session.add(XComModelV2(key=XCOM_RETURN_KEY, value=value, 
task_instance_id=ti.id))
+        session.commit()
+        return dag_run
+
+    @pytest.mark.parametrize(
+        ("task_id", "map_index", "expected"),
+        [
+            pytest.param("mapped", None, [0, 1], id="mapped-omitted"),
+            pytest.param("mapped", 1, 1, id="mapped-one"),
+            pytest.param("plain", None, "plain", id="unmapped-omitted"),
+        ],
+    )
+    def test_get(self, task_id, map_index, expected):
+        client = Client(base_url=None, token="", dry_run=True, 
transport=InProcessExecutionAPI().transport)
+        client.base_url = "http://in-process.invalid/";

Review Comment:
   #77146 isn’t going into `v3-4-test`, so I’ll keep the explicit client here 
for the backport and switch to `task_sdk_client` in #76826.



-- 
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]

Reply via email to