dheerajturaga commented on code in PR #73763:
URL: https://github.com/apache/airflow/pull/73763#discussion_r4171095456


##########
airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_backfills.py:
##########
@@ -461,6 +462,67 @@ def test_create_backfill(self, repro_act, repro_exp, 
session, dag_maker, test_cl
         }
         check_last_log(session, dag_id="TEST_DAG_1", event="create_backfill", 
logical_date=None)
 
+    @pytest.mark.parametrize(
+        ("drain_dag", "expected_state"),
+        [
+            pytest.param(True, DagSchedulingState.DRAINING, id="drain"),
+            pytest.param(False, DagSchedulingState.PAUSED, id="leave-paused"),
+        ],
+    )
+    def test_create_backfill_on_paused_dag_with_drain_dag(
+        self, session, dag_maker, test_client, drain_dag, expected_state
+    ):
+        with dag_maker(session=session, dag_id="TEST_DAG_1", 
schedule="@daily") as dag:
+            EmptyOperator(task_id="mytask")
+        session.execute(update(DagModel).where(DagModel.dag_id == 
dag.dag_id).values(is_paused=True))
+        session.commit()
+
+        response = test_client.post(
+            url="/backfills",
+            json={
+                "dag_id": dag.dag_id,
+                "from_date": to_iso(pendulum.parse("2024-01-01")),
+                "to_date": to_iso(pendulum.parse("2024-01-03")),
+                "drain_dag": drain_dag,
+            },
+        )
+
+        assert response.status_code == 200
+        session.expire_all()
+        assert session.get(DagModel, dag.dag_id).scheduling_state == 
expected_state
+        assert session.scalar(
+            select(func.count()).select_from(DagRun).where(DagRun.backfill_id 
== response.json()["id"])
+        )
+
+    def test_create_backfill_with_drain_dag_requires_dag_edit_access(

Review Comment:
   Added false and omitted `drain_dag` cases for backfill and materialization 
with denied Dag edit access. Both hook payload tests now cover true and false, 
and the invalidation test titles describe the conditional refresh correctly.
   
   ---
   Drafted-by: Codex (GPT-6); reviewed by @dheerajturaga before posting



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