kaxil edited a comment on issue #8505:
URL: https://github.com/apache/airflow/pull/8505#issuecomment-617461651
I recreated the Extra Links PR:
```python
@mock.patch('airflow.www.views.dagbag.get_dag')
@mock.patch('airflow.www.views.BaseView.render_template')
def test_extra_link_in_gantt_view(self, mock_render_template,
get_dag_function):
from tests.test_utils.mock_operators import Dummy2TestOperator
dag = DAG('ex_dag', start_date=self.default_date)
task = Dummy2TestOperator(task_id="some_dummy_task_2", dag=dag)
get_dag_function.return_value = dag
exec_date = dates.days_ago(2)
start_date = datetime(2020, 4, 10, 2, 0, 0)
end_date = exec_date + timedelta(seconds=30)
with create_session() as session:
for task in dag.tasks:
ti = TaskInstance(task=task, execution_date=exec_date,
state="success")
ti.start_date = start_date
ti.end_date = end_date
session.add(ti)
with self.app.app_context():
mock_render_template.return_value = make_response("RESPONSE",
200)
url = 'gantt?dag_id={}&execution_date={}'.format(dag.dag_id,
exec_date)
self.client.get(url, follow_redirects=True)
mock_render_template.assert_called_once_with(
'airflow/gantt.html',
base_date=mock.ANY, dag=mock.ANY,
data={
'taskNames': ['some_dummy_task_2'],
'tasks': [
{
'task_id': 'some_dummy_task_2',
'dag_id': 'ex_dag',
'execution_date': '2020-04-19T00:00:00+00:00',
'start_date': '2020-04-10T02:00:00+00:00',
'end_date': '2020-04-19T00:00:30+00:00',
'duration': None, 'state': 'success', 'try_number':
1,
'max_tries': 0, 'hostname': '', 'unixname': 'root',
'job_id': None, 'pool': 'default_pool',
'pool_slots': 1, 'queue': 'default',
'priority_weight': 1,
'operator': 'Dummy2TestOperator', 'queued_dttm':
None,
'pid': None, 'executor_config': {},
'extraLinks': ['github', 'airflow']
}
], 'height': 50
},
demo_mode=False,
execution_date=mock.ANY, form=mock.ANY, root=mock.ANY,
scheduler_job=mock.ANY
)
```
arghh we will need to find a way to test individual args such that order of
elements in list or duct doesn't matter.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]