chore: proper current_app.config proxy usage (#34345)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Maxime Beauchemin
2025-07-31 19:27:42 -07:00
committed by GitHub
parent 6c9cda758a
commit cb27d5fe8d
144 changed files with 1428 additions and 1119 deletions

View File

@@ -19,9 +19,10 @@ from unittest.mock import Mock, patch
import pandas as pd
import pytest
from flask import current_app
from flask_babel import gettext as __
from superset import app, db, sql_lab
from superset import db, sql_lab
from superset.commands.sql_lab import estimate, export, results
from superset.common.db_query_status import QueryStatus
from superset.errors import ErrorLevel, SupersetError, SupersetErrorType
@@ -89,7 +90,7 @@ class TestQueryEstimationCommand(SupersetTestCase):
assert ex_info.value.error.message == __(
"The query estimation was killed after %(sqllab_timeout)s seconds. It might " # noqa: E501
"be too complex, or the database might be under heavy load.",
sqllab_timeout=app.config["SQLLAB_QUERY_COST_ESTIMATE_TIMEOUT"],
sqllab_timeout=current_app.config["SQLLAB_QUERY_COST_ESTIMATE_TIMEOUT"],
)
def test_run_success(self) -> None:

View File

@@ -14,7 +14,8 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from superset import app
from flask import current_app
from superset.common.db_query_status import QueryStatus
from superset.models.core import Database
from superset.models.sql_lab import Query
@@ -43,12 +44,12 @@ def test_non_async_execute(non_async_example_db: Database, example_query: Query)
assert example_query.tracking_url
assert "/ui/query.html?" in example_query.tracking_url
app.config["TRACKING_URL_TRANSFORMER"] = lambda url, query: url.replace(
current_app.config["TRACKING_URL_TRANSFORMER"] = lambda url, query: url.replace(
"/ui/query.html?", f"/{query.client_id}/"
)
assert f"/{example_query.client_id}/" in example_query.tracking_url
app.config["TRACKING_URL_TRANSFORMER"] = lambda url: url + "&foo=bar"
current_app.config["TRACKING_URL_TRANSFORMER"] = lambda url: url + "&foo=bar"
assert example_query.tracking_url.endswith("&foo=bar")
if non_async_example_db.db_engine_spec.engine_name == "hive":