Пример #1
0
def _db(app):
    """
    Provide the transactional fixtures with access to the database via a Flask-SQLAlchemy
    database connection.
    """
    mock_db = db
    mock_db.init_app(app)
    install_database_extensions()
    run_migrations()
    install_feature_flags()

    install_local_providers()
    clean_all_database()

    return mock_db
Пример #2
0
def _db(app):  # pylint: disable=redefined-outer-name
    """
    Provide the transactional fixtures with access to the database via a Flask-SQLAlchemy
    database connection.
    """
    mock_db = db
    mock_db.init_app(app)
    install_database_extensions(app)
    run_migrations()

    install_activity()
    install_routes(app)
    install_local_providers()
    clean_all_database()

    return mock_db
Пример #3
0
def app():
    app = Flask(  # pylint: disable=redefined-outer-name
        __name__,
        template_folder=Path(pcapi.__path__[0]) / "templates",
    )

    app.config["SQLALCHEMY_DATABASE_URI"] = settings.DATABASE_URL_TEST
    app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
    app.config["SECRET_KEY"] = "@##&6cweafhv3426445"
    app.config["REMEMBER_COOKIE_HTTPONLY"] = False
    app.config["SESSION_COOKIE_HTTPONLY"] = False
    app.config["TESTING"] = True
    app.url_map.strict_slashes = False
    app.json_encoder = EnumJSONEncoder

    login_manager = LoginManager()
    login_manager.init_app(app)
    db.init_app(app)

    app.app_context().push()
    install_database_extensions(app)

    run_migrations()

    install_activity()
    install_routes(app)
    install_local_providers()
    admin.init_app(app)
    install_admin_views(admin, db.session)

    app.mailjet_client = Mock()
    app.redis_client = Mock()
    app.register_blueprint(native_v1, url_prefix="/native/v1")

    JWTManager(app)

    return app
Пример #4
0
def app_fixture():
    from pcapi import flask_app

    app = flask_app.app

    # FIXME: some tests fail without this, for example:
    #   - pytest tests/admin/custom_views/offer_view_test.py
    #   - pytest tests/core/fraud/test_api.py
    # Leave an XXX note about why we need that.
    app.teardown_request_funcs[None].remove(flask_app.remove_db_session)

    with app.app_context():
        app.config["TESTING"] = True

        install_all_routes(app)

        app.register_blueprint(test_blueprint, url_prefix="/test-blueprint")

        install_database_extensions()
        run_migrations()
        install_feature_flags()
        install_local_providers()

        yield app
Пример #5
0
def install_postgres_extensions():
    install_database_extensions()
    logger.info("Database extensions installed")