Example #1
0
def app(request):
    """Session-wide test `Flask` application."""
    app = create_app()

    # test config
    app.config.from_object(TestConfig)

    # to setup your own local test config, put a config file in tmp/instance, then
    # $ export FBONE_TEST_CFG=your-local-test.cfg
    if 'FBONE_TEST_CFG' in os.environ:
        app.config.from_envvar('FBONE_TEST_CFG')

    # hush the loggers, they dirty up our stdout
    log = logging.getLogger('werkzeug')
    log.setLevel(logging.ERROR)
    app.logger.disabled = True

    # we'll make Flask's test client a little easier to use
    app.client = app.test_client()

    # and we need to create the database if we're using MySQL
    if 'mysql' in app.config['SQLALCHEMY_DATABASE_URI']:
        URI = app.config['SQLALCHEMY_DATABASE_URI'][:app.config['SQLALCHEMY_DATABASE_URI'].rfind('/')]
        engine = sqlalchemy.create_engine(URI)
        engine.execute("CREATE DATABASE %s" % app.config['DB_NAME'])

    # finally, establish an application context before running the tests.
    ctx = app.app_context()
    ctx.push()

    def teardown():
        ctx.pop()

    request.addfinalizer(teardown)
    return app
Example #2
0
def app(request):
    """Session-wide test `Flask` application."""
    app = create_app()
    app.config.from_object(TestConfig)

    # Establish an application context before running the tests.
    ctx = app.app_context()
    ctx.push()

    def teardown():
        ctx.pop()

    request.addfinalizer(teardown)
    return app
Example #3
0
def app(request):
    """Session-wide test `Flask` application."""
    app = create_app()

    # test config
    app.config.from_object(TestConfig)

    # to setup your own local test config, put a config file in tmp/instance, then
    # $ export FBONE_TEST_CFG=your-local-test.cfg
    if 'FBONE_TEST_CFG' in os.environ:
        app.config.from_envvar('FBONE_TEST_CFG')

    # hush the loggers, they dirty up our stdout
    log = logging.getLogger('werkzeug')
    log.setLevel(logging.ERROR)
    app.logger.disabled = True

    # we'll make Flask's test client a little easier to use
    app.client = app.test_client()

    # and we need to create the database if we're using MySQL
    if 'mysql' in app.config['SQLALCHEMY_DATABASE_URI']:
        URI = app.config[
            'SQLALCHEMY_DATABASE_URI'][:app.config['SQLALCHEMY_DATABASE_URI'].
                                       rfind('/')]
        engine = sqlalchemy.create_engine(URI)
        engine.execute("CREATE DATABASE %s" % app.config['DB_NAME'])

    # finally, establish an application context before running the tests.
    ctx = app.app_context()
    ctx.push()

    def teardown():
        ctx.pop()

    request.addfinalizer(teardown)
    return app
Example #4
0
def test_test_config():
    app = create_app()
    app.config.from_object(TestConfig)
    assert app.config['TESTING'] is True
Example #5
0
def test_default_config():
    app = create_app()
    assert app.config['DEBUG'] is True
    assert app.config['TESTING'] is False