flask.ext.script.Manager

Here are the examples of the python api flask.ext.script.Manager taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

49 Examples 7

Example 1

Project: flask-script Source File: tests.py
Function: test_with_default_commands
    def test_with_default_commands(self):

        manager = Manager(self.app)
        manager.set_defaults()

        assert 'runserver' in manager._commands
        assert 'shell' in manager._commands

Example 2

Project: flask-script Source File: tests.py
Function: test_without_default_commands
    def test_without_default_commands(self):

        manager = Manager(self.app, with_default_commands=False)
        manager.set_defaults()

        assert 'runserver' not in manager._commands
        assert 'shell' not in manager._commands

Example 3

Project: flask-script Source File: tests.py
Function: test_add_command
    def test_add_command(self):

        manager = Manager(self.app)
        manager.add_command('simple', SimpleCommand())

        assert isinstance(manager._commands['simple'], SimpleCommand)

Example 4

Project: flask-script Source File: tests.py
    def test_add_named_command(self):

        manager = Manager(self.app)
        manager.add_command(NamedCommand())

        assert 'named' in manager._commands
        assert isinstance(manager._commands['named'], NamedCommand)

Example 5

Project: flask-script Source File: tests.py
    def test_add_explicit_named_command(self):

        manager = Manager(self.app)
        manager.add_command(ExplicitNamedCommand())

        name = ExplicitNamedCommand.name
        assert name in manager._commands
        assert isinstance(manager._commands[name], ExplicitNamedCommand)

Example 6

Project: flask-script Source File: tests.py
    def test_add_namespaced_command(self):

        manager = Manager(self.app)
        manager.add_command('one', NamespacedCommand())
        manager.add_command('two', NamespacedCommand())

        assert 'ns' in manager._commands
        assert isinstance(manager._commands['ns'], Manager)
        ns = manager._commands['ns']
        assert isinstance(ns._commands['one'], NamespacedCommand)
        assert isinstance(ns._commands['two'], NamespacedCommand)

Example 7

Project: flask-script Source File: tests.py
    def test_add_namespaced_simple_command(self):

        manager = Manager(self.app)
        manager.add_command('hello', SimpleCommand(), namespace='ns')
        manager.add_command('world', SimpleCommand(), namespace='ns')

        assert 'ns' in manager._commands
        assert isinstance(manager._commands['ns'], Manager)
        ns = manager._commands['ns']
        assert isinstance(ns._commands['hello'], SimpleCommand)
        assert isinstance(ns._commands['world'], SimpleCommand)

Example 8

Project: flask-script Source File: tests.py
    def test_add_command_class(self):

        manager = Manager(self.app)
        manager.add_command('simple', SimpleCommand)

        assert isinstance(manager._commands['simple'], SimpleCommand)

Example 9

Project: flask-script Source File: tests.py
Function: test_simple_command_decorator
    def test_simple_command_decorator(self, capsys):

        manager = Manager(self.app)

        @manager.command
        def hello():
            print('hello')

        assert 'hello' in manager._commands

        code = run('manage.py hello', manager.run)
        out, err = capsys.readouterr()
        assert 'hello' in out

Example 10

Project: flask-script Source File: tests.py
Function: test_simple_command_decorator_with_pos_arg
    def test_simple_command_decorator_with_pos_arg(self, capsys):

        manager = Manager(self.app)

        @manager.command
        def hello(name):
            print('hello ' + name)

        assert 'hello' in manager._commands

        code = run('manage.py hello joe', manager.run)
        out, err = capsys.readouterr()
        assert 'hello joe' in out

Example 11

Project: flask-script Source File: tests.py
    def test_method_command_decorator_with_pos_arg(self, capsys):

        manager = Manager(self.app)

        class SomeTest(object):
            def hello(self,name):
                print('hello ' + name)
        sometest = SomeTest()
        manager.command(sometest.hello)

        assert 'hello' in manager._commands

        code = run('manage.py hello joe', lambda: manager.run())
        out, err = capsys.readouterr()
        assert 'hello joe' in out

