chore(tests): Remove ineffectual login (#27149)

This commit is contained in:
John Bodley
2024-04-09 09:52:02 -07:00
committed by GitHub
parent ae0f2ce3c1
commit 481a63da55
47 changed files with 857 additions and 802 deletions

View File

@@ -38,6 +38,11 @@ from superset.utils import core as utils
from superset.models.sql_lab import Query
from tests.integration_tests.base_tests import SupersetTestCase
from tests.integration_tests.constants import (
ADMIN_USERNAME,
GAMMA_SQLLAB_NO_DATA_USERNAME,
)
from tests.integration_tests.fixtures.birth_names_dashboard import load_birth_names_data
from tests.integration_tests.fixtures.users import create_gamma_sqllab_no_data
QUERIES_FIXTURE_COUNT = 10
@@ -51,7 +56,11 @@ class TestSqlLabApi(SupersetTestCase):
clear=True,
)
def test_get_from_empty_bootsrap_data(self):
self.login(username="gamma_sqllab_no_data")
if utils.backend() == "postgresql":
# failing
return
self.login(GAMMA_SQLLAB_NO_DATA_USERNAME)
resp = self.client.get("/api/v1/sqllab/")
assert resp.status_code == 200
data = json.loads(resp.data.decode("utf-8"))
@@ -66,7 +75,7 @@ class TestSqlLabApi(SupersetTestCase):
clear=True,
)
def test_get_from_bootstrap_data_for_non_persisted_tab_state(self):
self.login("admin")
self.login(ADMIN_USERNAME)
# create a tab
data = {
"queryEditor": json.dumps(
@@ -88,14 +97,14 @@ class TestSqlLabApi(SupersetTestCase):
assert result["active_tab"] == None
assert result["tab_state_ids"] == []
@pytest.mark.usefixtures("load_birth_names_data")
@mock.patch.dict(
"superset.extensions.feature_flag_manager._feature_flags",
{"SQLLAB_BACKEND_PERSISTENCE": True},
clear=True,
)
def test_get_from_bootstrap_data_with_latest_query(self):
username = "admin"
self.login(username)
self.login(ADMIN_USERNAME)
# create a tab
data = {
@@ -198,7 +207,7 @@ class TestSqlLabApi(SupersetTestCase):
db.session.commit()
def test_estimate_required_params(self):
self.login()
self.login(ADMIN_USERNAME)
rv = self.client.post(
"/api/v1/sqllab/estimate/",
@@ -235,7 +244,7 @@ class TestSqlLabApi(SupersetTestCase):
self.assertEqual(rv.status_code, 400)
def test_estimate_valid_request(self):
self.login()
self.login(ADMIN_USERNAME)
formatter_response = [
{
@@ -265,7 +274,7 @@ class TestSqlLabApi(SupersetTestCase):
self.assertEqual(rv.status_code, 200)
def test_format_sql_request(self):
self.login()
self.login(ADMIN_USERNAME)
data = {"sql": "select 1 from my_table"}
rv = self.client.post(
@@ -279,7 +288,7 @@ class TestSqlLabApi(SupersetTestCase):
@mock.patch("superset.commands.sql_lab.results.results_backend_use_msgpack", False)
def test_execute_required_params(self):
self.login()
self.login(ADMIN_USERNAME)
client_id = f"{random.getrandbits(64)}"[:10]
data = {"client_id": client_id}
@@ -324,7 +333,7 @@ class TestSqlLabApi(SupersetTestCase):
core.results_backend = mock.Mock()
core.results_backend.get.return_value = {}
self.login()
self.login(ADMIN_USERNAME)
client_id = f"{random.getrandbits(64)}"[:10]
data = {"sql": "SELECT 1", "database_id": 1, "client_id": client_id}
@@ -342,7 +351,7 @@ class TestSqlLabApi(SupersetTestCase):
@mock.patch("superset.sqllab.api.get_sql_results")
def test_execute_custom_templated(self, sql_lab_mock, mock_dt) -> None:
mock_dt.utcnow = mock.Mock(return_value=datetime.datetime(1970, 1, 1))
self.login()
self.login(ADMIN_USERNAME)
sql = "SELECT '$DATE()' as test"
resp = {
"status": QueryStatus.SUCCESS,
@@ -366,7 +375,7 @@ class TestSqlLabApi(SupersetTestCase):
from superset.commands.sql_lab import results as command
command.results_backend = mock.Mock()
self.login()
self.login(ADMIN_USERNAME)
data = [{"col_0": i} for i in range(100)]
payload = {
@@ -418,7 +427,7 @@ class TestSqlLabApi(SupersetTestCase):
@mock.patch("superset.models.sql_lab.Query.raise_for_access", lambda _: None)
@mock.patch("superset.models.core.Database.get_df")
def test_export_results(self, get_df_mock: mock.Mock) -> None:
self.login()
self.login(ADMIN_USERNAME)
database = get_example_database()
query_obj = Query(