ramitkataria commented on code in PR #55241:
URL: https://github.com/apache/airflow/pull/55241#discussion_r2323733099
##########
airflow-core/tests/unit/models/test_deadline.py:
##########
@@ -160,16 +161,38 @@ def test_repr_without_callback_kwargs(self, deadline_orm,
dagrun, session):
)
@pytest.mark.db_test
- def test_handle_miss_async_callback(self, dagrun, deadline_orm, session):
+ @pytest.mark.parametrize(
+ "kwargs",
+ [
+ pytest.param(TEST_CALLBACK_KWARGS, id="non-empty kwargs"),
+ pytest.param(None, id="null kwargs"),
+ ],
+ )
+ def test_handle_miss_async_callback(self, dagrun, session, kwargs):
+ deadline_orm = Deadline(
+ deadline_time=DEFAULT_DATE,
+ callback=AsyncCallback(TEST_CALLBACK_PATH, kwargs),
+ dagrun_id=dagrun.id,
+ )
+ session.add(deadline_orm)
+ session.flush()
deadline_orm.handle_miss(session=session)
session.flush()
assert deadline_orm.trigger_id is not None
-
trigger = session.query(Trigger).filter(Trigger.id ==
deadline_orm.trigger_id).one()
assert trigger is not None
+
assert trigger.kwargs["callback_path"] == TEST_CALLBACK_PATH
- assert trigger.kwargs["callback_kwargs"] == TEST_CALLBACK_KWARGS
+
+ kwargs = trigger.kwargs["callback_kwargs"]
+ context = kwargs.pop("context")
+ assert kwargs == kwargs
+ assert context["deadline"]["id"] == str(deadline_orm.id)
+ assert context["deadline"]["deadline_time"].timestamp() ==
deadline_orm.deadline_time.timestamp()
+ assert all(
+ k in context["dag_run"] for k in {"dag_id", "run_id"} |
set(DagRunDataModel.model_fields.keys())
Review Comment:
I'm explicitly testing for these 2 keys in case something changes because of
this TODO:
https://github.com/apache/airflow/blob/b9937fbbb3243b5ea25b7091bb0394cb8c238761/airflow-core/src/airflow/api_fastapi/execution_api/datamodels/taskinstance.py#L286-L290
Once something changes there, we can make changes to how we fetch the simple
context to make sure these are included
--
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]