Example 12

Project: flask-script Source File: tests.py
    def test_global_option_provided_before_and_after_command(self, capsys):

        manager = Manager(self.app)
        manager.add_option('-c', '--config', dest='config_name', required=False, default='Development')
        manager.add_command('simple', SimpleCommand())

        assert isinstance(manager._commands['simple'], SimpleCommand)

        code = run('manage.py -c Development simple', manager.run)
        out, err = capsys.readouterr()
        assert code == 0
        assert 'OK' in out

        code = run('manage.py simple -c Development', manager.run)
        out, err = capsys.readouterr()
        assert code == 2
        assert 'OK' not in out

Example 13

Project: flask-script Source File: tests.py
    def test_global_option_value(self, capsys):

        def create_app(config_name='Empty'):
            print(config_name)
            return self.app

        manager = Manager(create_app)
        manager.add_option('-c', '--config', dest='config_name', required=False, default='Development')
        manager.add_command('simple', SimpleCommand())

        assert isinstance(manager._commands['simple'], SimpleCommand)

        code = run('manage.py simple', manager.run)
        out, err = capsys.readouterr()
        assert code == 0
        assert 'Empty' not in out  # config_name is overwritten by default option value
        assert 'Development' in out
        assert 'OK' in out

Example 14

Project: flask-script Source File: tests.py
Function: test_get_usage
    def test_get_usage(self):

        manager = Manager(self.app)
        manager.add_command('simple', SimpleCommand())

        usage = manager.create_parser('manage.py').format_help()
        assert 'simple command' in usage

Example 15

Project: flask-script Source File: tests.py
Function: test_get_usage_with_specified_usage
    def test_get_usage_with_specified_usage(self):

        manager = Manager(self.app, usage='hello')
        manager.add_command('simple', SimpleCommand())

        usage = manager.create_parser('manage.py').format_help()
        assert 'simple command' in usage
        assert 'hello' in usage

Example 16

Project: flask-script Source File: tests.py
Function: test_run_existing_command
    def test_run_existing_command(self, capsys):

        manager = Manager(self.app)
        manager.add_command('simple', SimpleCommand())
        code = run('manage.py simple', manager.run)
        out, err = capsys.readouterr()
        assert 'OK' in out

Example 17

Project: flask-script Source File: tests.py
Function: test_run_non_existant_command
    def test_run_non_existant_command(self, capsys):

        manager = Manager(self.app)
        run('manage.py simple', manager.run)
        out, err = capsys.readouterr()
        assert 'invalid choice' in err

Example 18

Project: flask-script Source File: tests.py
Function: test_run_existing
    def test_run_existing(self, capsys):

        manager = Manager(self.app)
        manager.add_command('simple', SimpleCommand())

        code = run('manage.py simple', manager.run)
        out, err = capsys.readouterr()
        assert 0 == code
        assert 'OK' in out

Example 19

Project: flask-script Source File: tests.py
Function: test_run_existing_bind_later
    def test_run_existing_bind_later(self, capsys):

        manager = Manager(self.app)

        code = run('manage.py simple', lambda: manager.run({'simple': SimpleCommand()}))
        out, err = capsys.readouterr()
        assert code == 0
        assert 'OK' in out

Example 20

Project: flask-script Source File: tests.py
Function: test_run_not_existing
    def test_run_not_existing(self, capsys):

        manager = Manager(self.app)

        code = run('manage.py simple', manager.run)
        out, err = capsys.readouterr()
        assert code == 2
        assert 'OK' not in out

Example 21

Project: flask-script Source File: tests.py
Function: test_run_no_name
    def test_run_no_name(self, capsys):

        manager = Manager(self.app)
        manager.add_command('simple', SimpleCommand())

        code = run('manage.py', manager.run)
        out, err = capsys.readouterr()
        assert code == 2
        assert 'simple command' in out

Example 22

