This is an automated email from the ASF dual-hosted git repository.

kaxilnaik pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/master by this push:
     new ac12401  Fix tests: Add Default Conns back only when needed (#9679)
ac12401 is described below

commit ac12401efeda16805d9b0ad67148bc0d12752973
Author: Kaxil Naik <[email protected]>
AuthorDate: Mon Jul 6 00:27:36 2020 +0100

    Fix tests: Add Default Conns back only when needed (#9679)
---
 tests/api_connexion/endpoints/test_connection_endpoint.py | 2 +-
 tests/test_utils/db.py                                    | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/tests/api_connexion/endpoints/test_connection_endpoint.py 
b/tests/api_connexion/endpoints/test_connection_endpoint.py
index 4c0af2f..45f38b0 100644
--- a/tests/api_connexion/endpoints/test_connection_endpoint.py
+++ b/tests/api_connexion/endpoints/test_connection_endpoint.py
@@ -34,7 +34,7 @@ class TestConnectionEndpoint(unittest.TestCase):
     def setUp(self) -> None:
         self.client = self.app.test_client()  # type:ignore
         # we want only the connection created here for this test
-        clear_db_connections()
+        clear_db_connections(False)
 
     def tearDown(self) -> None:
         clear_db_connections()
diff --git a/tests/test_utils/db.py b/tests/test_utils/db.py
index 44477cf..cd2ef46 100644
--- a/tests/test_utils/db.py
+++ b/tests/test_utils/db.py
@@ -59,10 +59,11 @@ def clear_db_pools():
         add_default_pool_if_not_exists(session)
 
 
-def clear_db_connections():
+def clear_db_connections(add_default_connections_back=True):
     with create_session() as session:
         session.query(Connection).delete()
-        create_default_connections(session)
+        if add_default_connections_back:
+            create_default_connections(session)
 
 
 def clear_db_variables():

Reply via email to