eladkal commented on code in PR #62999:
URL: https://github.com/apache/airflow/pull/62999#discussion_r2896694050
##########
tests/models/test_dagrun.py:
##########
@@ -779,6 +779,34 @@ def mutate_task_instance(task_instance):
task = dagrun.get_task_instances()[0]
assert task.queue == "queue1"
+ @mock.patch.object(settings, "task_instance_mutation_hook", autospec=True)
+ def test_task_instance_mutation_hook_has_run_id(self, mock_hook, session):
+ """Test that task_instance_mutation_hook receives a TI with run_id set
(not None).
+
+ Regression test for https://github.com/apache/airflow/issues/61945
+ """
+ observed_run_ids = []
+
+ def mutate_task_instance(task_instance):
+ observed_run_ids.append(task_instance.run_id)
+ if task_instance.run_id and
task_instance.run_id.startswith("manual__"):
+ task_instance.pool = "manual_pool"
+
+ mock_hook.side_effect = mutate_task_instance
+
+ dag = DAG(
+ "test_mutation_hook_run_id",
+ schedule=datetime.timedelta(days=1),
+ start_date=DEFAULT_DATE,
+ )
+ dag.add_task(EmptyOperator(task_id="mutated_task", owner="test"))
+
+ dagrun = self.create_dag_run(dag, session=session)
Review Comment:
```suggestion
self.create_dag_run(dag, session=session)
```
unused so I assume it's not needed
--
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]