[Zope-Checkins] SVN: Zope/trunk/lib/python/Testing/ZopeTestCase/ Spring cleaning! Improved docstrings, removed cruft, and added a ClassDiagram.pdf.

Stefan H. Holek stefan at epy.co.at
Sun May 8 04:15:23 EDT 2005


Log message for revision 30300:
  Spring cleaning! Improved docstrings, removed cruft, and added a ClassDiagram.pdf.
  No functional changes.
  

Changed:
  U   Zope/trunk/lib/python/Testing/ZopeTestCase/ZopeTestCase.py
  A   Zope/trunk/lib/python/Testing/ZopeTestCase/doc/ClassDiagram.pdf
  U   Zope/trunk/lib/python/Testing/ZopeTestCase/functional.py
  U   Zope/trunk/lib/python/Testing/ZopeTestCase/interfaces.py
  U   Zope/trunk/lib/python/Testing/ZopeTestCase/testFunctional.py
  U   Zope/trunk/lib/python/Testing/ZopeTestCase/testPortalTestCase.py
  U   Zope/trunk/lib/python/Testing/ZopeTestCase/testPythonScript.py
  U   Zope/trunk/lib/python/Testing/ZopeTestCase/testShoppingCart.py
  U   Zope/trunk/lib/python/Testing/ZopeTestCase/testZODBCompat.py
  U   Zope/trunk/lib/python/Testing/ZopeTestCase/testZopeTestCase.py
  U   Zope/trunk/lib/python/Testing/ZopeTestCase/zopedoctest/__init__.py

-=-
Modified: Zope/trunk/lib/python/Testing/ZopeTestCase/ZopeTestCase.py
===================================================================
--- Zope/trunk/lib/python/Testing/ZopeTestCase/ZopeTestCase.py	2005-05-07 18:54:29 UTC (rev 30299)
+++ Zope/trunk/lib/python/Testing/ZopeTestCase/ZopeTestCase.py	2005-05-08 08:15:23 UTC (rev 30300)
@@ -114,8 +114,12 @@
 
 
 class FunctionalTestCase(functional.Functional, ZopeTestCase):
-    '''Base class for functional Zope tests'''
+    '''Convenience base class for functional Zope tests
 
+       You can mix-in Functional with every xTestCase
+       to turn it into a functional test case.
+    '''
+
     __implements__ = (functional.Functional.__implements__,
                       ZopeTestCase.__implements__)
 

Added: Zope/trunk/lib/python/Testing/ZopeTestCase/doc/ClassDiagram.pdf
===================================================================
(Binary files differ)


Property changes on: Zope/trunk/lib/python/Testing/ZopeTestCase/doc/ClassDiagram.pdf
___________________________________________________________________
Name: svn:mime-type
   + application/pdf

Modified: Zope/trunk/lib/python/Testing/ZopeTestCase/functional.py
===================================================================
--- Zope/trunk/lib/python/Testing/ZopeTestCase/functional.py	2005-05-07 18:54:29 UTC (rev 30299)
+++ Zope/trunk/lib/python/Testing/ZopeTestCase/functional.py	2005-05-08 08:15:23 UTC (rev 30300)
@@ -12,9 +12,9 @@
 ##############################################################################
 """Support for functional unit testing in ZTC
 
-After Marius Gedminas' functional.py module for Zope 3.
+After Marius Gedminas' functional.py module for Zope3.
 
-$Id: functional.py,v 1.3 2004/09/12 16:49:59 shh42 Exp $
+$Id$
 """
 
 import sys, re, base64

Modified: Zope/trunk/lib/python/Testing/ZopeTestCase/interfaces.py
===================================================================
--- Zope/trunk/lib/python/Testing/ZopeTestCase/interfaces.py	2005-05-07 18:54:29 UTC (rev 30299)
+++ Zope/trunk/lib/python/Testing/ZopeTestCase/interfaces.py	2005-05-08 08:15:23 UTC (rev 30300)
@@ -12,14 +12,10 @@
 ##############################################################################
 """ZopeTestCase interfaces
 
-$Id: interfaces.py,v 1.5 2005/02/07 21:59:35 shh42 Exp $
+$Id$
 """
 
-try:
-    from Interface import Interface
-except ImportError:
-    # Old interface package
-    from Interface import Base as Interface
+from Interface import Interface
 
 
 class IZopeTestCase(Interface):

