示例#1
0
def test_get_endpoint_which_does_error(app_fixture, request, mock_sentry_sdk):
    app = request.getfixturevalue(app_fixture)

    result = simulate_get(app, '/unhappy')

    assert result.status == falcon.HTTP_500
    assert result.content.decode().startswith('A server error occurred')
    assert mock_sentry_sdk.capture_exception.called
示例#2
0
def test_get_endpoint_which_does_not_error(
    app_fixture, request, mock_sentry_sdk
):
    app = request.getfixturevalue(app_fixture)
    result = simulate_get(app, '/hello-world')

    assert result.status == falcon.HTTP_200
    assert result.content == b'hello world!'
    assert not mock_sentry_sdk.capture_exception.called
示例#3
0
def test_get_endpoint_which_500_errors(app_fixture, request, mock_sentry_sdk):
    app = request.getfixturevalue(app_fixture)

    result = simulate_get(app, '/500')

    # Falcon 500 errors are delivered to sentry
    assert result.status == falcon.HTTP_500
    assert result.content == b'{"title": "500 Internal Server Error"}'
    mock_sentry_sdk.init.assert_called_once_with(DSN)
    assert mock_sentry_sdk.capture_exception.called
示例#4
0
def test_if_environment_given_is_passed_to_sentry_init(
    mock_sentry_sdk, app_with_environment
):
    result = simulate_get(app_with_environment, '/500')

    # Falcon 500 errors are delivered to sentry
    assert result.status == falcon.HTTP_500
    assert result.content == b'{"title": "500 Internal Server Error"}'
    mock_sentry_sdk.init.assert_called_once_with(DSN, environment='production')
    assert mock_sentry_sdk.capture_exception.called
示例#5
0
def test_get_endpoint_which_400_errors(app_fixture, request, mock_sentry_sdk):
    app = request.getfixturevalue(app_fixture)

    result = simulate_get(app, '/400')

    # Checks that for normal exceptions handled by falcon they are
    # not delivered to sentry
    assert result.status == falcon.HTTP_400
    assert result.content == b'{"title": "Bad request"}'
    assert not mock_sentry_sdk.capture_exception.called