Project: flask-script Source File: tests.py
Function: test_run_good_options
    def test_run_good_options(self, capsys):

        manager = Manager(self.app)
        manager.add_command('simple', CommandWithOptions())

        code = run('manage.py simple --name=Joe', manager.run)
        out, err = capsys.readouterr()
        assert code == 0
        assert 'Joe' in out

Example 23

Project: flask-script Source File: tests.py
Function: test_run_dynamic_options
    def test_run_dynamic_options(self, capsys):

        manager = Manager(self.app)
        manager.add_command('simple', CommandWithDynamicOptions('Fred'))

        code = run('manage.py simple', manager.run)
        out, err = capsys.readouterr()
        assert code == 0
        assert 'Fred' in out

Example 24

Project: flask-script Source File: tests.py
Function: test_run_catch_all
    def test_run_catch_all(self, capsys):
        manager = Manager(self.app)
        manager.add_command('catch', CommandWithCatchAll())

        code = run('manage.py catch pos1 --foo pos2 --bar', manager.run)
        out, err = capsys.readouterr()
        out_list = [o.strip('u\'') for o in out.strip('[]\n').split(', ')]
        assert code == 0
        assert ['pos1', 'pos2', '--bar'] == out_list

Example 25

Project: flask-script Source File: tests.py
Function: test_run_bad_options
    def test_run_bad_options(self, capsys):
        manager = Manager(self.app)
        manager.add_command('simple', CommandWithOptions())

        code = run('manage.py simple --foo=bar', manager.run)
        assert code == 2

Example 26

Project: flask-script Source File: tests.py
    def test_raise_index_error(self):

        manager = Manager(self.app)

        @manager.command
        def error():
            raise IndexError()

        with raises(IndexError):
            run('manage.py error', manager.run)

Example 27

Project: flask-script Source File: tests.py
Function: test_run_with_default_command
    def test_run_with_default_command(self, capsys):
        manager = Manager(self.app)
        manager.add_command('simple', SimpleCommand())

        code = run('manage.py', lambda: manager.run(default_command='simple'))
        out, err = capsys.readouterr()
        assert code == 0
        assert 'OK' in out

Example 28

Project: flask-script Source File: tests.py
    def test_command_with_prompt(self, capsys):

        manager = Manager(self.app)

        @manager.command
        def hello():
            print(prompt(name='hello'))

        @Catcher
        def hello_john(msg):
            if re.search("hello", msg):
                return 'john'

        with hello_john:
            code = run('manage.py hello', manager.run)
            out, err = capsys.readouterr()
            assert 'hello: john' in out

Example 29

Project: flask-script Source File: tests.py
    def test_command_with_prompt_choices(self, capsys):

        manager = Manager(self.app)

        @manager.command
        def hello():
            print(prompt_choices(name='hello', choices=['peter', 'john', 'sam']))

        @Catcher
        def hello_john(msg):
            if re.search("hello", msg):
                return 'john'

        with hello_john:
            code = run('manage.py hello', manager.run)
            out, err = capsys.readouterr()
            assert 'hello - (peter, john, sam): john' in out

Example 30

Project: flask-script Source File: tests.py
    def test_add_submanager(self):

        sub_manager = Manager()

        manager = Manager(self.app)
        manager.add_command('sub_manager', sub_manager)

        assert isinstance(manager._commands['sub_manager'], Manager)
        assert sub_manager.parent == manager
        assert sub_manager.get_options() == manager.get_options()

Example 31

Project: flask-script Source File: tests.py
    def test_run_submanager_command(self, capsys):

        sub_manager = Manager()
        sub_manager.add_command('simple', SimpleCommand())

        manager = Manager(self.app)
        manager.add_command('sub_manager', sub_manager)

        code = run('manage.py sub_manager simple', manager.run)
        out, err = capsys.readouterr()
        assert code == 0
        assert 'OK' in out

Example 32

