kaxil commented on code in PR #47989:
URL: https://github.com/apache/airflow/pull/47989#discussion_r2005207878
##########
task-sdk/tests/task_sdk/execution_time/test_task_runner.py:
##########
@@ -1928,6 +1928,83 @@ def execute(self, context):
assert listener.error == error
[email protected]("mock_supervisor_comms")
+class TestTaskRunnerCallsCallbacks:
+ def test_task_runner_calls_execute_callback(self):
+ results = []
+
+ def custom_callback(context):
+ results.append("callback")
+
+ class CustomOperator(BaseOperator):
+ def execute(self, context):
+ results.append("execute")
+
+ task = CustomOperator(
+ task_id="test_task_runner_calls_execute_callback",
+ on_execute_callback=custom_callback,
+ )
+ dag = get_inline_dag(dag_id="test_task_runner_calls_execute_callback",
task=task)
+ ti = TaskInstance(
+ id=uuid7(),
+ task_id=task.task_id,
+ dag_id=dag.dag_id,
+ run_id="test_task_runner_calls_execute_callback",
+ try_number=1,
+ )
+
+ runtime_ti = RuntimeTaskInstance.model_construct(
+ **ti.model_dump(exclude_unset=True),
+ task=task,
+ start_date=timezone.utcnow(),
+ )
Review Comment:
You could use `create_runtime_ti` fixture
```suggestion
runtime_ti =
create_runtime_ti(dag_id="test_task_runner_calls_execute_callback", task=task)
```
https://github.com/apache/airflow/blob/f4af596beeed2a29fc4e878479f81b90ea8b140c/task-sdk/tests/conftest.py#L330
--
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]