Exemple #1
0
def app():
    """
    Initializes and returns a Flask application object
    """
    # Initialize the Flask-App with test-specific settings
    test_config_settings = dict(
        TESTING=True,               # Propagate exceptions
        LOGIN_DISABLED=False,       # Enable @register_required
        MAIL_SUPPRESS_SEND=True,    # Disable Flask-Mail send
        SERVER_NAME='localhost',    # Enable url_for() without request context
        SQLALCHEMY_DATABASE_URI='sqlite:///:memory:', # In-memory SQLite DB
        WTF_CSRF_ENABLED=False,     # Disable CSRF form validation
        )
    init_app(flask_app, sqlalchemy_db, test_config_settings)

    # Setup an application context (since the tests run outside of the webserver context)
    flask_app.app_context().push()

    return flask_app
Exemple #2
0
def app():
    """
    Initializes and returns a Flask application object
    """
    # Initialize the Flask-App with test-specific settings
    test_config_settings = dict(
        TESTING=True,  # Propagate exceptions
        LOGIN_DISABLED=False,  # Enable @register_required
        MAIL_SUPPRESS_SEND=True,  # Disable Flask-Mail send
        SERVER_NAME='localhost',  # Enable url_for() without request context
        SQLALCHEMY_DATABASE_URI='sqlite:///:memory:',  # In-memory SQLite DB
        WTF_CSRF_ENABLED=False,  # Disable CSRF form validation
    )
    init_app(flask_app, sqlalchemy_db, test_config_settings)

    # Setup an application context (since the tests run outside of the webserver context)
    flask_app.app_context().push()

    return flask_app
Exemple #3
0
def notify_all_users_task(subject, body):
    with app.app_context():
        recipients = notify_users.get_all_user_recipients()
        notify_users.send_email(recipients, subject, body)