You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "bbovenzi (via GitHub)" <gi...@apache.org> on 2026/07/06 20:07:13 UTC

Re: [PR] Add Calendar Deadlines API and Data Models [airflow]

bbovenzi commented on code in PR #68604:
URL: https://github.com/apache/airflow/pull/68604#discussion_r3531747669


##########
airflow-core/tests/unit/api_fastapi/core_api/routes/ui/test_calendar.py:
##########
@@ -320,3 +324,182 @@ def test_hourly_calendar_partitioned(self, test_client, query_params, result):
         assert response.status_code == 200
         body = response.json()
         assert body == result
+
+
+_CALLBACK_PATH = "tests.unit.api_fastapi.core_api.routes.ui.test_calendar._noop_callback"
+
+
+async def _noop_callback(**kwargs):
+    """No-op callback used to satisfy Deadline creation in tests."""
+
+
+def _cb() -> AsyncCallback:
+    return AsyncCallback(_CALLBACK_PATH)
+
+
+class TestCalendarDeadlines:
+    """Tests for the GET /calendar/{dag_id}/deadlines endpoint."""
+
+    DAG_NAME = "test_deadlines_calendar_dag"
+
+    @pytest.fixture(autouse=True)
+    def setup_deadlines(self, dag_maker, session) -> None:
+        clear_db_deadline()
+        clear_db_runs()
+        clear_db_dags()
+
+        with dag_maker(self.DAG_NAME, serialized=True, session=session):
+            EmptyOperator(task_id="task")
+
+        # Run 1: one active (non-missed) deadline on Jan 1 2025
+        run1 = dag_maker.create_dagrun(
+            run_id="run_active",
+            state=DagRunState.SUCCESS,
+            run_type=DagRunType.SCHEDULED,
+            logical_date=timezone.datetime(2025, 1, 1),
+            triggered_by=DagRunTriggeredByType.TEST,
+        )
+        session.add(
+            Deadline(
+                deadline_time=timezone.datetime(2025, 1, 1, 12, 0, 0),
+                callback=_cb(),
+                dagrun_id=run1.id,
+                deadline_alert_id=None,
+            )
+        )
+
+        # Run 2: one missed deadline on Jan 2 2025
+        run2 = dag_maker.create_dagrun(
+            run_id="run_missed",
+            state=DagRunState.SUCCESS,
+            run_type=DagRunType.SCHEDULED,
+            logical_date=timezone.datetime(2025, 1, 2),
+            triggered_by=DagRunTriggeredByType.TEST,
+        )
+        missed_dl = Deadline(
+            deadline_time=timezone.datetime(2025, 1, 2, 8, 0, 0),
+            callback=_cb(),
+            dagrun_id=run2.id,
+            deadline_alert_id=None,
+        )
+        missed_dl.missed = True
+        session.add(missed_dl)
+
+        # Run 3: two active deadlines on Jan 1 2025 (same day bucket as run1)

Review Comment:
   Let's add one more missed dagrun on jan 1st to test the multiple states in the same bucket.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org