Modified: Zope/trunk/lib/python/Testing/ZopeTestCase/testFunctional.py
===================================================================
--- Zope/trunk/lib/python/Testing/ZopeTestCase/testFunctional.py	2005-05-07 18:54:29 UTC (rev 30299)
+++ Zope/trunk/lib/python/Testing/ZopeTestCase/testFunctional.py	2005-05-08 08:15:23 UTC (rev 30300)
@@ -12,7 +12,10 @@
 ##############################################################################
 """Example functional ZopeTestCase
 
-$Id: testFunctional.py,v 1.16 2005/02/12 13:13:04 shh42 Exp $
+Demonstrates how to use the publish() API to execute GET, POST, PUT, etc.
+requests against the ZPublisher and how to examine the response.
+
+$Id$
 """
 
 import os, sys

Modified: Zope/trunk/lib/python/Testing/ZopeTestCase/testPortalTestCase.py
===================================================================
--- Zope/trunk/lib/python/Testing/ZopeTestCase/testPortalTestCase.py	2005-05-07 18:54:29 UTC (rev 30299)
+++ Zope/trunk/lib/python/Testing/ZopeTestCase/testPortalTestCase.py	2005-05-08 08:15:23 UTC (rev 30300)
@@ -343,44 +343,6 @@
         #self.assertEqual(self._called, ['afterClear', 'beforeSetUp', 'afterSetUp'])
         self.assertEqual(self._called, ['beforeSetUp', 'afterSetUp'])
 
-    # This is crazy
-
-    def __test_crazyRoles_0(self):
-        # Permission assignments should be reset
-        self.app = self._app()
-        perms = self.getPermissionsOfRole('Anonymous', self.app)
-        for perm in ['Access contents information', 'View', 'Query Vocabulary', 'Search ZCatalog']:
-            if perm not in perms:
-                self.fail('Expected permission "%s"' % perm)
-
-    def __test_crazyRoles_1(self):
-        # Permission assignments should be reset
-        self.app = self._app()
-        self.app.manage_role('Anonymous', ['View'])
-        self.assertPermissionsOfRole(['View'], 'Anonymous', self.app)
-        self.failIf(getSecurityManager().checkPermission('Access contents information', self.app))
-
-    def __test_crazyRoles_2(self):
-        # Permission assignments should be reset
-        self.app = self._app()
-        try:
-            self.assertPermissionsOfRole(['View'], 'Anonymous', self.app)
-        except self.failureException:
-            pass
-
-    def __test_crazyRoles_3(self):
-        # Permission assignments should be reset
-        self.app = self._app()
-        self.failUnless(getSecurityManager().checkPermission('Access contents information', self.app))
-
-    def __test_crazyRoles_4(self):
-        # Permission assignments should be reset
-        self.app = self._app()
-        perms = self.getPermissionsOfRole('Anonymous', self.app)
-        for perm in ['Access contents information', 'View', 'Query Vocabulary', 'Search ZCatalog']:
-            if perm not in perms:
-                self.fail('Expected permission "%s"' % perm)
-
     # Helpers
 
     def getPermissionsOfRole(self, role, context=None):

Modified: Zope/trunk/lib/python/Testing/ZopeTestCase/testPythonScript.py
===================================================================
--- Zope/trunk/lib/python/Testing/ZopeTestCase/testPythonScript.py	2005-05-07 18:54:29 UTC (rev 30299)
+++ Zope/trunk/lib/python/Testing/ZopeTestCase/testPythonScript.py	2005-05-08 08:15:23 UTC (rev 30300)
@@ -10,17 +10,19 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""Example ZopeTestCase testing a PythonScript object in the default fixture
+"""Example ZopeTestCase testing a PythonScript in the default fixture
 
-Note that you are encouraged to call any of the following methods
-from your own tests to modify the test user's security credentials:
+This test module demonstrates the security API of ZopeTestCase.
 
-  - setRoles()
-  - setPermissions()
-  - login()
-  - logout()
+Note that you are encouraged to call any of the following methods to
+modify the test user's security credentials:
 
-$Id: testPythonScript.py,v 1.9 2004/04/09 12:38:37 shh42 Exp $
+    setRoles()
+    setPermissions()
+    login()
+    logout()
+
+$Id$
 """
 
 import os, sys
@@ -52,9 +54,9 @@
         self.ps = self.folder['ps']
         self.ps.ZPythonScript_edit(ps_params1, ps_body1)
 
-    # Test the fixture ##############################################
+    # Test the setup
 
-    def testFixture(self):
+    def testSetup(self):
         # The PythonScript should exist and be properly set up
         self.failUnless(hasattr(self.folder, 'ps'))
         self.assertEqual(self.ps.body(), ps_body1+'\n')
@@ -62,7 +64,7 @@
         owner = self.ps.getOwner()
         self.assertEqual(owner.getUserName(), ZopeTestCase.user_name)
 
-    # Test the scripts ##############################################
+    # Test the script(s)
 
     def testCanCallScript1WithArgument(self):
         # PythonScript should return 2
