[GitHub] [airflow] kaxil commented on issue #8308: Fix Extra Links in Gannt View
kaxil commented on issue #8308: URL: https://github.com/apache/airflow/pull/8308#issuecomment-617463114 Waiting to hear what Ash thinks. The thing I like about your approach @mik-laj is like you said separates testing **templates** and **flask views**. On the other hand, the things we were doing until now is more like system test but I am learning towards what you suggested :) 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: us...@infra.apache.org
[GitHub] [airflow] kaxil commented on issue #8308: Fix Extra Links in Gannt View
kaxil commented on issue #8308: URL: https://github.com/apache/airflow/pull/8308#issuecomment-617461852 > @ashb we can also mock jinja and check template params. POC: #8505 Was able to use the `app_context` and recreate this: ```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={}_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 ) ``` ``` 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: us...@infra.apache.org
[GitHub] [airflow] kaxil commented on issue #8308: Fix Extra Links in Gannt View
kaxil commented on issue #8308: Fix Extra Links in Gannt View URL: https://github.com/apache/airflow/pull/8308#issuecomment-614312645 > Whops, thanks Kaxil. > > The test to add would probably to ensure that the right extra_link name appears in the response. It's very poor test, but it's better than nothing. Added test 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [airflow] kaxil commented on issue #8308: Fix Extra Links in Gannt View
kaxil commented on issue #8308: Fix Extra Links in Gannt View URL: https://github.com/apache/airflow/pull/8308#issuecomment-613717782 > Should we add tests to avoid regression? Was just typing that :D 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: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [airflow] kaxil commented on issue #8308: Fix Extra Links in Gannt View
kaxil commented on issue #8308: Fix Extra Links in Gannt View URL: https://github.com/apache/airflow/pull/8308#issuecomment-613716622 I am not sure how to add a test for this. Any suggestions @ashb ? 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: us...@infra.apache.org With regards, Apache Git Services