Пример #1
0
 def load_app(self, config):
     """
     Called from the parent class, so we can provide the appropriate flask
     app for this test case.
     """
     app = Flask('test.localhost')
     app.request_class = Request
     app.config.update(config)
     app.register_blueprint(test_views)
     app.central_userdb = UserDB(app.config['MONGO_URI'], 'eduid_am')
     app.session_interface = SessionFactory(app.config)
     return app
Пример #2
0
def init_idproofing_letter_app(name, config=None):
    """
    :param name: The name of the instance, it will affect the configuration loaded.
    :param config: any additional configuration settings. Specially useful
                   in test cases

    :type name: str
    :type config: dict

    :return: the flask app
    :rtype: flask.Flask
    """
    app = Flask(name, static_folder=None)

    # Load configuration
    app.config.from_object('idproofing_letter.settings.common')
    app.config.from_envvar('IDPROOFING_LETTER_SETTINGS', silent=True)
    if config:
        app.config.update(config)

    # Setup logging
    app = init_logging(app)

    # Setup exception handling
    app = init_exception_handlers(app)

    # Register views
    from idproofing_letter.views import idproofing_letter_views
    app.register_blueprint(idproofing_letter_views)

    # Init dbs
    app.central_userdb = UserDB(app.config['MONGO_URI'], 'eduid_am')
    app.proofing_statedb = LetterProofingStateDB(app.config['MONGO_URI'])

    # Init celery
    init_celery(app)

    # Initiate external modules
    app.ekopost = Ekopost(app)

    # Check for secret key
    if app.config['SECRET_KEY'] is None:
        app.logger.error('Missing SECRET_KEY in the settings file')

    app.logger.info('Application initialized')
    return app