feluelle commented on a change in pull request #6573: [AIRFLOW-5904] "Trigger DAG" should redirect to the "dag_default_view" page URL: https://github.com/apache/airflow/pull/6573#discussion_r350731708
########## File path: tests/www/test_views.py ########## @@ -1744,12 +1744,23 @@ def setUp(self): super().setUp() self.session = Session() models.DagBag().get_dag("example_bash_operator").sync_to_db(session=self.session) + self.graph_endpoint = '/graph?dag_id=example_bash_operator' + self.trigger_url = 'origin=%2F{}%3Fdag_id%3Dexample_bash_operator' def test_trigger_dag_button_normal_exist(self): resp = self.client.get('/', follow_redirects=True) self.assertIn('/trigger?dag_id=example_bash_operator', resp.data.decode('utf-8')) self.assertIn("return confirmDeleteDag(this, 'example_bash_operator')", resp.data.decode('utf-8')) + def test_trigger_dag_default_view(self): + resp = self.client.get(self.graph_endpoint, follow_redirects=False) + self.assertIn(self.trigger_url.format('tree'), resp.data.decode('utf-8')) + + def test_trigger_dag_graph_view(self): + conf.set("webserver", "dag_default_view", "graph") Review comment: ```suggestion ``` It is safer to use the conf context manager: ```python with conf_vars({('webserver', 'dag_default_view'): 'graph'}): ... ``` so that value will be reset afterwards. You can also use it as function decorator `@conf_vars({('webserver', 'dag_default_view'): 'graph'})` which in my opinion is even cleaner. ---------------------------------------------------------------- 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