ephraimbuddy commented on code in PR #29065: URL: https://github.com/apache/airflow/pull/29065#discussion_r1083419076
########## tests/models/test_cleartasks.py: ########## @@ -251,6 +253,94 @@ def test_clear_task_instances_without_dag(self, dag_maker): assert ti1.try_number == 2 assert ti1.max_tries == 2 + def test_clear_task_instances_without_dag_param(self, dag_maker): + with dag_maker( + "test_clear_task_instances_without_dag_param", + start_date=DEFAULT_DATE, + end_date=DEFAULT_DATE + datetime.timedelta(days=10), + ) as dag: + task0 = EmptyOperator(task_id="task0") + task1 = EmptyOperator(task_id="task1", retries=2) + + # Write DAG to the database so it can be found by clear_task_instances(). + SerializedDagModel.write_dag(dag) + + dr = dag_maker.create_dagrun( + state=State.RUNNING, + run_type=DagRunType.SCHEDULED, + ) + + ti0, ti1 = sorted(dr.task_instances, key=lambda ti: ti.task_id) + ti0.refresh_from_task(task0) + ti1.refresh_from_task(task1) + + ti0.run() + ti1.run() + + with create_session() as session: Review Comment: Since this is a new test, I think we should use the `session` fixture instead of the `create_session` ########## tests/models/test_cleartasks.py: ########## @@ -202,9 +203,9 @@ def test_clear_task_instances_without_task(self, dag_maker): # but it works for our case because we specifically constructed test DAGS # in the way that those two sort methods are equivalent qry = session.query(TI).filter(TI.dag_id == dag.dag_id).order_by(TI.task_id).all() - clear_task_instances(qry, session) + clear_task_instances(qry, session, dag=dag) Review Comment: Was this failing? -- 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: commits-unsubscr...@airflow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org