feat: add denylist for db engines (#21486)

This commit is contained in:
Elizabeth Thompson
2022-10-08 19:45:21 -07:00
committed by GitHub
parent aef6217a80
commit f58227a912
4 changed files with 106 additions and 2 deletions

View File

@@ -21,6 +21,7 @@ import os
from typing import Any, Callable, Iterator
import pytest
from _pytest.fixtures import SubRequest
from pytest_mock import MockFixture
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
@@ -68,7 +69,7 @@ def session(get_session) -> Iterator[Session]:
@pytest.fixture(scope="module")
def app() -> Iterator[SupersetApp]:
def app(request: SubRequest) -> Iterator[SupersetApp]:
"""
A fixture that generates a Superset app.
"""
@@ -82,6 +83,11 @@ def app() -> Iterator[SupersetApp]:
app.config["PREVENT_UNSAFE_DB_CONNECTIONS"] = False
app.config["TESTING"] = True
# loop over extra configs passed in by tests
if request and hasattr(request, "param"):
for key, val in request.param.items():
app.config[key] = val
# ``superset.extensions.appbuilder`` is a singleton, and won't rebuild the
# routes when this fixture is called multiple times; we need to clear the
# registered views to ensure the initialization can happen more than once.