ferruzzi commented on code in PR #74127:
URL: https://github.com/apache/airflow/pull/74127#discussion_r4331499832
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/ui/deadlines.py:
##########
@@ -182,6 +182,10 @@ def get_dag_deadline_alerts(
dag_id: str,
session: SessionDep,
limit: QueryLimit,
+ name: Annotated[
+ FilterParam[str | None],
+ Depends(filter_param_factory(DeadlineAlert.name, str | None)),
+ ],
Review Comment:
Just a thought, I won't block over this, but I think both
`routes/ui/assets.py:89` and `routes/public/pools.py:107` are using
pattern-matching instead of strict matching. What you have is still better
than nothing, but maybe we want to keep it consistent?
##########
airflow-core/tests/unit/api_fastapi/core_api/routes/ui/test_deadlines.py:
##########
@@ -559,20 +577,53 @@ def test_returns_deadline_alerts_for_dag(self,
test_client):
response = test_client.get(f"/dags/{DAG_ID}/deadlineAlerts")
assert response.status_code == 200
data = response.json()
- assert data["total_entries"] == 1
- assert len(data["deadline_alerts"]) == 1
+ assert data["total_entries"] == 2
+ assert len(data["deadline_alerts"]) == 2
def test_alert_response_fields(self, test_client):
"""Alert response includes expected fields with correct values."""
response = test_client.get(f"/dags/{DAG_ID}/deadlineAlerts")
+
assert response.status_code == 200
- alert = response.json()["deadline_alerts"][0]
+
+ data = response.json()
+ alert = next(alert for alert in data["deadline_alerts"] if
alert["name"] == ALERT_NAME)
+
assert alert["name"] == ALERT_NAME
assert alert["interval"] == 3600.0
assert alert["reference_type"] == "DagRunQueuedAtDeadline"
assert "id" in alert
assert "created_at" in alert
+ @pytest.mark.parametrize(
+ ("params", "expected_alerts"),
+ [
+ pytest.param(
+ {"name": ALERT_NAME},
+ [ALERT_NAME],
+ id="matching_name",
+ ),
+ pytest.param(
+ {"name": "does-not-exist"},
+ [],
+ id="no_match",
+ ),
+ ],
+ )
+ def test_filter_by_name(self, test_client, params, expected_alerts):
Review Comment:
Can you add a test with a matching substring, just to be safe?
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/ui/deadlines.py:
##########
Review Comment:
This docstring is no longer true, right?
--
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]