[CMF-checkins] SVN: CMF/branches/jens_tools_as_utilities/CMF
FunctionalLayer test cleanup:
Yvo Schubbe
y.2007- at wcm-solutions.de
Wed Jan 24 06:27:36 EST 2007
Log message for revision 72209:
FunctionalLayer test cleanup:
- the global registry should not be modified, setSite(self.app.site) makes the local available
- the "self.app = ZopeTestCase.app()" hack seems to obsolete
Changed:
U CMF/branches/jens_tools_as_utilities/CMFCalendar/browser/event.txt
U CMF/branches/jens_tools_as_utilities/CMFCalendar/tests/test_Calendar.py
U CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_DiscussionReply.py
U CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Image.py
U CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Portal.py
U CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_join.py
U CMF/branches/jens_tools_as_utilities/CMFTopic/tests/test_DateC.py
-=-
Modified: CMF/branches/jens_tools_as_utilities/CMFCalendar/browser/event.txt
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCalendar/browser/event.txt 2007-01-24 11:16:47 UTC (rev 72208)
+++ CMF/branches/jens_tools_as_utilities/CMFCalendar/browser/event.txt 2007-01-24 11:27:35 UTC (rev 72209)
@@ -1,27 +1,10 @@
Event Views
-----------
-Register the minimum number of utilities we need
+Set up site, user and Event.
- >>> from zope.component import getSiteManager
- >>> from Products.CMFCore.interfaces import ICatalogTool
- >>> from Products.CMFCore.interfaces import IConfigurableWorkflowTool
- >>> from Products.CMFCore.interfaces import IMembershipTool
- >>> from Products.CMFCore.interfaces import IPropertiesTool
- >>> from Products.CMFCore.interfaces import ISkinsTool
- >>> from Products.CMFCore.interfaces import ITypesTool
- >>> from Products.CMFCore.interfaces import IURLTool
- >>> sm = getSiteManager()
- >>> sm.registerUtility(app.site.portal_catalog, ICatalogTool)
- >>> sm.registerUtility(app.site.portal_workflow, IConfigurableWorkflowTool)
- >>> sm.registerUtility(app.site.portal_membership, IMembershipTool)
- >>> sm.registerUtility(app.site.portal_properties, IPropertiesTool)
- >>> sm.registerUtility(app.site.portal_skins, ISkinsTool)
- >>> sm.registerUtility(app.site.portal_types, ITypesTool)
- >>> sm.registerUtility(app.site.portal_url, IURLTool)
-
-Set up Event and user.
-
+ >>> from zope.app.component.hooks import setSite
+ >>> setSite(app.site)
>>> uf = app.site.acl_users
>>> uf._doAddUser('mgr', 'mgrpw', ['Manager'], [])
>>> from AccessControl.SecurityManagement import newSecurityManager
Modified: CMF/branches/jens_tools_as_utilities/CMFCalendar/tests/test_Calendar.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCalendar/tests/test_Calendar.py 2007-01-24 11:16:47 UTC (rev 72208)
+++ CMF/branches/jens_tools_as_utilities/CMFCalendar/tests/test_Calendar.py 2007-01-24 11:27:35 UTC (rev 72209)
@@ -21,21 +21,11 @@
import locale
-from zope.component import getSiteManager
-
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.User import UnrestrictedUser
from DateTime import DateTime
+from zope.app.component.hooks import setSite
-from Products.CMFCore.interfaces import IActionsTool
-from Products.CMFCore.interfaces import ICatalogTool
-from Products.CMFCore.interfaces import IConfigurableWorkflowTool
-from Products.CMFCore.interfaces import IMembershipTool
-from Products.CMFCore.interfaces import IPropertiesTool
-from Products.CMFCore.interfaces import ISkinsTool
-from Products.CMFCore.interfaces import ITypesTool
-from Products.CMFCore.interfaces import IURLTool
-from Products.CMFCalendar.interfaces import ICalendarTool
from Products.CMFCalendar.testing import FunctionalLayer
@@ -118,31 +108,13 @@
layer = FunctionalLayer
def afterSetUp(self):
+ setSite(self.app.site)
newSecurityManager(None, UnrestrictedUser('god', '', ['Manager'], ''))
- # Need to make sure we get a _clean_ datbase connection, otherwise
- # tests are plagued by ZODB connection errors due to the way the
- # FunctionalLayer sets up the portal.
- self.app = ZopeTestCase.app()
-
# sessioning setup
sdm = self.app.session_data_manager
self.app.REQUEST.set_lazy('SESSION', sdm.getSessionData)
- # register utilities
- sm = getSiteManager()
- sm.registerUtility(self.app.site.portal_actions, IActionsTool)
- sm.registerUtility(self.app.site.portal_calendar, ICalendarTool)
- sm.registerUtility(self.app.site.portal_catalog, ICatalogTool)
- sm.registerUtility( self.app.site.portal_workflow
- , IConfigurableWorkflowTool
- )
- sm.registerUtility(self.app.site.portal_membership, IMembershipTool)
- sm.registerUtility(self.app.site.portal_properties, IPropertiesTool)
- sm.registerUtility(self.app.site.portal_skins, ISkinsTool)
- sm.registerUtility(self.app.site.portal_types, ITypesTool)
- sm.registerUtility(self.app.site.portal_url, IURLTool)
-
def _testURL(self, url, params=None):
obj = self.app.site.restrictedTraverse(url)
if params is None:
Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_DiscussionReply.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_DiscussionReply.py 2007-01-24 11:16:47 UTC (rev 72208)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_DiscussionReply.py 2007-01-24 11:27:35 UTC (rev 72209)
@@ -19,11 +19,8 @@
from Testing import ZopeTestCase
from AccessControl.SecurityManagement import newSecurityManager
+from zope.app.component.hooks import setSite
-from zope.component import getSiteManager
-
-from Products.CMFCore.interfaces import IMembershipTool
-from Products.CMFCore.interfaces import ITypesTool
from Products.CMFDefault.testing import FunctionalLayer
@@ -32,16 +29,8 @@
layer = FunctionalLayer
def afterSetUp(self):
-
- # Need to make sure we get a _clean_ datbase connection, otherwise
- # tests are plagued by ZODB connection errors due to the way the
- # FunctionalLayer sets up the portal.
- self.app = ZopeTestCase.app()
-
+ setSite(self.app.site)
self.portal = self.app.site
- sm = getSiteManager()
- sm.registerUtility(self.portal.portal_membership, IMembershipTool)
- sm.registerUtility(self.portal.portal_types, ITypesTool)
# Become a Manager
self.uf = self.portal.acl_users
self.uf.userFolderAddUser('manager', '', ['Manager'], [])
@@ -73,10 +62,6 @@
# else's document.
def afterSetUp(self):
- self.portal = self.app.site
- sm = getSiteManager()
- sm.registerUtility(self.portal.portal_membership, IMembershipTool)
- sm.registerUtility(self.portal.portal_types, ITypesTool)
DiscussionReplyTest.afterSetUp(self)
self.uf.userFolderAddUser('member', '', ['Member'], [])
self.site_login('member')
Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Image.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Image.py 2007-01-24 11:16:47 UTC (rev 72208)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Image.py 2007-01-24 11:27:35 UTC (rev 72209)
@@ -22,6 +22,7 @@
from cStringIO import StringIO
from zope.app.component.hooks import setHooks
+from zope.app.component.hooks import setSite
from zope.component import getSiteManager
import transaction
@@ -29,9 +30,6 @@
from AccessControl.User import UnrestrictedUser
from Products.CMFCore.interfaces import ICachingPolicyManager
-from Products.CMFCore.interfaces import IConfigurableWorkflowTool
-from Products.CMFCore.interfaces import IMembershipTool
-from Products.CMFCore.interfaces import ITypesTool
from Products.CMFCore.testing import ConformsToContent
from Products.CMFCore.tests.base.dummy import DummyCachingManager
from Products.CMFCore.tests.base.dummy import DummyCachingManagerWithPolicy
@@ -114,16 +112,10 @@
layer = FunctionalLayer
def afterSetUp(self):
-
- self.site = self.app.site
- sm = getSiteManager()
- sm.registerUtility( self.app.site.portal_workflow
- , IConfigurableWorkflowTool
- )
- sm.registerUtility(self.app.site.portal_membership, IMembershipTool)
- sm.registerUtility(self.app.site.portal_types, ITypesTool)
+ setSite(self.app.site)
newSecurityManager(None, UnrestrictedUser('god', '', ['Manager'], ''))
+ self.site = self.app.site
self.site.invokeFactory('File', id='file')
self.site.portal_workflow.doActionFor(self.site.file, 'publish')
self.site.invokeFactory('Image', id='image')
Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Portal.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Portal.py 2007-01-24 11:16:47 UTC (rev 72208)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Portal.py 2007-01-24 11:27:35 UTC (rev 72209)
@@ -21,14 +21,8 @@
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.User import UnrestrictedUser
from Acquisition import aq_base
+from zope.app.component.hooks import setSite
-from zope.component import getSiteManager
-
-from Products.CMFCore.interfaces import ICatalogTool
-from Products.CMFCore.interfaces import IConfigurableWorkflowTool
-from Products.CMFCore.interfaces import IMembershipTool
-from Products.CMFCore.interfaces import ITypesTool
-from Products.CMFCore.interfaces import IURLTool
from Products.CMFDefault.testing import FunctionalLayer
@@ -36,23 +30,6 @@
layer = FunctionalLayer
- def afterSetUp(self):
- ZopeTestCase.FunctionalTestCase.afterSetUp(self)
-
- # Need to make sure we get a _clean_ datbase connection, otherwise
- # tests are plagued by ZODB connection errors due to the way the
- # FunctionalLayer sets up the portal.
- self.app = ZopeTestCase.app()
-
- sm = getSiteManager()
- sm.registerUtility(self.app.site.portal_catalog, ICatalogTool)
- sm.registerUtility( self.app.site.portal_workflow
- , IConfigurableWorkflowTool
- )
- sm.registerUtility(self.app.site.portal_membership, IMembershipTool)
- sm.registerUtility(self.app.site.portal_types, ITypesTool)
- sm.registerUtility(self.app.site.portal_url, IURLTool)
-
def _makeContent( self, site, portal_type, id='document', **kw ):
newSecurityManager(None, UnrestrictedUser('god', '', ['Manager'], ''))
@@ -64,6 +41,9 @@
return content
+ def afterSetUp(self):
+ setSite(self.app.site)
+
def test_new( self ):
site = self.app.site
Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_join.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_join.py 2007-01-24 11:16:47 UTC (rev 72208)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_join.py 2007-01-24 11:27:35 UTC (rev 72209)
@@ -18,10 +18,8 @@
import unittest
from Testing import ZopeTestCase
-from zope.component import getSiteManager
+from zope.app.component.hooks import setSite
-from Products.CMFCore.interfaces import IMemberDataTool
-from Products.CMFCore.interfaces import IMembershipTool
from Products.CMFDefault.testing import FunctionalLayer
@@ -30,12 +28,8 @@
layer = FunctionalLayer
def afterSetUp(self):
- ZopeTestCase.FunctionalTestCase.afterSetUp(self)
+ setSite(self.app.site)
- sm = getSiteManager()
- sm.registerUtility(self.app.site.portal_memberdata, IMemberDataTool)
- sm.registerUtility(self.app.site.portal_membership, IMembershipTool)
-
def test_join( self ):
site = self.app.site
member_id = 'test_user'
Modified: CMF/branches/jens_tools_as_utilities/CMFTopic/tests/test_DateC.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFTopic/tests/test_DateC.py 2007-01-24 11:16:47 UTC (rev 72208)
+++ CMF/branches/jens_tools_as_utilities/CMFTopic/tests/test_DateC.py 2007-01-24 11:27:35 UTC (rev 72209)
@@ -18,14 +18,9 @@
import unittest
from Testing import ZopeTestCase
-from zope.component import getSiteManager
-
from DateTime.DateTime import DateTime
+from zope.app.component.hooks import setSite
-from Products.CMFCore.interfaces import ICatalogTool
-from Products.CMFCore.interfaces import IConfigurableWorkflowTool
-from Products.CMFCore.interfaces import ITypesTool
-from Products.CMFCore.interfaces import IURLTool
from Products.CMFCore.tests.base.dummy import DummyContent
from Products.CMFDefault.testing import FunctionalLayer
from Products.CMFTopic.Topic import Topic
@@ -166,12 +161,8 @@
day_diffs.extend(selectable_diffs)
def afterSetUp(self):
+ setSite(self.app.site)
self.site = self.app.site
- sm = getSiteManager()
- sm.registerUtility(self.site.portal_catalog, ICatalogTool)
- sm.registerUtility(self.site.portal_workflow, IConfigurableWorkflowTool)
- sm.registerUtility(self.site.portal_types, ITypesTool)
- sm.registerUtility(self.site.portal_url, IURLTool)
self.site._setObject( 'topic', Topic('topic') )
self.topic = self.site.topic
self.topic.addCriterion('modified', 'Friendly Date Criterion')
More information about the CMF-checkins
mailing list