Esempio n. 1
0
def test_gunicorn_application_load(monkeypatch):
    monkeypatch.setattr(
        sys, 'argv', ['', __name__ + ':wsgi', '--bind=0.0.0.0:0'])
    app = gunicorn.TaliskerApplication('')
    wsgiapp = app.load_wsgiapp()
    assert wsgiapp._talisker_wrapped
    assert wsgiapp._talisker_original_app == wsgi
Esempio n. 2
0
def test_gunicorn_application_config_loglevel_debug_devel(monkeypatch):
    monkeypatch.setattr(
        sys, 'argv',
        ['talisker', 'wsgi:app', '--log-level', 'debug'])
    app = gunicorn.TaliskerApplication('', devel=True)
    assert app.cfg.loglevel.lower() == 'debug'
    assert logs.get_talisker_handler().level == logging.DEBUG
Esempio n. 3
0
def test_gunicorn_application_init(monkeypatch):
    monkeypatch.setattr(sys, 'argv', ['talisker', 'wsgi:app'])
    app = gunicorn.TaliskerApplication('')
    assert app.cfg.logger_class == gunicorn.GunicornLogger
    assert app.cfg.loglevel.lower() == 'info'
    assert app.cfg.on_starting is gunicorn.gunicorn_on_starting
    assert app.cfg.child_exit is gunicorn.gunicorn_child_exit
    assert app.cfg.worker_exit is gunicorn.gunicorn_worker_exit
    assert logs.get_talisker_handler().level == logging.NOTSET
Esempio n. 4
0
def test_gunicorn_application_config_errorlog(monkeypatch, context):
    monkeypatch.setattr(sys, 'argv',
                        ['talisker', 'wsgi:app', '--log-file', '/tmp/log'])
    app = gunicorn.TaliskerApplication('')
    context.assert_log(
        msg='ignoring gunicorn errorlog',
        extra={'errorlog': '/tmp/log'},
    )
    assert app.cfg.errorlog == '-'
Esempio n. 5
0
def test_gunicorn_application_config_logger_class(monkeypatch, context):
    monkeypatch.setattr(
        sys, 'argv',
        ['talisker', 'wsgi:app', '--logger-class', 'gunicorn.glogging.Logger'])
    from gunicorn.glogging import Logger
    app = gunicorn.TaliskerApplication('')
    context.assert_log(
        msg='using custom gunicorn logger class',
        extra={'logger_class': Logger},
    )
    assert app.cfg.logger_class is Logger
Esempio n. 6
0
def test_gunicorn_application_config_statsd(monkeypatch, context):
    monkeypatch.setattr(
        sys, 'argv',
        ['talisker', 'wsgi:app', '--statsd-host', 'localhost:8125'])
    app = gunicorn.TaliskerApplication('')
    context.assert_log(
        msg='ignoring gunicorn statsd',
        extra={'statsd_host': ('localhost', 8125)},
    )
    assert app.cfg.statsd_host is None
    assert app.cfg.statsd_prefix is None
Esempio n. 7
0
def test_gunicorn_application_init_devel_overriden(monkeypatch):
    monkeypatch.setattr(
        sys, 'argv',
        ['talisker', 'wsgi:app', '--timeout', '10'])
    app = gunicorn.TaliskerApplication('', devel=True)
    assert app.cfg.timeout == 10
Esempio n. 8
0
def test_gunicorn_application_init_devel(monkeypatch):
    monkeypatch.setattr(sys, 'argv', ['talisker', 'wsgi:app'])
    app = gunicorn.TaliskerApplication('', devel=True)
    assert app.cfg.timeout == 99999
    assert app.cfg.reload