[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/ErrorReportingService/tests - __init__.py:1.2 testErrorReportingService.py:1.2

Jim Fulton jim@zope.com
Wed, 23 Oct 2002 12:00:51 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/ErrorReportingService/tests
In directory cvs.zope.org:/tmp/cvs-serv8321/lib/python/Zope/App/OFS/Services/ErrorReportingService/tests

Added Files:
	__init__.py testErrorReportingService.py 
Log Message:
Merging in the work done by Naveen and Rakesh on the
ErrorReportingService-branch branch.

There is now an error reporting service that works like the Zope 2.6
site error log. Yay!


=== Zope3/lib/python/Zope/App/OFS/Services/ErrorReportingService/tests/__init__.py 1.1 => 1.2 ===
--- /dev/null	Wed Oct 23 12:00:51 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ErrorReportingService/tests/__init__.py	Wed Oct 23 12:00:20 2002
@@ -0,0 +1,14 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+# 
+##############################################################################
+


=== Zope3/lib/python/Zope/App/OFS/Services/ErrorReportingService/tests/testErrorReportingService.py 1.1 => 1.2 ===
--- /dev/null	Wed Oct 23 12:00:51 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ErrorReportingService/tests/testErrorReportingService.py	Wed Oct 23 12:00:20 2002
@@ -0,0 +1,81 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+# 
+##############################################################################
+"""
+
+Revision information:
+$Id$
+"""
+from unittest import TestCase, TestLoader, TextTestRunner
+from Zope.App.OFS.Services.ErrorReportingService.ErrorReportingService import ErrorReportingService
+from Zope.Testing.CleanUp import CleanUp
+from Zope.Exceptions.ExceptionFormatter import format_exception
+
+import sys
+class C1:
+    def getAnErrorInfo(self):
+     exc_info = None
+     try:
+        someerror()
+     except:
+         exc_info = sys.exc_info()
+     return exc_info
+
+class ErrorReportingServiceTests(CleanUp, TestCase):
+
+    def test_checkForEmpryLog(self):
+        """Test Check Empty Log
+        """
+        errService = ErrorReportingService()
+        getProp = errService.getLogEntries()
+        self.failIf(getProp)
+        
+    def test_checkProperties(self):
+        """Test Properties test
+        """
+        errService = ErrorReportingService()
+        setProp = {
+            'keep_entries':10,
+            'copy_to_zlog':1,
+            'ignored_exceptions':()
+            }
+        errService.setProperties(**setProp)
+        getProp = errService.getProperties()
+        self.assertEqual(setProp, getProp)
+
+    def test_ErrorLog(self):
+        """Test for Logging Error .
+           Create one error and check whether its logged or not.
+        """ 
+        errService = ErrorReportingService()
+        exc_info = C1().getAnErrorInfo()
+        errService.raising(exc_info)
+        getErrLog = errService.getLogEntries()
+        self.assertEquals(1, len(getErrLog))
+
+        tb_text = ''.join(format_exception(*exc_info, **{'as_html': 0}))
+
+        err_id =  getErrLog[0]['id']
+        self.assertEquals(tb_text, errService.getLogEntryById(err_id)['tb_text'])
+
+        
+        
+
+
+
+def test_suite():
+    loader=TestLoader()
+    return loader.loadTestsFromTestCase(ErrorReportingServiceTests)
+
+if __name__=='__main__':
+    TextTestRunner().run(test_suite())