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

maximebeauchemin pushed a commit to branch main_db_not_needed
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git

commit 70e0a37c92f34c55045320c867ce1082f53bfd4c
Author: Maxime Beauchemin <[email protected]>
AuthorDate: Mon Aug 19 21:18:25 2019 -0700

    removing get_main_database
---
 superset/utils/core.py | 10 ----------
 tests/base_tests.py    |  6 ++----
 tests/celery_tests.py  | 12 ++++++------
 3 files changed, 8 insertions(+), 20 deletions(-)

diff --git a/superset/utils/core.py b/superset/utils/core.py
index c341f08..446a507 100644
--- a/superset/utils/core.py
+++ b/superset/utils/core.py
@@ -942,10 +942,6 @@ def user_label(user: User) -> Optional[str]:
     return None
 
 
-def get_or_create_main_db():
-    get_main_database()
-
-
 def get_or_create_db(database_name, sqlalchemy_uri, *args, **kwargs):
     from superset import db
     from superset.models import core as models
@@ -963,12 +959,6 @@ def get_or_create_db(database_name, sqlalchemy_uri, *args, 
**kwargs):
     return database
 
 
-def get_main_database():
-    from superset import conf
-
-    return get_or_create_db("main", conf.get("SQLALCHEMY_DATABASE_URI"))
-
-
 def get_example_database():
     from superset import conf
 
diff --git a/tests/base_tests.py b/tests/base_tests.py
index 0f84456..8fc96cc 100644
--- a/tests/base_tests.py
+++ b/tests/base_tests.py
@@ -28,7 +28,7 @@ from superset.connectors.druid.models import DruidCluster, 
DruidDatasource
 from superset.connectors.sqla.models import SqlaTable
 from superset.models import core as models
 from superset.models.core import Database
-from superset.utils.core import get_example_database, get_main_database
+from superset.utils.core import get_example_database
 
 BASE_DIR = app.config.get("BASE_DIR")
 
@@ -169,9 +169,7 @@ class SupersetTestCase(unittest.TestCase):
                 security_manager.del_permission_role(public_role, perm)
 
     def _get_database_by_name(self, database_name="main"):
-        if database_name == "main":
-            return get_main_database()
-        elif database_name == "examples":
+        if database_name == "examples":
             return get_example_database()
         else:
             raise ValueError("Database doesn't exist")
diff --git a/tests/celery_tests.py b/tests/celery_tests.py
index 7935448..82f21e7 100644
--- a/tests/celery_tests.py
+++ b/tests/celery_tests.py
@@ -28,7 +28,7 @@ from superset.db_engine_specs.base import BaseEngineSpec
 from superset.models.helpers import QueryStatus
 from superset.models.sql_lab import Query
 from superset.sql_parse import ParsedQuery
-from superset.utils.core import get_main_database
+from superset.utils.core import get_example_database
 from .base_tests import SupersetTestCase
 
 
@@ -132,14 +132,14 @@ class CeleryTestCase(SupersetTestCase):
         return json.loads(resp.data)
 
     def test_run_sync_query_dont_exist(self):
-        main_db = get_main_database()
+        main_db = get_example_database()
         db_id = main_db.id
         sql_dont_exist = "SELECT name FROM table_dont_exist"
         result1 = self.run_sql(db_id, sql_dont_exist, "1", cta="true")
         self.assertTrue("error" in result1)
 
     def test_run_sync_query_cta(self):
-        main_db = get_main_database()
+        main_db = get_example_database()
         backend = main_db.backend
         db_id = main_db.id
         tmp_table_name = "tmp_async_22"
@@ -162,7 +162,7 @@ class CeleryTestCase(SupersetTestCase):
             self.assertGreater(len(results["data"]), 0)
 
     def test_run_sync_query_cta_no_data(self):
-        main_db = get_main_database()
+        main_db = get_example_database()
         db_id = main_db.id
         sql_empty_result = "SELECT * FROM ab_user WHERE id=666"
         result3 = self.run_sql(db_id, sql_empty_result, "3")
@@ -183,7 +183,7 @@ class CeleryTestCase(SupersetTestCase):
         return self.run_sql(db_id, sql)
 
     def test_run_async_query(self):
-        main_db = get_main_database()
+        main_db = get_example_database()
         db_id = main_db.id
 
         self.drop_table_if_exists("tmp_async_1", main_db)
@@ -216,7 +216,7 @@ class CeleryTestCase(SupersetTestCase):
         self.assertEqual(True, query.select_as_cta_used)
 
     def test_run_async_query_with_lower_limit(self):
-        main_db = get_main_database()
+        main_db = get_example_database()
         db_id = main_db.id
         self.drop_table_if_exists("tmp_async_2", main_db)
 

Reply via email to