@@ -78,18 +80,18 @@
         self.assertEqual(self.ps(1), 2)
 
     def testCannotCallScript2WithoutArgument(self):
-        # PythonScript should raise a TypeError
+        # PythonScript should raise a TypeError if called without arguments
         self.ps.ZPythonScript_edit(ps_params2, ps_body2)
         self.assertRaises(TypeError, self.ps, ())
 
-    # Test access protection ########################################
+    # Test access protection with restrictedTraverse
 
     def testCannotAccessWithoutAccessPermission(self):
         # manage_main should be protected
         self.assertRaises(Unauthorized, self.ps.restrictedTraverse, 'manage_main')
 
     def testCanAccessWithAccessPermission(self):
-        # manage_main should be accessible
+        # manage_main should be accessible if we have the necessary permissions
         self.setPermissions(access_permissions)
         try:
             self.ps.restrictedTraverse('manage_main')
@@ -97,26 +99,26 @@
             self.fail('Access to manage_main was denied')
 
     def testCannotAccessIfAnonymous(self):
-        # manage_main should be protected
+        # manage_main should be protected from Anonymous
         self.logout()
         self.assertRaises(Unauthorized, self.ps.restrictedTraverse, 'manage_main')
 
     def testCanAccessIfManager(self):
-        # manage_main should be accessible to Managers
+        # manage_main should be accessible to Manager
         self.setRoles(['Manager'])
         try:
             self.ps.restrictedTraverse('manage_main')
         except Unauthorized:
             self.fail('Access to manage_main was denied to Manager')
 
-    # Test access protection with SecurityManager ###################
+    # Test access protection with SecurityManager
 
     def testCannotAccessWithoutAccessPermissionSecurityManager(self):
         # manage_main should be protected
         self.assertRaises(Unauthorized, getSecurityManager().validateValue, self.ps.manage_main)
 
     def testCanAccessWithAccessPermissionSecurityManager(self):
-        # manage_main should be accessible
+        # manage_main should be accessible if we have the necessary permissions
         self.setPermissions(access_permissions)
         try:
             getSecurityManager().validateValue(self.ps.manage_main)
@@ -124,19 +126,19 @@
             self.fail('Access to manage_main was denied')
 
     def testCannotAccessIfAnonymousSecurityManager(self):
-        # manage_main should be protected
+        # manage_main should be protected from Anonymous
         self.logout()
         self.assertRaises(Unauthorized, getSecurityManager().validateValue, self.ps.manage_main)
 
     def testCanAccessIfManagerSecurityManager(self):
-        # manage_main should be accessible to Managers
+        # manage_main should be accessible to Manager
         self.setRoles(['Manager'])
         try:
             getSecurityManager().validateValue(self.ps.manage_main)
         except Unauthorized:
             self.fail('Access to manage_main was denied to Manager')
 
-    # Test edit protection ##########################################
+    # Test edit protection with restrictedTraverse
 
     def testCannotEditWithoutChangePermission(self):
         # PythonScript should not be editable
@@ -151,7 +153,7 @@
                     'ZPythonScript_edit was protected but no exception was raised')
 
     def testCanEditWithChangePermission(self):
-        # PythonScript should be editable
+        # PythonScript should be editable if we have the necessary permissions
         self.setPermissions(change_permissions)
         try:
             self.ps.restrictedTraverse('ZPythonScript_edit')(ps_params2, ps_body2)
@@ -162,7 +164,7 @@
             self.assertEqual(self.ps.params(), ps_params2)
 
     def testCannotEditIfAnonymous(self):
-        # PythonScript should not be editable
+        # PythonScript should not be editable by Anonymous
         self.logout()
         try:
             self.ps.restrictedTraverse('ZPythonScript_edit')(ps_params2, ps_body2)
@@ -175,7 +177,7 @@
                     'ZPythonScript_edit was protected but no exception was raised')
 
     def testCanEditIfManager(self):
-        # PythonScript should be editable for Managers
+        # PythonScript should be editable by Manager
         self.setRoles(['Manager'])
         try:
             self.ps.restrictedTraverse('ZPythonScript_edit')(ps_params2, ps_body2)

Modified: Zope/trunk/lib/python/Testing/ZopeTestCase/testShoppingCart.py
===================================================================
--- Zope/trunk/lib/python/Testing/ZopeTestCase/testShoppingCart.py	2005-05-07 18:54:29 UTC (rev 30299)
+++ Zope/trunk/lib/python/Testing/ZopeTestCase/testShoppingCart.py	2005-05-08 08:15:23 UTC (rev 30300)
@@ -10,7 +10,7 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""Example ZopeTestCase testing the ShoppingCart example application.
+"""Example ZopeTestCase testing the ShoppingCart example application
 
 Note the use of sessions and how the SESSION object is added to
 the REQUEST in afterSetUp().
@@ -18,7 +18,7 @@
 You can use zLOG.LOG() if you set up the event log variables first.
 Handy for debugging and tracing your tests.
 
-$Id: testShoppingCart.py,v 1.11 2005/02/23 17:14:56 shh42 Exp $
+$Id$
 """
 
 import os, sys

