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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]