kaxil commented on code in PR #48651:
URL: https://github.com/apache/airflow/pull/48651#discussion_r2026786349
##########
airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_dag_runs.py:
##########
@@ -218,3 +218,99 @@ def test_dag_run_not_found(self, client):
response = client.post(f"/execution/dag-runs/{dag_id}/{run_id}/clear")
assert response.status_code == 404
+
+
+class TestGetDagRunCount:
+ def setup_method(self):
+ clear_db_runs()
+
+ def teardown_method(self):
+ clear_db_runs()
+
+ def test_get_count_basic(self, client, session, dag_maker):
+ with dag_maker("test_dag"):
+ pass
+ dag_maker.create_dagrun()
+ session.commit()
+
+ response = client.get("/execution/dag-runs/count", params={"dag_id":
"test_dag"})
+ assert response.status_code == 200
+ assert response.json() == 1
+
+ def test_get_count_with_states(self, client, session, dag_maker):
+ """Test counting DAG runs in specific states."""
+ with dag_maker("test_get_count_with_states"):
+ pass
+
+ # Create DAG runs with different states
+ dag_maker.create_dagrun(
+ state=State.SUCCESS, logical_date=timezone.datetime(2025, 1, 1),
run_id="test_run_id1"
+ )
+ dag_maker.create_dagrun(
+ state=State.FAILED, logical_date=timezone.datetime(2025, 1, 2),
run_id="test_run_id2"
+ )
+ dag_maker.create_dagrun(
+ state=State.RUNNING, logical_date=timezone.datetime(2025, 1, 3),
run_id="test_run_id3"
+ )
+ session.commit()
+
+ response = client.get(
+ "/execution/dag-runs/count",
+ params={"dag_id": "test_get_count_with_states", "states":
[State.SUCCESS, State.FAILED]},
Review Comment:
I think that's fine since the database will validate that anyway. I just
wanted to test that it goes through to the endpoint
--
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]