class SentryExceptionHandlerTest(TestCase): @fixture def request(self): return make_request() @fixture def exc_info(self): return (ValueError, ValueError('lol world'), None) def setUp(self): super(SentryExceptionHandlerTest, self).setUp() self.client = get_client() self.handler = SentryDjangoHandler(self.client) @mock.patch.object(MockClient, 'captureException') @mock.patch('sys.exc_info') def test_does_capture_exception(self, exc_info, captureException): exc_info.return_value = self.exc_info self.handler.exception_handler(request=self.request) captureException.assert_called_once_with(exc_info=self.exc_info, request=self.request) @mock.patch.object(MockClient, 'send') @mock.patch('sys.exc_info') def test_does_exclude_filtered_types(self, exc_info, mock_send): exc_info.return_value = self.exc_info try: self.client.ignore_exceptions = set(['ValueError']) self.handler.exception_handler(request=self.request) finally: self.client.ignore_exceptions.clear() assert not mock_send.called @mock.patch.object(MockClient, 'send') @mock.patch('sys.exc_info') def test_ignore_exceptions_with_expression_match(self, exc_info, mock_send): exc_info.return_value = self.exc_info try: if not PY2: self.client.ignore_exceptions = set(['builtins.*']) else: self.client.ignore_exceptions = set(['exceptions.*']) self.handler.exception_handler(request=self.request) finally: self.client.ignore_exceptions.clear() assert not mock_send.called @mock.patch.object(MockClient, 'send') @mock.patch('sys.exc_info') def test_ignore_exceptions_with_module_match(self, exc_info, mock_send): exc_info.return_value = self.exc_info try: if not PY2: self.client.ignore_exceptions = set(['builtins.ValueError']) else: self.client.ignore_exceptions = set(['exceptions.ValueError']) self.handler.exception_handler(request=self.request) finally: self.client.ignore_exceptions.clear() assert not mock_send.called
class SentryExceptionHandlerTest(TestCase): @fixture def request(self): return make_request() @fixture def exc_info(self): return (ValueError, ValueError('lol world'), None) def setUp(self): super(SentryExceptionHandlerTest, self).setUp() self.client = get_client() self.handler = SentryDjangoHandler(self.client) @mock.patch.object(TempStoreClient, 'captureException') @mock.patch('sys.exc_info') def test_does_capture_exception(self, exc_info, captureException): exc_info.return_value = self.exc_info self.handler.exception_handler(request=self.request) captureException.assert_called_once_with(exc_info=self.exc_info, request=self.request) @mock.patch.object(TempStoreClient, 'send') @mock.patch('sys.exc_info') def test_does_exclude_filtered_types(self, exc_info, mock_send): exc_info.return_value = self.exc_info try: self.client.ignore_exceptions = set(['ValueError']) self.handler.exception_handler(request=self.request) finally: self.client.ignore_exceptions.clear() assert not mock_send.called @mock.patch.object(TempStoreClient, 'send') @mock.patch('sys.exc_info') def test_ignore_exceptions_with_expression_match(self, exc_info, mock_send): exc_info.return_value = self.exc_info try: if not PY2: self.client.ignore_exceptions = set(['builtins.*']) else: self.client.ignore_exceptions = set(['exceptions.*']) self.handler.exception_handler(request=self.request) finally: self.client.ignore_exceptions.clear() assert not mock_send.called @mock.patch.object(TempStoreClient, 'send') @mock.patch('sys.exc_info') def test_ignore_exceptions_with_module_match(self, exc_info, mock_send): exc_info.return_value = self.exc_info try: if not PY2: self.client.ignore_exceptions = set(['builtins.ValueError']) else: self.client.ignore_exceptions = set(['exceptions.ValueError']) self.handler.exception_handler(request=self.request) finally: self.client.ignore_exceptions.clear() assert not mock_send.called