Exemple #1
0
def test_bad_app(monkeypatch):
    monkeypatch.setenv("SF_ENV", "")

    with pytest.raises(SystemExit):
        app.create_app()

    with pytest.raises(SystemExit):
        app.create_app(app_env="")
Exemple #2
0
def test_app_more_config(monkeypatch):
    key = "TEST_ENV_VAR"
    envvar = "SF_{}".format(key)
    value = "False"

    monkeypatch.setenv(envvar, value)

    flask_app = app.create_app(app_env="test")

    assert flask_app.config.get(key) is False
Exemple #3
0
def cli(ctx, env):
    """Manage steam_friends."""
    # similar to flask.app.Flask.debug_log_format
    debug_log_format = (
        '-' * 80 + '\n' +
        '%(levelname)s in %(name)s [%(pathname)s:%(lineno)d]:\n' +
        '%(message)s\n' +
        '-' * 80
    )

    logging.basicConfig(stream=sys.stderr, level=logging.DEBUG, format=debug_log_format)
    logging.getLogger('celery').setLevel(logging.WARNING)
    logging.getLogger('requests').setLevel(logging.WARNING)
    logging.getLogger('werkzeug').setLevel(logging.WARNING)

    ctx.obj = app.create_app(app_env=env)
Exemple #4
0
def cli(ctx, env):
    """Manage steam_friends."""
    # similar to flask.app.Flask.debug_log_format
    debug_log_format = (
        '-' * 80 + '\n' +
        '%(levelname)s in %(name)s [%(pathname)s:%(lineno)d]:\n' +
        '%(message)s\n' + '-' * 80)

    logging.basicConfig(stream=sys.stderr,
                        level=logging.DEBUG,
                        format=debug_log_format)

    # TODO: set levels differently for different environments

    logging.getLogger('celery').setLevel(logging.WARNING)
    logging.getLogger('requests').setLevel(logging.WARNING)
    logging.getLogger('werkzeug').setLevel(logging.WARNING)
    logging.getLogger('flask').setLevel(logging.INFO)

    ctx.obj = app.create_app(app_env=env)
Exemple #5
0
def flask_app():
    a = app.create_app(app_env='test')
    assert a.testing is True
    return a
Exemple #6
0
def flask_app():
    a = app.create_app(app_env='test')
    assert a.testing is True
    return a
Exemple #7
0
"""this file is used to run the flask application in production."""
from __future__ import absolute_import

import logging
import sys

from steam_friends import app

# a simple single line format suitable for production
log_format = '%(asctime)s - %(levelname)s - %(name)s: %(message)s'

# configure logging before we do anything
logging.basicConfig(stream=sys.stdout, level=logging.INFO, format=log_format)
logging.getLogger('flask').setLevel(logging.WARNING)
logging.getLogger('werkzeug').setLevel(logging.WARNING)

# uwsgi expects "application" by default
application = app.create_app(app_env='prod')

# assert some things just to be safe
assert application.debug is False
assert application.testing is False

application.logger.info("Starting %s for production", application)
Exemple #8
0
def test_debug_app(monkeypatch):
    monkeypatch.setenv("SF_DEBUG", "True")

    flask_app = app.create_app(app_env="test")

    assert flask_app.debug is True
Exemple #9
0
"""
this file is used to run the flask application in production
"""
from __future__ import absolute_import

import logging
import sys

from steam_friends import app


# a simple single line format suitable for production
log_format = '%(asctime)s - %(levelname)s - %(name)s: %(message)s'

# configure logging before we do anything
logging.basicConfig(stream=sys.stdout, level=logging.INFO, format=log_format)
logging.getLogger('werkzeug').setLevel(logging.WARNING)

# uwsgi expects "application" by default
application = app.create_app(app_env='prod')

# assert some things just to be safe
assert application.debug is False
assert application.testing is False

application.logger.info("Starting %s for production", application)