예제 #1
0
def test_gunicorn_gevent_entrypoint():
    # this will error in python3.6 without our fix
    gunicorn = testing.GunicornProcess(app='tests.py36_async_tls:app',
                                       gunicorn='talisker.gunicorn.gevent',
                                       args=['--worker-class=gevent'])
    with gunicorn:
        r = requests.get(gunicorn.url('/'))
    assert r.status_code == 200
예제 #2
0
파일: test_testing.py 프로젝트: sj/talisker
def test_gunicornprocess_success():
    id = 'test-id'
    gunicorn = testing.GunicornProcess('tests.wsgi_app')
    with gunicorn:
        r = requests.get(gunicorn.url('/'), headers={'X-Request-Id': id})
        assert r.status_code == 200
    assert {
        'logmsg': 'GET /',
        'extra': {
            'status': '200',
            'method': 'GET',
            'ip': '127.0.0.1',
            'proto': 'HTTP/1.1',
            'request_id': id,
        }
    } in gunicorn.log
예제 #3
0
def test_gunicornprocess_success():
    try:
        import gunicorn  # noqa
    except ImportError:
        pytest.skip('need gunicorn installed')
    id = 'test-id'
    ps = testing.GunicornProcess('tests.wsgi_app')
    with ps:
        r = requests.get(ps.url('/'), headers={'X-Request-Id': id})
        assert r.status_code == 200
    ps.log.assert_log(msg='GET /',
                      extra={
                          'status': '200',
                          'method': 'GET',
                          'ip': '127.0.0.1',
                          'proto': 'HTTP/1.1',
                          'request_id': id,
                      })
예제 #4
0
파일: test_testing.py 프로젝트: sj/talisker
def test_gunicornprocess_bad_app():
    gunicorn = testing.GunicornProcess('no_app_here')
    with pytest.raises(testing.ServerProcessError):
        with gunicorn:
            pass