예제 #1
0
 def setUp(self):
     self.client = DjangoClient(
         servers=['http://example.com'],
         organization_id='org',
         app_id='app',
         secret_token='secret',
         filter_exception_types=['KeyError', 'tests.contrib.django.fake1.FakeException']
     )
예제 #2
0
class DjangoClientNoTempTest(TestCase):
    def setUp(self):
        self.client = DjangoClient(
            servers=['http://example.com'],
            organization_id='org',
            app_id='app',
            secret_token='secret',
            filter_exception_types=[
                'KeyError', 'tests.contrib.django.fake1.FakeException'
            ])

    @mock.patch('opbeat.contrib.django.DjangoClient.send_encoded')
    def test_filter_no_match(self, send_encoded):
        try:
            raise ValueError('foo')
        except:
            self.client.capture('Exception')

        self.assertEquals(send_encoded.call_count, 1)

    @mock.patch('opbeat.contrib.django.DjangoClient.send_encoded')
    def test_filter_matches_type(self, send_encoded):
        try:
            raise KeyError('foo')
        except:
            self.client.capture('Exception')

        self.assertEquals(send_encoded.call_count, 0)

    @mock.patch('opbeat.contrib.django.DjangoClient.send_encoded')
    def test_filter_matches_type_but_not_module(self, send_encoded):
        try:
            from tests.contrib.django.fake2 import FakeException
            raise FakeException('foo')
        except:
            self.client.capture('Exception')

        self.assertEquals(send_encoded.call_count, 1)

    @mock.patch('opbeat.contrib.django.DjangoClient.send_encoded')
    def test_filter_matches_type_and_module(self, send_encoded):
        try:
            from tests.contrib.django.fake1 import FakeException
            raise FakeException('foo')
        except:
            self.client.capture('Exception')

        self.assertEquals(send_encoded.call_count, 0)

    @mock.patch('opbeat.contrib.django.DjangoClient.send_encoded')
    def test_filter_matches_module_only(self, send_encoded):
        try:
            from tests.contrib.django.fake1 import OtherFakeException
            raise OtherFakeException('foo')
        except:
            self.client.capture('Exception')

        self.assertEquals(send_encoded.call_count, 1)
예제 #3
0
class DjangoClientNoTempTest(TestCase):
    def setUp(self):
        self.client = DjangoClient(
            servers=['http://example.com'],
            organization_id='org',
            app_id='app',
            secret_token='secret',
            filter_exception_types=['KeyError', 'tests.contrib.django.fake1.FakeException']
        )

    @mock.patch('opbeat.contrib.django.DjangoClient.send_encoded')
    def test_filter_no_match(self, send_encoded):
        try:
            raise ValueError('foo')
        except:
            self.client.capture('Exception')

        self.assertEquals(send_encoded.call_count, 1)

    @mock.patch('opbeat.contrib.django.DjangoClient.send_encoded')
    def test_filter_matches_type(self, send_encoded):
        try:
            raise KeyError('foo')
        except:
            self.client.capture('Exception')

        self.assertEquals(send_encoded.call_count, 0)

    @mock.patch('opbeat.contrib.django.DjangoClient.send_encoded')
    def test_filter_matches_type_but_not_module(self, send_encoded):
        try:
            from tests.contrib.django.fake2 import FakeException
            raise FakeException('foo')
        except:
            self.client.capture('Exception')

        self.assertEquals(send_encoded.call_count, 1)

    @mock.patch('opbeat.contrib.django.DjangoClient.send_encoded')
    def test_filter_matches_type_and_module(self, send_encoded):
        try:
            from tests.contrib.django.fake1 import FakeException
            raise FakeException('foo')
        except:
            self.client.capture('Exception')

        self.assertEquals(send_encoded.call_count, 0)

    @mock.patch('opbeat.contrib.django.DjangoClient.send_encoded')
    def test_filter_matches_module_only(self, send_encoded):
        try:
            from tests.contrib.django.fake1 import OtherFakeException
            raise OtherFakeException('foo')
        except:
            self.client.capture('Exception')

        self.assertEquals(send_encoded.call_count, 1)
예제 #4
0
 def setUp(self):
     self.client = DjangoClient(
         servers=['http://example.com'],
         organization_id='org',
         app_id='app',
         secret_token='secret',
         filter_exception_types=['KeyError', 'tests.contrib.django.fake1.FakeException']
     )