Beispiel #1
0
def test_logging_with_missing_file(capsys):
    """Assert that a message is sent to STDERR when the configuration doesn't exist."""
    file_path = None
    setup_logging(file_path)  # important to do this first

    captured = capsys.readouterr()

    assert captured.err.startswith('Unable to configure logging')
Beispiel #2
0
def test_logging_with_file(capsys):
    """Assert that logging is setup with the configuration file."""
    file_path = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                             'logging.conf')
    setup_logging(file_path)  # important to do this first

    captured = capsys.readouterr()

    assert captured.out.startswith('Configure logging, from conf')
Beispiel #3
0
from humps.main import camelize
from flask import Flask
from sentry_sdk.integrations.flask import FlaskIntegration  # noqa: I001
from sbc_common_components.exception_handling.exception_handler import ExceptionHandler  # noqa: I001

from auth_api import models
from auth_api.extensions import mail
from auth_api.jwt_wrapper import JWTWrapper
from auth_api.models import db, ma
from auth_api.utils.cache import cache
from auth_api.utils.run_version import get_run_version
from auth_api.utils.util_logging import setup_logging
import auth_api.config as config
from auth_api.config import _Config

setup_logging(os.path.join(_Config.PROJECT_ROOT,
                           'logging.conf'))  # important to do this first

JWT = JWTWrapper.get_instance()


def create_app(run_mode=os.getenv('FLASK_ENV', 'production')):
    """Return a configured Flask App using the Factory method."""
    app = Flask(__name__)
    app.config.from_object(config.CONFIGURATION[run_mode])

    # Configure Sentry
    if app.config.get('SENTRY_DSN', None):
        sentry_sdk.init(dsn=app.config.get('SENTRY_DSN'),
                        integrations=[FlaskIntegration()])

    from auth_api.resources import API_BLUEPRINT, OPS_BLUEPRINT, \
Beispiel #4
0
import config

from flask_opentracing import FlaskTracing
from jaeger_client import Config as JaegerConfig

# from auth_api.resources import API, ops_blueprint  # , api_blueprint

from auth_api.utils.run_version import get_run_version

from auth_api.models import db, ma
from auth_api.utils.run_version import get_run_version
from auth_api.utils.util_logging import setup_logging

setup_logging(
    os.path.join(os.path.abspath(os.path.dirname(__file__)),
                 'logging.conf'))  # important to do this first

# lower case name as used by convention in most Flask apps
jwt = JwtManager()  # pylint: disable=invalid-name


def create_app(run_mode=os.getenv('FLASK_ENV', 'production')):
    """Return a configured Flask App using the Factory method."""
    app = Flask(__name__)
    app.config.from_object(config.CONFIGURATION[run_mode])

    # start tracer
    tracer = init_tracer(__name__)
    FlaskTracing(tracer)