Project: flask-script Source File: tests.py
    def test_submanager_has_options(self, capsys):

        sub_manager = Manager()
        sub_manager.add_command('simple', SimpleCommand())

        manager = Manager(self.app)
        manager.add_command('sub_manager', sub_manager)
        manager.add_option('-c', '--config', dest='config', required=False)

        code = run('manage.py sub_manager simple', manager.run)
        out, err = capsys.readouterr()
        assert code == 0
        assert 'OK' in out

        code = run('manage.py -c Development sub_manager simple', manager.run)
        out, err = capsys.readouterr()
        assert code == 0
        assert 'OK' in out

Example 33

Project: flask-script Source File: tests.py
    def test_submanager_separate_options(self, capsys):

        sub_manager = Manager(AppForTesting(verbose=True), with_default_commands=False)
        sub_manager.add_command('opt', CommandWithOptionalArg())
        sub_manager.add_option('-n', '--name', dest='name_sub', required=False)

        manager = Manager(AppForTesting(verbose=True), with_default_commands=False)
        manager.add_command('sub_manager', sub_manager)
        manager.add_option('-n', '--name', dest='name_main', required=False)

        code = run('manage.py -n MyMainName sub_manager -n MySubName opt -n MyName', manager.run)
        out, err = capsys.readouterr()
        assert code == 0
        assert 'APP name_main=MyMainName' in out
        assert 'APP name_sub=MySubName' in out
        assert 'OK name=MyName' in out

Example 34

Project: flask-script Source File: tests.py
    def test_manager_usage_with_submanager(self, capsys):

        sub_manager = Manager(usage='Example sub-manager')

        manager = Manager(self.app)
        manager.add_command('sub_manager', sub_manager)

        code = run('manage.py -?', manager.run)
        out, err = capsys.readouterr()
        assert code == 0
        assert 'Example sub-manager' in out

Example 35

Project: flask-script Source File: tests.py
    def test_submanager_has_no_default_commands(self):

        sub_manager = Manager()

        manager = Manager()
        manager.add_command('sub_manager', sub_manager)
        manager.set_defaults()

        assert 'runserver' not in sub_manager._commands
        assert 'shell' not in sub_manager._commands

Example 36

Project: notify-api Source File: conftest.py
@pytest.fixture(scope='session')
def notify_db(notify_api, request):
    Migrate(notify_api, db)
    Manager(db, MigrateCommand)
    BASE_DIR = os.path.dirname(os.path.dirname(__file__))
    ALEMBIC_CONFIG = os.path.join(BASE_DIR, 'migrations')
    config = Config(ALEMBIC_CONFIG + '/alembic.ini')
    config.set_main_option("script_location", ALEMBIC_CONFIG)

    with notify_api.app_context():
        upgrade(config, 'head')

    def teardown():
        db.session.remove()
        db.drop_all()
        db.engine.execute("drop table alembic_version")
        db.get_engine(notify_api).dispose()

    request.addfinalizer(teardown)

Example 37

Project: flask-script Source File: tests.py
Function: test_command_decorator_with_options
    def test_command_decorator_with_options(self, capsys):

        manager = Manager(self.app)

        @manager.command
        def hello(name='fred'):
            'Prints your name'
            print('hello ' + name)

        assert 'hello' in manager._commands

        code = run('manage.py hello --name=joe', manager.run)
        out, err = capsys.readouterr()
        assert 'hello joe' in out

        code = run('manage.py hello -n joe', manager.run)
        out, err = capsys.readouterr()
        assert 'hello joe' in out

        code = run('manage.py hello -?', manager.run)
        out, err = capsys.readouterr()
        assert 'Prints your name' in out

        code = run('manage.py hello --help', manager.run)
        out, err = capsys.readouterr()
        assert 'Prints your name' in out

Example 38

Project: flask-script Source File: tests.py
Function: test_no_help
    def test_no_help(self, capsys):
        """
        Tests that erasing --help really works.
        """

        manager = Manager(self.app)
        manager.help_args = ()

        @manager.command
        def hello(name='fred'):
            'Prints your name'
            print('hello ' + name)
        assert 'hello' in manager._commands

        code = run('manage.py --help hello', manager.run)
        out, err = capsys.readouterr()
        print(out)
        assert 'too many arguments' in err

        code = run('manage.py hello --help', manager.run)
        out, err = capsys.readouterr()
        print(out)
        assert 'too many arguments' in err

