예제 #1
0
def app() -> Iterator[SupersetApp]:
    """
    A fixture that generates a Superset app.
    """
    app = SupersetApp(__name__)

    app.config.from_object("superset.config")
    app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite://"
    app.config["TESTING"] = True

    # ``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.
    appbuilder.baseviews = []

    app_initializer = SupersetAppInitializer(app)
    app_initializer.init_app()

    # reload base views to ensure error handlers are applied to the app
    with app.app_context():
        import superset.views.base

        importlib.reload(superset.views.base)

    yield app
예제 #2
0
def app(mocker: MockFixture, session: Session) -> Iterator[SupersetApp]:
    """
    A fixture that generates a Superset app.
    """
    app = SupersetApp(__name__)

    app.config.from_object("superset.config")
    app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite://"
    app.config["FAB_ADD_SECURITY_VIEWS"] = False

    app_initializer = app.config.get("APP_INITIALIZER",
                                     SupersetAppInitializer)(app)
    app_initializer.init_app()

    # patch session
    mocker.patch(
        "superset.security.SupersetSecurityManager.get_session",
        return_value=session,
    )
    mocker.patch("superset.db.session", session)

    yield app
예제 #3
0
def app_context(app: SupersetApp) -> Iterator[None]:
    """
    A fixture that yields and application context.
    """
    with app.app_context():
        yield
예제 #4
0
def client(app: SupersetApp) -> Any:
    with app.test_client() as client:
        yield client