Log message for revision 30566: Sync up with standalone version 0.9.8.
Changed: U Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/PortalTestCase.py U Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/ZopeLite.py U Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/__init__.py U Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/doc/API.stx U Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/doc/CHANGES.txt U Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/doc/ClassDiagram.pdf A Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/doc/VERSION.txt U Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/testBaseTestCase.py U Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/testPortalTestCase.py U Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/testPythonScript.py U Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/testWebserver.py U Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/testZopeTestCase.py U Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/utils.py -=- Modified: Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/PortalTestCase.py =================================================================== --- Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/PortalTestCase.py 2005-05-30 22:07:11 UTC (rev 30565) +++ Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/PortalTestCase.py 2005-05-30 22:37:34 UTC (rev 30566) @@ -96,7 +96,7 @@ def _refreshSkinData(self): '''Refreshes the skin cache.''' - if hasattr(self.portal, 'clearCurrentSkin'): + if hasattr(aq_base(self.portal), 'clearCurrentSkin'): self.portal.clearCurrentSkin() else: # CMF 1.4 self.portal._v_skindata = None @@ -119,7 +119,10 @@ or more lightweight version of the memberarea. ''' pm = self.portal.portal_membership - pm.createMemberarea(name) + if hasattr(aq_base(pm), 'createMemberArea'): + pm.createMemberArea(name) + else: # CMF 1.4 + pm.createMemberarea(name) # Security interface Modified: Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/ZopeLite.py =================================================================== --- Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/ZopeLite.py 2005-05-30 22:07:11 UTC (rev 30565) +++ Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/ZopeLite.py 2005-05-30 22:37:34 UTC (rev 30566) @@ -22,7 +22,7 @@ Zope2.installProduct('SomeProduct') app = Zope2.app() -$Id: ZopeLite.py,v 1.24 2004/08/18 09:28:54 shh42 Exp $ +$Id$ """ import os, sys, time @@ -182,6 +182,7 @@ DB = Zope2.DB configure = Zope2.configure def startup(): pass +Zope = Zope2 # ZODB sandbox factory from ZODB.DemoStorage import DemoStorage Modified: Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/__init__.py =================================================================== --- Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/__init__.py 2005-05-30 22:07:11 UTC (rev 30565) +++ Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/__init__.py 2005-05-30 22:37:34 UTC (rev 30566) @@ -12,7 +12,7 @@ ############################################################################## """Names exported by the ZopeTestCase package -$Id: __init__.py,v 1.25 2005/02/22 14:59:16 shh42 Exp $ +$Id$ """ import ZopeLite as Zope2 @@ -33,14 +33,14 @@ from PortalTestCase import portal_name from PortalTestCase import PortalTestCase +from profiler import Profiled +from sandbox import Sandboxed +from functional import Functional + from base import TestCase from base import app from base import close -from profiler import Profiled -from sandbox import Sandboxed -from functional import Functional - from ZODB.tests.warnhook import WarningsHook from unittest import main @@ -49,3 +49,8 @@ from zopedoctest import FunctionalDocTestSuite from zopedoctest import FunctionalDocFileSuite +import zopedoctest as doctest +import transaction + +Zope = Zope2 + Modified: Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/doc/API.stx =================================================================== --- Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/doc/API.stx 2005-05-30 22:07:11 UTC (rev 30565) +++ Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/doc/API.stx 2005-05-30 22:37:34 UTC (rev 30566) @@ -39,30 +39,44 @@ _print(msg) + ZopeDocTestSuite(module=None, **kw) + + ZopeDocFileSuite(*paths, **kw) + + FunctionalDocTestSuite(module=None, **kw) + + FunctionalDocFileSuite(*paths, **kw) + Classes + TestCase + ZopeTestCase FunctionalTestCase PortalTestCase - TestCase - Profiled Sandboxed Functional + WarningsHook + Modules ZopeLite as Zope utils + doctest + transaction + + Module ZopeLite Lightweight replacement for the Zope module Modified: Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/doc/CHANGES.txt =================================================================== --- Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/doc/CHANGES.txt 2005-05-30 22:07:11 UTC (rev 30565) +++ Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/doc/CHANGES.txt 2005-05-30 22:37:34 UTC (rev 30566) @@ -1,6 +1,7 @@ -0.9.7 (Zope 2.8 edition) +0.9.8 (Zope 2.8 edition) - Renamed 'doctest' package to 'zopedoctest' because of name-shadowing - issues discovered during integration into Zope 2.8. + issues discovered during integration into Zope 2.8. Tests may still use + 'from Testing.ZopeTestCase import doctest' as the name is aliased there. - Greatly improved the doctest story. ZopeTestCase now implements four test suite factories: ZopeDocTestSuite, ZopeDocFileSuite, FunctionalDocTestSuite, and FunctionalDocFileSuite. @@ -10,7 +11,8 @@ - ZopeLite now takes care not to monkey patch an already started Zope. - PortalTestCase.setUp() no longer calls _refreshSkinData() as CMF is smart enough now. -- Fixed _refreshSkinData() helper to work with CMF >= 1.5. +- Fixed PortalTestCase._refreshSkinData() helper to work with CMF >= 1.5. +- Made PortalTestCase.createMemberarea() work better with CMF >= 1.5. - Fixed a bug where using sessions in sandboxed (functional) tests would cause connection pool depletion and subsequent hangs. Thanks to Balazs Ree. - Encapsulated the ConnectionRegistry in its own module, connections.py. @@ -19,6 +21,10 @@ to Sidnei da Silva. - Modified runalltests.py so it imports modules more like test.py, i.e. without touching sys.path and without the help of imp. +- The standalone version of ZopeTestCase gained a Zope 2.8-style transaction + module. Tests may now use 'from Testing.ZopeTestCase import transaction' + which is guaranteed to work across Zope versions. +- The REQUEST now contains the ACTUAL_URL variable introduced in Zope 2.7.4. 0.9.6 - Dropped support for Zope 2.5 as it lacks the setSecurityManager() API. Modified: Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/doc/ClassDiagram.pdf =================================================================== (Binary files differ) Copied: Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/doc/VERSION.txt (from rev 30565, Zope/trunk/lib/python/Testing/ZopeTestCase/doc/VERSION.txt) Property changes on: Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/doc/VERSION.txt ___________________________________________________________________ Name: svn:eol-style + native Modified: Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/testBaseTestCase.py =================================================================== --- Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/testBaseTestCase.py 2005-05-30 22:07:11 UTC (rev 30565) +++ Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/testBaseTestCase.py 2005-05-30 22:37:34 UTC (rev 30566) @@ -388,6 +388,7 @@ self.failIfEqual(request.get('BASE0', ''), '') self.failIfEqual(request.get('BASE1', ''), '') self.failIfEqual(request.get('BASE2', ''), '') + self.failIfEqual(request.get('ACTUAL_URL', ''), '') import gc Modified: Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/testPortalTestCase.py =================================================================== --- Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/testPortalTestCase.py 2005-05-30 22:07:11 UTC (rev 30565) +++ Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/testPortalTestCase.py 2005-05-30 22:37:34 UTC (rev 30566) @@ -61,14 +61,23 @@ class DummyMembershipTool(SimpleItem): id = 'portal_membership' + def __init__(self): + self._called = [] def createMemberarea(self, member_id): + self._called.append('createMemberarea') portal = self.aq_inner.aq_parent portal.Members.manage_addFolder(member_id) def getHomeFolder(self, member_id): portal = self.aq_inner.aq_parent return getattr(portal.Members, member_id) +class NewMembershipTool(DummyMembershipTool): + def createMemberArea(self, member_id): + self._called.append('createMemberArea') + portal = self.aq_inner.aq_parent + portal.Members.manage_addFolder(member_id) + class TestPortalTestCase(ZopeTestCase.PortalTestCase): '''Incrementally exercise the PortalTestCase API.''' @@ -105,7 +114,7 @@ def test_getPortal(self): # Portal should be set up self.app = self._app() - self.portal = self.getPortal() + self.portal = self._portal() self.failUnless(hasattr_(self.app, portal_name)) self.failUnless(hasattr_(self.portal, 'Members')) self.failUnless(hasattr_(self.portal, 'portal_membership')) @@ -114,7 +123,7 @@ def test_setupUserFolder(self): # User folder should be set up. self.app = self._app() - self.portal = self.getPortal() + self.portal = self._portal() self.failIf(hasattr_(self.portal, 'acl_users')) self._setupUserFolder() self.failUnless(hasattr_(self.portal, 'acl_users')) @@ -124,7 +133,7 @@ def test_setupUser(self): # User should be set up self.app = self._app() - self.portal = self.getPortal() + self.portal = self._portal() self._setupUserFolder() self._setupUser() acl_user = self.portal.acl_users.getUserById(user_name) @@ -135,7 +144,7 @@ def test_setupHomeFolder(self): # User's home folder should be set up self.app = self._app() - self.portal = self.getPortal() + self.portal = self._portal() self._setupUserFolder() self._setupUser() self.login() @@ -151,14 +160,14 @@ def test_refreshSkinData(self): # The skin cache should be refreshed self.app = self._app() - self.portal = self.getPortal() + self.portal = self._portal() self._refreshSkinData() self.assertEqual(self.portal._called, ['clearCurrentSkin', 'setupCurrentSkin']) def test_setRoles(self): # Roles should be set for user self.app = self._app() - self.portal = self.getPortal() + self.portal = self._portal() self._setupUserFolder() self._setupUser() test_roles = ['Manager', 'Member'] @@ -169,7 +178,7 @@ def test_setRoles_2(self): # Roles should be set for logged in user self.app = self._app() - self.portal = self.getPortal() + self.portal = self._portal() self._setupUserFolder() self._setupUser() self.login() @@ -181,7 +190,7 @@ def test_setRoles_3(self): # Roles should be set for a specified user self.app = self._app() - self.portal = self.getPortal() + self.portal = self._portal() self._setupUserFolder() self.portal.acl_users.userFolderAddUser('user_2', 'secret', [], []) test_roles = ['Manager', 'Member'] @@ -192,7 +201,7 @@ def test_setRoles_4(self): # Roles should be set from a tuple self.app = self._app() - self.portal = self.getPortal() + self.portal = self._portal() self._setupUserFolder() self._setupUser() test_roles = ['Manager', 'Member'] @@ -203,7 +212,7 @@ def test_setRoles_5(self): # Roles should be set from a string self.app = self._app() - self.portal = self.getPortal() + self.portal = self._portal() self._setupUserFolder() self._setupUser() test_roles = ['Manager'] @@ -214,7 +223,7 @@ def test_setPermissions(self): # Permissions should be set for user self.app = self._app() - self.portal = self.getPortal() + self.portal = self._portal() test_perms = ['Add Folders', 'Delete objects'] self.setPermissions(test_perms) self.assertPermissionsOfRole(test_perms, 'Member') @@ -222,7 +231,7 @@ def test_setPermissions_2(self): # Permissions should be set for specified role self.app = self._app() - self.portal = self.getPortal() + self.portal = self._portal() self.portal._addRole('role_2') test_perms = ['Add Folders', 'Delete objects'] self.assertPermissionsOfRole([], 'role_2') @@ -232,7 +241,7 @@ def test_setPermissions_3(self): # Permissions should be set from a tuple self.app = self._app() - self.portal = self.getPortal() + self.portal = self._portal() test_perms = ['Add Folders', 'Delete objects'] self.setPermissions(tuple(test_perms)) self.assertPermissionsOfRole(test_perms, 'Member') @@ -240,7 +249,7 @@ def test_setPermissions_4(self): # Permissions should be set from a string self.app = self._app() - self.portal = self.getPortal() + self.portal = self._portal() test_perms = ['Add Folders'] self.setPermissions('Add Folders') self.assertPermissionsOfRole(test_perms, 'Member') @@ -248,7 +257,7 @@ def test_login(self): # User should be able to log in self.app = self._app() - self.portal = self.getPortal() + self.portal = self._portal() self._setupUserFolder() self._setupUser() auth_name = getSecurityManager().getUser().getUserName() @@ -260,7 +269,7 @@ def test_login_2(self): # A specified user should be logged in self.app = self._app() - self.portal = self.getPortal() + self.portal = self._portal() self._setupUserFolder() self.portal.acl_users.userFolderAddUser('user_2', 'secret', [], []) auth_name = getSecurityManager().getUser().getUserName() @@ -272,14 +281,14 @@ def test_login_3(self): # Unknown user should raise AttributeError self.app = self._app() - self.portal = self.getPortal() + self.portal = self._portal() self._setupUserFolder() self.assertRaises(AttributeError, self.login, 'user_3') def test_logout(self): # User should be able to log out self.app = self._app() - self.portal = self.getPortal() + self.portal = self._portal() self._setupUserFolder() self._setupUser() self.login() @@ -290,7 +299,7 @@ def test_clear(self): # Everything should be removed self.app = self._app() - self.portal = self.getPortal() + self.portal = self._portal() self._setupUserFolder() self._setupUser() self._setupHomeFolder() @@ -343,6 +352,30 @@ #self.assertEqual(self._called, ['afterClear', 'beforeSetUp', 'afterSetUp']) self.assertEqual(self._called, ['beforeSetUp', 'afterSetUp']) + def test_createMemberarea(self): + # Should call the membership tool's createMemberarea + self.app = self._app() + self.portal = self._portal() + self._setupUserFolder() + self._setupUser() + self.login() + self.createMemberarea(user_name) + self.assertEqual(self.portal.portal_membership._called, ['createMemberarea']) + self.failUnless(hasattr_(self.portal.Members, user_name)) + + def test_createMemberarea_NewTool(self): + # Should call the membership tool's createMemberArea + self.app = self._app() + self.portal = self._portal() + self._setupUserFolder() + self._setupUser() + self.portal._delObject('portal_membership') + self.portal._setObject('portal_membership', NewMembershipTool()) + self.login() + self.createMemberarea(user_name) + self.assertEqual(self.portal.portal_membership._called, ['createMemberArea']) + self.failUnless(hasattr_(self.portal.Members, user_name)) + # Helpers def getPermissionsOfRole(self, role, context=None): Modified: Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/testPythonScript.py =================================================================== --- Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/testPythonScript.py 2005-05-30 22:07:11 UTC (rev 30565) +++ Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/testPythonScript.py 2005-05-30 22:37:34 UTC (rev 30566) @@ -30,11 +30,12 @@ execfile(os.path.join(sys.path[0], 'framework.py')) from Testing import ZopeTestCase + +ZopeTestCase.installProduct('PythonScripts') + from AccessControl import Unauthorized from AccessControl import getSecurityManager -ZopeTestCase.installProduct('PythonScripts') - access_permissions = ['View management screens'] change_permissions = ['Change Python Scripts'] Modified: Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/testWebserver.py =================================================================== --- Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/testWebserver.py 2005-05-30 22:07:11 UTC (rev 30565) +++ Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/testWebserver.py 2005-05-30 22:37:34 UTC (rev 30566) @@ -26,7 +26,7 @@ If you want to write functional unit tests, see the testFunctional.py example instead. -$Id: testWebserver.py,v 1.16 2005/02/12 13:11:10 shh42 Exp $ +$Id$ """ import os, sys @@ -38,11 +38,10 @@ from Testing import ZopeTestCase +from Testing.ZopeTestCase import transaction from AccessControl import Unauthorized import urllib -import transaction - # Create the error_log object ZopeTestCase.utils.setupSiteErrorLog() Modified: Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/testZopeTestCase.py =================================================================== --- Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/testZopeTestCase.py 2005-05-30 22:07:11 UTC (rev 30565) +++ Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/testZopeTestCase.py 2005-05-30 22:37:34 UTC (rev 30566) @@ -28,18 +28,18 @@ from Testing import ZopeTestCase +from Testing.ZopeTestCase import folder_name +from Testing.ZopeTestCase import user_name +from Testing.ZopeTestCase import user_role +from Testing.ZopeTestCase import standard_permissions + from Acquisition import aq_base from AccessControl import getSecurityManager from types import ListType import transaction -folder_name = ZopeTestCase.folder_name -user_name = ZopeTestCase.user_name -user_role = ZopeTestCase.user_role -standard_permissions = ZopeTestCase.standard_permissions - def hasattr_(ob, attr): return hasattr(aq_base(ob), attr) Modified: Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/utils.py =================================================================== --- Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/utils.py 2005-05-30 22:07:11 UTC (rev 30565) +++ Zope/branches/Zope-2_8-branch/lib/python/Testing/ZopeTestCase/utils.py 2005-05-30 22:37:34 UTC (rev 30566) @@ -136,6 +136,7 @@ environ['REQUEST_METHOD'] = 'GET' request = Request(sys.stdin, environ, response) request._steps = ['noobject'] # Fake a published object + request['ACTUAL_URL'] = request.get('URL') # Zope 2.7.4 return app.__of__(RequestContainer(REQUEST=request)) _______________________________________________ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins