예제 #1
0
def cli_create_app(_):
    # Flask's default click integration silences exceptions thrown by
    # create_app, which IMO isn't so awesome. so this gets around that.
    env = os.getenv('FLASK_ENV')

    if _should_create_basic_app(env):
        return AppFactory.create_basic_app()

    try:
        return AppFactory.create_app(env)
    except:
        print(format_exc())
        clear_env_vars()
        sys.exit(1)
예제 #2
0
def app(bundles, db_ext):
    if (bundles and 'tests._bundles.custom_extension' not in bundles
            and 'flask_sqlalchemy_bundle' not in bundles):
        bundles.insert(0, 'flask_sqlalchemy_bundle')

    unchained._reset()
    app = AppFactory.create_app(TEST, bundles=bundles)
    ctx = app.app_context()
    ctx.push()
    yield app
    ctx.pop()

    if PRIOR_FLASK_ENV:
        os.environ['FLASK_ENV'] = PRIOR_FLASK_ENV
    else:
        del os.environ['FLASK_ENV']
예제 #3
0
def app(request, bundles):
    """
    Automatically used test fixture. Returns the application instance-under-test with
    a valid app context.
    """
    unchained._reset()
    options = request.keywords.get('options', None)
    if options is not None:
        options = {k.upper(): v for k, v in options.kwargs.items()}
    app = AppFactory.create_app(TEST,
                                bundles=bundles,
                                _config_overrides=options)
    ctx = app.app_context()
    ctx.push()
    yield app
    ctx.pop()
예제 #4
0
def app(request, bundles):
    """
    Automatically used test fixture. Returns the application instance-under-test with
    a valid app context.
    """
    unchained._reset()

    options = {}
    for mark in request.node.iter_markers('options'):
        kwargs = getattr(mark, 'kwargs', {})
        options.update({k.upper(): v for k, v in kwargs.items()})

    app = AppFactory.create_app(TEST, bundles=bundles, _config_overrides=options)
    ctx = app.app_context()
    ctx.push()
    yield app
    ctx.pop()
예제 #5
0
def app(bundles, db_ext, request):
    if (bundles and 'tests.bundles.sqlalchemy._bundles.custom_extension'
            not in bundles
            and 'flask_unchained.bundles.sqlalchemy' not in bundles):
        bundles.insert(0, 'flask_unchained.bundles.sqlalchemy')

    options = request.keywords.get('options', None)
    if options is not None:
        options = {k.upper(): v for k, v in options.kwargs.items()}
    app = AppFactory.create_app(TEST,
                                bundles=bundles,
                                _config_overrides=options)
    ctx = app.app_context()
    ctx.push()
    yield app
    ctx.pop()

    if PRIOR_FLASK_ENV:
        os.environ['FLASK_ENV'] = PRIOR_FLASK_ENV
    else:
        del os.environ['FLASK_ENV']
    del os.environ['SQLA_TESTING']
예제 #6
0
def app(bundles, db_ext, request):
    if (bundles and 'tests.bundles.sqlalchemy._bundles.custom_extension'
            not in bundles
            and 'flask_unchained.bundles.sqlalchemy' not in bundles):
        bundles.insert(0, 'flask_unchained.bundles.sqlalchemy')

    options = {}
    for mark in request.node.iter_markers('options'):
        kwargs = getattr(mark, 'kwargs', {})
        options.update({k.upper(): v for k, v in kwargs.items()})

    app = AppFactory.create_app(TEST,
                                bundles=bundles,
                                _config_overrides=options)
    ctx = app.app_context()
    ctx.push()
    yield app
    ctx.pop()

    if PRIOR_FLASK_ENV:
        os.environ['FLASK_ENV'] = PRIOR_FLASK_ENV
    else:
        del os.environ['FLASK_ENV']
    del os.environ['SQLA_TESTING']
예제 #7
0
def app():
    app = AppFactory.create_app(TEST)
    ctx = app.app_context()
    ctx.push()
    yield app
    ctx.pop()
import os

from flask_unchained import AppFactory, PROD

# import the celery extension so that celery can access it for its startup
from flask_unchained.bundles.celery import celery

app = AppFactory().create_app(os.getenv('FLASK_ENV', PROD))
app.app_context().push()
예제 #9
0
import os

from flask_unchained import AppFactory, PROD
from flask_unchained.bundles.celery import celery

app = AppFactory.create_app(os.getenv('FLASK_ENV', PROD))
app.app_context().push()