You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ka...@apache.org on 2020/06/23 01:07:32 UTC
[airflow] branch v1-10-test updated: [AIRFLOW-6940] Improve test
isolation in test_views.py (#7564)
This is an automated email from the ASF dual-hosted git repository.
kaxilnaik pushed a commit to branch v1-10-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/v1-10-test by this push:
new c80a35d [AIRFLOW-6940] Improve test isolation in test_views.py (#7564)
c80a35d is described below
commit c80a35d462f8980f1aedcf8fb70900648379a107
Author: Kamil BreguĊa <mi...@users.noreply.github.com>
AuthorDate: Thu Feb 27 11:26:13 2020 +0100
[AIRFLOW-6940] Improve test isolation in test_views.py (#7564)
---
tests/www_rbac/test_views.py | 48 +++++++++-----------------------------------
1 file changed, 9 insertions(+), 39 deletions(-)
diff --git a/tests/www_rbac/test_views.py b/tests/www_rbac/test_views.py
index 116d3d6..a5210f3 100644
--- a/tests/www_rbac/test_views.py
+++ b/tests/www_rbac/test_views.py
@@ -58,8 +58,9 @@ from airflow.utils.db import create_session
from airflow.utils.state import State
from airflow.utils.timezone import datetime
from airflow.www_rbac import app as application
-from tests.test_utils.config import conf_vars
from tests.compat import mock
+from tests.test_utils.config import conf_vars
+from tests.test_utils.db import clear_db_runs
class TestBase(unittest.TestCase):
@@ -71,6 +72,10 @@ class TestBase(unittest.TestCase):
settings.configure_orm()
cls.session = Session
+ @classmethod
+ def tearDownClass(cls):
+ clear_db_runs()
+
def setUp(self):
self.client = self.app.test_client()
self.login()
@@ -379,21 +384,9 @@ class TestAirflowBaseViews(TestBase):
super(TestAirflowBaseViews, self).setUp()
self.logout()
self.login()
- self.cleanup_dagruns()
+ clear_db_runs()
self.prepare_dagruns()
- def cleanup_dagruns(self):
- DR = models.DagRun
- dag_ids = ['example_bash_operator',
- 'example_subdag_operator',
- 'example_xcom']
- (self.session
- .query(DR)
- .filter(DR.dag_id.in_(dag_ids))
- .filter(DR.run_id == self.run_id)
- .delete(synchronize_session='fetch'))
- self.session.commit()
-
def prepare_dagruns(self):
self.bash_dag = self.dagbag.dags['example_bash_operator']
self.sub_dag = self.dagbag.dags['example_subdag_operator']
@@ -1349,17 +1342,6 @@ class TestDagACLView(TestBase):
for dag in dagbag.dags.values():
dag.sync_to_db()
- def cleanup_dagruns(self):
- DR = models.DagRun
- dag_ids = ['example_bash_operator',
- 'example_subdag_operator']
- (self.session
- .query(DR)
- .filter(DR.dag_id.in_(dag_ids))
- .filter(DR.run_id == self.run_id)
- .delete(synchronize_session='fetch'))
- self.session.commit()
-
def prepare_dagruns(self):
dagbag = models.DagBag(include_examples=True)
self.bash_dag = dagbag.dags['example_bash_operator']
@@ -1379,7 +1361,7 @@ class TestDagACLView(TestBase):
def setUp(self):
super(TestDagACLView, self).setUp()
- self.cleanup_dagruns()
+ clear_db_runs()
self.prepare_dagruns()
self.logout()
self.appbuilder.sm.sync_roles()
@@ -2658,21 +2640,9 @@ class TestDecorators(TestBase):
super(TestDecorators, self).setUp()
self.logout()
self.login()
- self.cleanup_dagruns()
+ clear_db_runs()
self.prepare_dagruns()
- def cleanup_dagruns(self):
- DR = models.DagRun
- dag_ids = ['example_bash_operator',
- 'example_subdag_operator',
- 'example_xcom']
- (self.session
- .query(DR)
- .filter(DR.dag_id.in_(dag_ids))
- .filter(DR.run_id == self.run_id)
- .delete(synchronize_session='fetch'))
- self.session.commit()
-
def prepare_dagruns(self):
dagbag = models.DagBag(include_examples=True)
self.bash_dag = dagbag.dags['example_bash_operator']