コード例 #1
0
    def setUp(self):
        _settings = dict(
            TESTING=True,
            LOGIN_DISABLED=False,
            MAIL_SUPPRESS_SEND=True,
            SERVER_NAME='localhost',
            SQLALCHEMY_DATABASE_URI='sqlite:///:memory:',
            WTF_CSRF_ENABLED=False,
        )

        init_app(app, db, _settings)
        app.app_context().push()
        self.app = app
コード例 #2
0
ファイル: test.py プロジェクト: javierchavez/tcapp
    def setUp(self):
        _settings = dict(
            TESTING=True,               
            LOGIN_DISABLED=False,       
            MAIL_SUPPRESS_SEND=True,    
            SERVER_NAME='localhost',    
            SQLALCHEMY_DATABASE_URI='sqlite:///:memory:', 
            WTF_CSRF_ENABLED=False,    
            )

        init_app(app, db, _settings)
        app.app_context().push()
        self.app = app
コード例 #3
0
ファイル: conftest.py プロジェクト: CloudKitts/planet-hunt
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
コード例 #4
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
コード例 #5
0
ファイル: reset_db.py プロジェクト: ra2003/Flask-User-demo
    # Add users
    print('Adding users')
    user = add_user(app, db, 'admin', 'Admin', 'User', '*****@*****.**',
                    'Password1')
    user.roles.append(admin_role)
    db.session.commit()


def add_user(app, db, username, first_name, last_name, email, password):
    """
    Create UserAuth and User records.
    """
    user_auth = UserAuth(username=username,
                         password=app.user_manager.hash_password(password))
    user = User(
        active=True,
        first_name=first_name,
        # last_name=last_name,
        # email=email,
        # confirmed_at=datetime.datetime.now(),
        user_auth=user_auth)
    db.session.add(user_auth)
    db.session.add(user)
    return user


# Initialize the app and reset the database
if __name__ == "__main__":
    init_app(app, db)
    reset_db(app, db)
コード例 #6
0
# This file starts the WSGI web application.
# - Heroku starts gunicorn, which loads Procfile, which starts runserver.py
# - Developers can run it from the command line: python runserver.py

from app.app_and_db import app, db
from app.startup.init_app import init_app
import os

application = app
init_app(application, db)

# Start a development web server if executed from the command line
if __name__ == "__main__":
    port = int(os.environ.get('PORT', 5000))
    application.run(host='0.0.0.0', port=port, debug=True)
コード例 #7
0
ファイル: runserver.py プロジェクト: lxydotcom/dws
# This file starts the WSGI web application.
# - Heroku starts gunicorn, which loads Procfile, which starts runserver.py
# - Developers can run it from the command line: python runserver.py

from app.app_and_db import app, db
from app.startup.init_app import init_app

init_app(app, db)


# celery config
from celery import Celery
def make_celery(app):
  celery = Celery(app.import_name, broker=app.config['CELERY_BROKER_URL'])
  celery.conf.update(app.config)
  return celery

app.config.update(
  CELERY_BROKER_URL='redis://localhost:6379/0',
  CELERY_RESULT_BACKEND='redis://localhost:6379/0'
)

celery = make_celery(app)
app.celery = celery


# startup provisioning
from app.provisioning.startup import init_app
init_app(app, db)