Example 39

Project: flask-script Source File: tests.py
Function: test_command_decorator_with_boolean_options
    def test_command_decorator_with_boolean_options(self, capsys):

        manager = Manager(self.app)

        @manager.command
        def verify(verified=False):
            'Checks if verified'
            print('VERIFIED ? ' + 'YES' if verified else 'NO')

        assert 'verify' in manager._commands

        code = run('manage.py verify --verified', manager.run)
        out, err = capsys.readouterr()
        assert 'YES' in out

        code = run('manage.py verify -v', manager.run)
        out, err = capsys.readouterr()
        assert 'YES' in out

        code = run('manage.py verify', manager.run)
        out, err = capsys.readouterr()
        assert 'NO' in out

        code = run('manage.py verify -?', manager.run)
        out, err = capsys.readouterr()
        assert 'Checks if verified' in out

Example 40

Project: flask-script Source File: tests.py
Function: test_simple_command_decorator_with_pos_arg_and_options
    def test_simple_command_decorator_with_pos_arg_and_options(self, capsys):

        manager = Manager(self.app)

        @manager.command
        def hello(name, url=None):
            if url:
                assert type(url) is text_type
                print('hello ' + name + ' from ' + url)
            else:
                assert type(name) is text_type
                print('hello ' + name)

        assert 'hello' in manager._commands

        code = run('manage.py hello joe', manager.run)
        out, err = capsys.readouterr()
        assert 'hello joe' in out

        code = run('manage.py hello joe --url=reddit.com', manager.run)
        out, err = capsys.readouterr()
        assert 'hello joe from reddit.com' in out

Example 41

Project: flask-script Source File: tests.py
Function: test_command_decorator_with_additional_options
    def test_command_decorator_with_additional_options(self, capsys):

        manager = Manager(self.app)

        @manager.option('-n', '--name', dest='name', help='Your name')
        def hello(name):
            print('hello ' + name)

        assert 'hello' in manager._commands

        code = run('manage.py hello --name=joe', manager.run)
        out, err = capsys.readouterr()
        assert 'hello joe' in out

        code = run('manage.py hello -?', manager.run)
        out, err = capsys.readouterr()
        assert 'Your name' in out

        @manager.option('-n', '--name', dest='name', help='Your name')
        @manager.option('-u', '--url', dest='url', help='Your URL')
        def hello_again(name, url=None):
            if url:
                print('hello ' + name + ' from ' + url)
            else:
                print('hello ' + name)

        assert 'hello_again' in manager._commands

        code = run('manage.py hello_again --name=joe', manager.run)
        out, err = capsys.readouterr()
        assert 'hello joe' in out

        code = run('manage.py hello_again --name=joe --url=reddit.com', manager.run)
        out, err = capsys.readouterr()
        assert 'hello joe from reddit.com' in out

Example 42

Project: flask-script Source File: tests.py
Function: test_init_with_flask_instance
    def test_init_with_flask_instance(self):
        manager = Manager(self.app)
        assert callable(manager.app)

Example 43

Project: flask-script Source File: tests.py
Function: test_init_with_callable
    def test_init_with_callable(self):
        manager = Manager(lambda: self.app)
        assert callable(manager.app)

Example 44

Project: flask-script Source File: tests.py
    def test_command_with_default_prompt(self, capsys):

        manager = Manager(self.app)

        @manager.command
        def hello():
            print(prompt(name='hello', default='romeo'))

        @Catcher
        def hello(msg):
            if re.search("hello", msg):
                return '\n'  # just hit enter

        with hello:
            code = run('manage.py hello', manager.run)
            out, err = capsys.readouterr()
            assert 'hello [romeo]: romeo' in out

        @Catcher
        def hello_juliette(msg):
            if re.search("hello", msg):
                return 'juliette'

        with hello_juliette:
            code = run('manage.py hello', manager.run)
            out, err = capsys.readouterr()
            assert 'hello [romeo]: juliette' in out

