vatsrahul1001 commented on code in PR #45731:
URL: https://github.com/apache/airflow/pull/45731#discussion_r1922617451


##########
tests/api_fastapi/core_api/routes/public/test_backfills.py:
##########
@@ -264,95 +264,191 @@ def test_no_schedule_dag(self, session, dag_maker, 
test_client):
             url="/public/backfills",
             json=data,
         )
-        assert response.status_code == 409
+        assert response.status_code == 422
         assert response.json().get("detail") == f"{dag.dag_id} has no schedule"
 
-
-class TestCreateBackfillDryRun(TestBackfillEndpoint):
     @pytest.mark.parametrize(
-        "reprocess_behavior, expected_dates",
+        "repro_act, repro_exp, run_backwards, status_code",
         [
-            (
-                "none",
-                [
-                    {"logical_date": "2024-01-01T00:00:00Z"},
-                    {"logical_date": "2024-01-04T00:00:00Z"},
-                    {"logical_date": "2024-01-05T00:00:00Z"},
-                ],
-            ),
-            (
-                "failed",
-                [
-                    {"logical_date": "2024-01-01T00:00:00Z"},
-                    {"logical_date": "2024-01-03T00:00:00Z"},  # Reprocess 
failed
-                    {"logical_date": "2024-01-04T00:00:00Z"},
-                    {"logical_date": "2024-01-05T00:00:00Z"},
-                ],
-            ),
-            (
-                "completed",
-                [
-                    {"logical_date": "2024-01-01T00:00:00Z"},
-                    {"logical_date": "2024-01-02T00:00:00Z"},  # Reprocess all
-                    {"logical_date": "2024-01-03T00:00:00Z"},
-                    {"logical_date": "2024-01-04T00:00:00Z"},
-                    {"logical_date": "2024-01-05T00:00:00Z"},
-                ],
-            ),
+            ("none", ReprocessBehavior.NONE, False, 422),
+            ("completed", ReprocessBehavior.COMPLETED, False, 200),
+            ("completed", ReprocessBehavior.COMPLETED, True, 422),
         ],
     )
-    def test_create_backfill_dry_run(
-        self, session, dag_maker, test_client, reprocess_behavior, 
expected_dates
+    def test_create_backfill_with_depends_on_past(
+        self, repro_act, repro_exp, run_backwards, status_code, session, 
dag_maker, test_client
     ):
-        with dag_maker(
-            session=session,
-            dag_id="TEST_DAG_2",
-            schedule="0 0 * * *",
-            start_date=pendulum.parse("2024-01-01"),
-        ) as dag:
-            EmptyOperator(task_id="mytask")
-
+        with dag_maker(session=session, dag_id="TEST_DAG_1", schedule="0 * * * 
*") as dag:
+            EmptyOperator(task_id="mytask", depends_on_past=True)
+        session.query(DagModel).all()
         session.commit()
+        from_date = pendulum.parse("2024-01-01")
+        from_date_iso = to_iso(from_date)
+        to_date = pendulum.parse("2024-02-01")
+        to_date_iso = to_iso(to_date)
+        max_active_runs = 5
+        data = {
+            "dag_id": dag.dag_id,
+            "from_date": f"{from_date_iso}",
+            "to_date": f"{to_date_iso}",
+            "max_active_runs": max_active_runs,
+            "run_backwards": run_backwards,
+            "dag_run_conf": {"param1": "val1", "param2": True},
+            "dry_run": False,
+            "reprocess_behavior": repro_act,
+        }
+        response = test_client.post(
+            url="/public/backfills",
+            json=data,
+        )
+        assert response.status_code == status_code
 
-        existing_dagruns = [
-            {"logical_date": pendulum.parse("2024-01-02"), "state": 
DagRunState.SUCCESS},  # Completed dag run
-            {"logical_date": pendulum.parse("2024-01-03"), "state": 
DagRunState.FAILED},  # Failed dag run
-        ]
-        for dagrun in existing_dagruns:
-            session.add(
-                DagRun(
-                    dag_id=dag.dag_id,
-                    run_id=f"manual__{dagrun['logical_date'].isoformat()}",
-                    logical_date=dagrun["logical_date"],
-                    state=dagrun["state"],
-                    run_type="scheduled",
+        if response.status_code != 200:
+            if run_backwards:
+                assert (
+                    response.json().get("detail")
+                    == "Backfill cannot be run in reverse when the DAG has 
tasks where depends_on_past=True."
+                )
+            else:
+                assert (
+                    response.json().get("detail")
+                    == f"{dag.dag_id} has tasks for which 
depends_on_past=True. You must set reprocess behavior to reprocess completed or 
reprocess failed."
                 )
-            )
-        session.commit()
 
+
+class TestCreateBackfillDryRun(TestBackfillEndpoint):
+    # @pytest.mark.parametrize(

Review Comment:
   @jason810496 commented by mistake, Fixed this



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