Ejemplo n.º 1
0
def test_sentry_handler():
    mocked_client = mock.Mock()
    handler = sentry_handler(mocked_client)
    exc = ValueError('test')
    exc_info = (type(exc), exc, None)
    delete_message = handler(exc_info, 'test')

    assert delete_message is False
    assert mocked_client.captureException.called
    assert mocked_client.captureException.called_once_with(extra={'message': 'test'})
Ejemplo n.º 2
0
def test_sentry_handler():
    mocked_client = mock.Mock()
    handler = sentry_handler(mocked_client)
    exc = ValueError('test')
    exc_info = (type(exc), exc, None)
    delete_message = handler(exc_info, 'test')

    assert delete_message is False
    assert mocked_client.captureException.called
    mocked_client.captureException.assert_called_once_with(
        exc_info,
        extra={'message': 'test'},
    )
Ejemplo n.º 3
0
def test_sentry_handler_delete_message():
    mock_scope = MockScope()
    sdk_mocked = mock.Mock()
    sdk_mocked.push_scope.return_value = mock_scope

    handler = sentry_handler(sdk_mocked, delete_message=True)
    exc = ValueError("test")
    exc_info = (type(exc), exc, None)
    delete_message = handler(exc_info, "test")

    assert delete_message is True
    assert sdk_mocked.push_scope.called
    mock_scope.set_extra.assert_called_once_with("message", "test")
    sdk_mocked.capture_exception.assert_called_once_with(exc_info)
Ejemplo n.º 4
0
from raven import Client
from loafer.ext.sentry import sentry_handler
from decouple import config


def sum_(x, y):
    return x + y


async def handler_add(data, *args):
    print(data)
    return sum_(data['x'], data['y'])


client = Client(config('SENTRY_TOKEN_URL'))
error_handler = sentry_handler(client, delete_message=False)
Ejemplo n.º 5
0
import os
import sys

import sentry_sdk

from loafer.ext.sentry import sentry_handler

sentry_sdk.init(os.environ.get("SENTRY_SDK_URL", None))
handler = sentry_handler(sentry_sdk)

try:
    raise ValueError("test")
except:  # noqa
    handler(sys.exc_info(), "ping-message")