rawwar commented on code in PR #42975:
URL: https://github.com/apache/airflow/pull/42975#discussion_r1841698813


##########
tests/api_fastapi/core_api/routes/public/test_dag_run.py:
##########
@@ -254,3 +254,40 @@ def test_delete_dag_run_not_found(self, test_client):
         assert response.status_code == 404
         body = response.json()
         assert body["detail"] == "The DagRun with dag_id: `test_dag1` and 
run_id: `invalid` was not found"
+
+
+class TestClearDagRun:
+    def test_clear_dag_run(self, test_client):
+        response = test_client.post(
+            f"/public/dags/{DAG1_ID}/dagRuns/{DAG1_RUN1_ID}/clear", 
json={"dry_run": False}
+        )
+        assert response.status_code == 200
+        body = response.json()
+        assert body["dag_id"] == DAG1_ID
+        assert body["run_id"] == DAG1_RUN1_ID
+        assert body["state"] == "queued"
+
+    @pytest.mark.parametrize(
+        "body",
+        [{"dry_run": True}, {}],
+    )
+    def test_clear_dag_run_dry_run(self, test_client, body):
+        response = 
test_client.post(f"/public/dags/{DAG1_ID}/dagRuns/{DAG1_RUN1_ID}/clear", 
json=body)
+        assert response.status_code == 200
+        body = response.json()
+        assert body["total_entries"] == 1
+        for each in body["task_instances"]:
+            assert each["state"] is None

Review Comment:
   Yeah. You are right. For some reason, dag.clear is returning task instance 
with None state. I'm looking into it.



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