Example 45

Project: flask-script Source File: tests.py
    def test_command_with_prompt_bool(self, capsys):

        manager = Manager(self.app)

        @manager.command
        def hello():
            print(prompt_bool(name='correct', default=True, yes_choices=['y'],
                              no_choices=['n']) and 'yes' or 'no')

        @Catcher
        def correct_default(msg):
            if re.search("correct", msg):
                return '\n'  # just hit enter

        @Catcher
        def correct_y(msg):
            if re.search("correct", msg):
                return 'y'

        @Catcher
        def correct_n(msg):
            if re.search("correct", msg):
                return 'n'

        with correct_default:
            code = run('manage.py hello', manager.run)
            out, err = capsys.readouterr()
            assert 'correct [y]: yes' in out

        with correct_y:
            code = run('manage.py hello', manager.run)
            out, err = capsys.readouterr()
            assert 'correct [y]: yes' in out

        with correct_n:
            code = run('manage.py hello', manager.run)
            out, err = capsys.readouterr()
            assert 'correct [y]: no' in out

Example 46

Project: flask-script Source File: tests.py
    def test_command_with_default_prompt_choices(self, capsys):

        manager = Manager(self.app)

        @manager.command
        def hello():
            print(prompt_choices(name='hello', choices=['peter', 'charlie', 'sam'], default="john"))

        @Catcher
        def hello_john(msg):
            if re.search("hello", msg):
                return '\n'

        with hello_john:
            code = run('manage.py hello', manager.run)
            out, err = capsys.readouterr()
            assert 'hello - (peter, charlie, sam) [john]: john' in out

        @Catcher
        def hello_charlie(msg):
            if re.search("hello", msg):
                return 'charlie'

        with hello_charlie:
            code = run('manage.py hello', manager.run)
            out, err = capsys.readouterr()
            assert 'hello - (peter, charlie, sam) [john]: charlie' in out

Example 47

Project: flask-script Source File: tests.py
    def test_submanager_usage_and_help_and_description(self, capsys):

        sub_manager = Manager(usage='sub_manager [--foo]',
                              help='shorter desc for submanager',
                              description='longer desc for submanager')
        sub_manager.add_command('simple', SimpleCommand())

        manager = Manager(self.app)
        manager.add_command('sub_manager', sub_manager)

        code = run('manage.py -?', manager.run)
        out, err = capsys.readouterr()
        assert code == 0
        assert 'sub_manager [--foo]' not in out
        assert 'shorter desc for submanager' in out
        assert 'longer desc for submanager' not in out

        code = run('manage.py sub_manager', manager.run)
        out, err = capsys.readouterr()
        assert code == 2
        assert 'sub_manager [--foo]' in out
        assert 'shorter desc for submanager' not in out
        assert 'longer desc for submanager' in out
        assert 'simple command' in out

        code = run('manage.py sub_manager -?', manager.run)
        out, err = capsys.readouterr()
        assert code == 0
        assert 'sub_manager [--foo]' in out
        assert 'shorter desc for submanager' not in out
        assert 'longer desc for submanager' in out
        assert 'simple command' in out

        code = run('manage.py sub_manager simple -?', manager.run)
        out, err = capsys.readouterr()
        assert code == 0
        assert 'sub_manager [--foo] simple [-?]' in out
        assert 'simple command' in out

Example 48

