コード例 #1
0
ファイル: tests.py プロジェクト: dz/django-db-log2
    def testUseLogging(self):
        Message.objects.all().delete()
        GroupedMessage.objects.all().delete()
        
        request = RF.get("/", REMOTE_ADDR="127.0.0.1:8000")

        try:
            Message.objects.get(id=999999999)
        except Message.DoesNotExist, exc:
            GroupedMessage.handle_exception(request=request, sender=self)
コード例 #2
0
ファイル: tests.py プロジェクト: dz/django-db-log2
     self.assertEquals(last.logger, 'root')
     self.assertEquals(last.class_name, 'DoesNotExist')
     self.assertEquals(last.level, logging.ERROR)
     self.assertEquals(last.message, smart_unicode(exc))
     
     settings.USE_LOGGING = True
     
     logger = logging.getLogger('dblog')
     for h in logger.handlers:
         logger.removeHandler(h)
     logger.addHandler(logging.StreamHandler())
     
     try:
         Message.objects.get(id=999999999)
     except Message.DoesNotExist, exc:
         GroupedMessage.handle_exception(request=request, sender=self)
     else:
         self.fail('Expected an exception.')
     
     cur = (Message.objects.count(), GroupedMessage.objects.count())
     self.assertEquals(cur, (1, 1), 'Assumed logs failed to save. %s' % (cur,))
     
     settings.USE_LOGGING = False
 
 def testThrashing(self):
     settings.THRASHING_LIMIT = 10
     settings.THRASHING_TIMEOUT = 60
     
     Message.objects.all().delete()
     GroupedMessage.objects.all().delete()