Modified: Zope/trunk/lib/python/Testing/ZopeTestCase/testZODBCompat.py
===================================================================
--- Zope/trunk/lib/python/Testing/ZopeTestCase/testZODBCompat.py	2005-05-07 18:54:29 UTC (rev 30299)
+++ Zope/trunk/lib/python/Testing/ZopeTestCase/testZODBCompat.py	2005-05-08 08:15:23 UTC (rev 30300)
@@ -12,11 +12,11 @@
 ##############################################################################
 """Tests ZODB behavior in ZopeTestCase
 
-Demonstrates that cut/copy/paste/clone/rename and import/export 
-work in ZopeTestCase if a subtransaction is commited before performing
-the respective operations.
+Demonstrates that cut/copy/paste/clone/rename and import/export
+work if a subtransaction is committed before performing the respective
+operation.
 
-$Id: testZODBCompat.py,v 1.17 2004/04/09 12:38:37 shh42 Exp $
+$Id$
 """
 
 import os, sys

Modified: Zope/trunk/lib/python/Testing/ZopeTestCase/testZopeTestCase.py
===================================================================
--- Zope/trunk/lib/python/Testing/ZopeTestCase/testZopeTestCase.py	2005-05-07 18:54:29 UTC (rev 30299)
+++ Zope/trunk/lib/python/Testing/ZopeTestCase/testZopeTestCase.py	2005-05-08 08:15:23 UTC (rev 30300)
@@ -19,7 +19,7 @@
 example test cases. See testSkeleton.py for a quick
 way of getting started.
 
-$Id: testZopeTestCase.py,v 1.25 2005/01/30 14:22:48 shh42 Exp $
+$Id$
 """
 
 import os, sys
@@ -319,44 +319,6 @@
         manager_perms.remove('Take ownership')
         self.assertPermissionsOfRole(manager_perms, 'Manager')
 
-    # This is crazy 
-
-    def __test_crazyRoles_0(self):
-        # Permission assignments should be reset
-        self.app = self._app()
-        perms = self.getPermissionsOfRole('Anonymous', self.app)
-        for perm in ['Access contents information', 'View', 'Query Vocabulary', 'Search ZCatalog']:
-            if perm not in perms:
-                self.fail('Expected permission "%s"' % perm)
-
-    def __test_crazyRoles_1(self):
-        # Permission assignments should be reset
-        self.app = self._app()
-        self.app.manage_role('Anonymous', ['View'])
-        self.assertPermissionsOfRole(['View'], 'Anonymous', self.app)
-        self.failIf(getSecurityManager().checkPermission('Access contents information', self.app))
-
-    def __test_crazyRoles_2(self):
-        # Permission assignments should be reset
-        self.app = self._app()
-        try:
-            self.assertPermissionsOfRole(['View'], 'Anonymous', self.app)
-        except self.failureException:
-            pass
-
-    def __test_crazyRoles_3(self):
-        # Permission assignments should be reset
-        self.app = self._app()
-        self.failUnless(getSecurityManager().checkPermission('Access contents information', self.app))
-
-    def __test_crazyRoles_4(self):
-        # Permission assignments should be reset
-        self.app = self._app()
-        perms = self.getPermissionsOfRole('Anonymous', self.app)
-        for perm in ['Access contents information', 'View', 'Query Vocabulary', 'Search ZCatalog']:
-            if perm not in perms:
-                self.fail('Expected permission "%s"' % perm)
-
     # Helpers
 
     def getPermissionsOfRole(self, role, context=None):

Modified: Zope/trunk/lib/python/Testing/ZopeTestCase/zopedoctest/__init__.py
===================================================================
--- Zope/trunk/lib/python/Testing/ZopeTestCase/zopedoctest/__init__.py	2005-05-07 18:54:29 UTC (rev 30299)
+++ Zope/trunk/lib/python/Testing/ZopeTestCase/zopedoctest/__init__.py	2005-05-08 08:15:23 UTC (rev 30300)
@@ -12,11 +12,9 @@
 ##############################################################################
 """ZopeTestCase doctest support
 
-$Id: __init__.py,v 1.2 2005/03/26 18:07:08 shh42 Exp $
+$Id$
 """
 
-__version__ = '0.9.7'
-
 from zope.testing.doctest import *
 from functional import *
 



More information about the Zope-Checkins mailing list