tirkarthi commented on issue #22933: URL: https://github.com/apache/airflow/issues/22933#issuecomment-1095972343
Sample test case, I will submit a PR shortly. ```python def test_task_fail_duration(app, admin_client, dag_maker, session): """Task duration page with a TaskFail entry should render without error.""" with dag_maker() as dag: op1 = BashOperator(task_id='fail', bash_command='sleep 5 && exit 1') op2 = BashOperator(task_id='success', bash_command='exit 0') with pytest.raises(AirflowException): op1.run() op2.run() op1_fails = ( session.query(TaskFail) .filter( TaskFail.task_id == 'fail', TaskFail.dag_id == dag.dag_id, ) .all() ) op2_fails = ( session.query(TaskFail) .filter( TaskFail.task_id == 'success', TaskFail.dag_id == dag.dag_id, ) .all() ) assert len(op1_fails) == 1 assert len(op2_fails) == 0 with unittest.mock.patch.object(app, 'dag_bag') as mocked_dag_bag: mocked_dag_bag.get_dag.return_value = dag resp = admin_client.get(f"dags/{dag.dag_id}/duration", follow_redirects=True) breakpoint() assert resp.status_code == 200 ``` -- 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