Project: aurora Source File: runner.py
def create_manager(app):
    manager = Manager(app)
    manager.add_option('-c', '--config',
                       dest="config",
                       required=False,
                       help="config file")

    manager.add_command("runserver", Server())
    manager.add_command("migrate", ManageMigrations(
        config_path='aurora_app/migrations/alembic.ini'))

    def create_superuser_dialog():
        import getpass
        from email.utils import parseaddr

        print "You need to create a superuser!"

        username = raw_input('Username [{0}]: '.format(getpass.getuser()))
        if not username:
            username = getpass.getuser()

        email = None
        while not email:
            email = parseaddr(raw_input('Email: '))[1]

        passwords = lambda: (getpass.getpass(),
                             getpass.getpass('Password (retype): '))

        password, retyped_password = passwords()

        while password == '' or password != retyped_password:
            print 'Passwords do not match or your password is empty!'
            password, retyped_password = passwords()

        return username, email, password

    @manager.command
    def init_config():
        """Creates settings.py in default folder."""
        import inspect
        from .config import BaseConfig
        lines = inspect.getsource(BaseConfig).split('\n')[1:]
        lines = [line[4:] for line in lines]
        open(BaseConfig.AURORA_SETTINGS, 'w').write('\n'.join(lines))
        print 'Configuration was written at: ' + BaseConfig.AURORA_SETTINGS

    @manager.command
    def init_db():
        """Creates aurora database."""
        from .users.models import User
        from .users.constants import ROLES

        db.create_all()

        username, email, password = create_superuser_dialog()

        superuser = User(username=username, password=password, email=email,
                         role=ROLES['ADMIN'])
        db.session.add(superuser)
        db.session.commit()

    return manager

Example 49

Project: open-event-orga-server Source File: __init__.py
def create_app():
    Autodoc(app)
    # cal = Calendar()
    babel.init_app(app)

    app.register_blueprint(babel_routes)
    app.register_blueprint(api_v1_routes)
    app.register_blueprint(sitemap_routes)
    Migrate(app, db)

    app.config.from_object(environ.get('APP_CONFIG',
                                       'config.ProductionConfig'))
    db.init_app(app)
    manager = Manager(app)
    manager.add_command('db', MigrateCommand)

    if app.config['CACHING']:
        cache.init_app(app, config={'CACHE_TYPE': 'simple'})
    else:
        cache.init_app(app, config={'CACHE_TYPE': 'null'})

    CORS(app)
    stripe.api_key = 'SomeStripeKey'
    app.secret_key = 'super secret key'
    app.json_encoder = MiniJSONEncoder
    app.config['BABEL_DEFAULT_LOCALE'] = 'en'
    app.config['JSONIFY_PRETTYPRINT_REGULAR'] = False
    app.config['UPLOADS_FOLDER'] = os.path.realpath('.') + '/static/'
    app.config['FILE_SYSTEM_STORAGE_FILE_VIEW'] = 'static'
    app.config['STATIC_URL'] = '/static/'
    app.config['STATIC_ROOT'] = 'staticfiles'
    app.config['STATICFILES_DIRS'] = (os.path.join(BASE_DIR, 'static'),)
    app.config['SQLALCHEMY_RECORD_QUERIES'] = True

    app.logger.addHandler(logging.StreamHandler(sys.stdout))
    app.logger.setLevel(logging.ERROR)
    app.jinja_env.add_extension('jinja2.ext.do')
    app.jinja_env.add_extension('jinja2.ext.loopcontrols')
    app.jinja_env.undefined = SilentUndefined
    app.jinja_env.filters['operation_name'] = operation_name

    # set up jwt
    app.config['JWT_AUTH_USERNAME_KEY'] = 'email'
    app.config['JWT_EXPIRATION_DELTA'] = timedelta(seconds=24 * 60 * 60)
    app.config['JWT_AUTH_URL_RULE'] = None
    jwt = JWT(app, jwt_authenticate, jwt_identity)

    # setup celery
    app.config['CELERY_BROKER_URL'] = environ.get('REDIS_URL',
                                                  'redis://localhost:6379/0')
    app.config['CELERY_RESULT_BACKEND'] = app.config['CELERY_BROKER_URL']

    HTMLMIN(app)
    admin_view = AdminView("Open Event")
    admin_view.init(app)
    admin_view.init_login(app)

    if app.config['TESTING']:
        # Profiling
        app.config['PROFILE'] = True
        app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[30])

    # API version 2
    with app.app_context():
        from app.api import api_v2
        app.register_blueprint(api_v2)

    sa.orm.configure_mappers()

    return app, manager, db, jwt