예제 #1
0
 def testThrashing(self):
     settings.THRASHING_LIMIT = 10
     settings.THRASHING_TIMEOUT = 60
     
     Message.objects.all().delete()
     GroupedMessage.objects.all().delete()
     
     for i in range(0, 50):
         SentryClient.create_from_text('hi')
     
     self.assertEquals(Message.objects.count(), settings.THRASHING_LIMIT)
예제 #2
0
    def testNoThrashing(self):
        prev = settings.THRASHING_LIMIT
        settings.THRASHING_LIMIT = 0
        
        Message.objects.all().delete()
        GroupedMessage.objects.all().delete()
        
        for i in range(0, 50):
            SentryClient.create_from_text('hi')
        
        self.assertEquals(Message.objects.count(), 50)

        settings.THRASHING_LIMIT = prev
예제 #3
0
    def testCorrectUnicode(self):
        self.setUpHandler()
        
        cnt = Message.objects.count()
        value = 'רונית מגן'.decode('utf-8')

        error = SentryClient.create_from_text(value)
        self.assertEquals(Message.objects.count(), cnt+1)
        self.assertEquals(error.message, value)

        logging.info(value)
        self.assertEquals(Message.objects.count(), cnt+2)

        x = TestModel.objects.create(data={'value': value})
        logging.warn(x)
        self.assertEquals(Message.objects.count(), cnt+3)

        try:
            raise SyntaxMessage(value)
        except Exception, exc:
            logging.exception(exc)
            logging.info('test', exc_info=sys.exc_info())
예제 #4
0
 def testLongURLs(self):
     # Fix: #6 solves URLs > 200 characters
     error = SentryClient.create_from_text('hello world', url='a'*210)
     self.assertEquals(error.url, 'a'*200)
     self.assertEquals(error.data['url'], 'a'*210)
예제 #5
0
        except Message.DoesNotExist, exc:
            error = SentryClient.create_from_exception()
            self.assertTrue(error.data.get('__sentry__', {}).get('exc'))
        else:
            self.fail('Unable to create `Message` entry.')

        
        cur = (Message.objects.count(), GroupedMessage.objects.count())
        self.assertEquals(cur, (2, 2), 'Assumed logs failed to save. %s' % (cur,))
        last = Message.objects.all().order_by('-id')[0:1].get()
        self.assertEquals(last.logger, 'root')
        self.assertEquals(last.class_name, 'DoesNotExist')
        self.assertEquals(last.level, logging.ERROR)
        self.assertEquals(last.message, smart_unicode(exc))
        
        SentryClient.create_from_text('This is an error', level=logging.DEBUG)
        
        cur = (Message.objects.count(), GroupedMessage.objects.count())
        self.assertEquals(cur, (3, 3), 'Assumed logs failed to save. %s' % (cur,))
        last = Message.objects.all().order_by('-id')[0:1].get()
        self.assertEquals(last.logger, 'root')
        self.assertEquals(last.level, logging.DEBUG)
        self.assertEquals(last.message, 'This is an error')
        
    def testAlternateDatabase(self):
        settings.DATABASE_USING = 'default'
        
        try:
            Message.objects.get(id=999999979)
        except Message.DoesNotExist, exc:
            SentryClient.create_from_exception(exc)