[CMF-checkins] SVN: CMF/branches/jens_tools_as_utilities/CMF - test
cleanup (all tests pass now)
Yvo Schubbe
y.2007- at wcm-solutions.de
Mon Jan 29 13:12:16 EST 2007
Log message for revision 72254:
- test cleanup (all tests pass now)
Changed:
U CMF/branches/jens_tools_as_utilities/CMFActionIcons/tests/test_exportimport.py
U CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/tests/test_actions.py
U CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_ActionsTool.py
U CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSPageTemplate.py
U CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSReSTMethod.py
U CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSSTXMethod.py
U CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_MemberDataTool.py
U CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_PortalContent.py
U CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_PortalFolder.py
U CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_TypesTool.py
U CMF/branches/jens_tools_as_utilities/CMFDefault/browser/folder.txt
U CMF/branches/jens_tools_as_utilities/CMFDefault/tests/RegistrationTool.txt
U CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_DiscussionTool.py
U CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Discussions.py
U CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_DublinCore.py
U CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Favorite.py
U CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_File.py
U CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Image.py
U CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_MembershipTool.py
U CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_RegistrationTool.py
U CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_SyndicationTool.py
U CMF/branches/jens_tools_as_utilities/CMFTopic/tests/test_Topic.py
U CMF/branches/jens_tools_as_utilities/CMFUid/tests/test_uidhandling.py
-=-
Modified: CMF/branches/jens_tools_as_utilities/CMFActionIcons/tests/test_exportimport.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFActionIcons/tests/test_exportimport.py 2007-01-29 18:08:16 UTC (rev 72253)
+++ CMF/branches/jens_tools_as_utilities/CMFActionIcons/tests/test_exportimport.py 2007-01-29 18:12:14 UTC (rev 72254)
@@ -71,7 +71,7 @@
tool = ActionIconsTool()
site._setObject( tool.getId(), tool )
- sm = getSiteManager(site)
+ sm = getSiteManager()
sm.registerUtility(site.portal_actionicons, IActionIconsTool)
if with_icon:
Modified: CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/tests/test_actions.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/tests/test_actions.py 2007-01-29 18:08:16 UTC (rev 72253)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/tests/test_actions.py 2007-01-29 18:12:14 UTC (rev 72254)
@@ -20,9 +20,9 @@
from Acquisition import Implicit
from Acquisition import aq_parent
-from OFS.Folder import Folder
from OFS.OrderedFolder import OrderedFolder
+from zope.component import getSiteManager
from zope.interface import implements
from zope.interface import Interface
@@ -343,7 +343,6 @@
def setUp(self):
from Products.CMFCore.interfaces import IActionsTool
from Products.CMFCore.ActionsTool import ActionsTool
- from zope.component import getGlobalSiteManager
BodyAdapterTestCase.setUp(self)
site = DummySite('site')
@@ -352,8 +351,8 @@
self._BODY = _ACTIONSTOOL_BODY
# utility registration
- gsm = getGlobalSiteManager()
- gsm.registerUtility(self._obj, IActionsTool)
+ sm = getSiteManager()
+ sm.registerUtility(self._obj, IActionsTool)
class _ActionSetup(BaseRegistryTests):
Modified: CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_ActionsTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_ActionsTool.py 2007-01-29 18:08:16 UTC (rev 72253)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_ActionsTool.py 2007-01-29 18:12:14 UTC (rev 72254)
@@ -19,6 +19,7 @@
import Testing
from zope.component import getSiteManager
+from zope.testing.cleanup import cleanUp
from Products.CMFCore.ActionInformation import Action
from Products.CMFCore.ActionInformation import ActionCategory
@@ -152,7 +153,11 @@
'category': 'folder'}],
'global': []})
+ def tearDown(self):
+ cleanUp()
+ SecurityRequestTest.tearDown(self)
+
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(ActionsToolTests),
Modified: CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSPageTemplate.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSPageTemplate.py 2007-01-29 18:08:16 UTC (rev 72253)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSPageTemplate.py 2007-01-29 18:12:14 UTC (rev 72254)
@@ -24,9 +24,9 @@
from OFS.Folder import Folder
from Products.StandardCacheManagers import RAMCacheManager
-from zope.app.component.hooks import setHooks
from zope.component import getSiteManager
from zope.tales.tales import Undefined
+from zope.testing.cleanup import cleanUp
from Products.CMFCore.FSPageTemplate import FSPageTemplate
from Products.CMFCore.FSMetadata import FSMetadata
@@ -62,7 +62,7 @@
def _setupCachingPolicyManager(self, cpm_object):
self.root.caching_policy_manager = cpm_object
- sm = getSiteManager(self.root)
+ sm = getSiteManager()
sm.registerUtility( self.root.caching_policy_manager
, ICachingPolicyManager
)
@@ -140,11 +140,12 @@
script = script.__of__(self.root)
self.assertEqual(script(), 'foo bar spam eggs\n')
+
class FSPageTemplateCustomizationTests( SecurityTest, FSPTMaker ):
- def setUp( self ):
+ def setUp(self):
FSPTMaker.setUp(self)
- SecurityTest.setUp( self )
+ SecurityTest.setUp(self)
self.root._setObject( 'portal_skins', Folder( 'portal_skins' ) )
self.skins = self.root.portal_skins
@@ -162,6 +163,11 @@
self.fsPT = self.fsdir.testPT
+ def tearDown(self):
+ cleanUp()
+ SecurityTest.tearDown(self)
+ FSPTMaker.tearDown(self)
+
def test_customize( self ):
self.fsPT.manage_doCustomize( folder_path='custom' )
@@ -193,11 +199,7 @@
customized = self.custom.testPT
self.failIf( customized.expand )
- def tearDown(self):
- SecurityTest.tearDown(self)
- FSPTMaker.tearDown(self)
-
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(FSPageTemplateTests),
Modified: CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSReSTMethod.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSReSTMethod.py 2007-01-29 18:08:16 UTC (rev 72253)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSReSTMethod.py 2007-01-29 18:12:14 UTC (rev 72254)
@@ -15,10 +15,13 @@
$Id$
"""
import unittest
+import Testing
+
import os
import re
from zope.component import getSiteManager
+from zope.testing.cleanup import cleanUp
from Products.CMFCore.interfaces import ICachingPolicyManager
from Products.CMFCore.interfaces import ISkinsTool
@@ -150,6 +153,7 @@
self.assertEqual( data, '' )
self.assertEqual( self.RESPONSE.getStatus(), 304 )
+
ADD_ZPT = 'Add page templates'
ZPT_META_TYPES = ( { 'name' : 'Page Template'
, 'action' : 'manage_addPageTemplate'
@@ -158,11 +162,13 @@
,
)
+
class FSReSTMethodCustomizationTests(SecurityTest, FSReSTMaker):
- def setUp( self ):
+ def setUp(self):
from OFS.Folder import Folder
- SecurityTest.setUp( self )
+
+ SecurityTest.setUp(self)
FSReSTMaker.setUp(self)
self.root._setObject( 'portal_skins', Folder( 'portal_skins' ) )
@@ -181,9 +187,10 @@
self.fsReST = self.fsdir.testReST
- def tearDown( self ):
- FSReSTMaker.tearDown( self )
- SecurityTest.tearDown( self )
+ def tearDown(self):
+ cleanUp()
+ FSReSTMaker.tearDown(self)
+ SecurityTest.tearDown(self)
def test_customize( self ):
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
@@ -224,11 +231,7 @@
self.assertEqual(custom_pt.ZCacheable_getManagerId(), cache_id)
- def tearDown(self):
- SecurityTest.tearDown(self)
- FSReSTMaker.tearDown(self)
-
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(FSReSTMethodTests),
@@ -236,4 +239,5 @@
))
if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+ from Products.CMFCore.testing import run
+ run(test_suite())
Modified: CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSSTXMethod.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSSTXMethod.py 2007-01-29 18:08:16 UTC (rev 72253)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSSTXMethod.py 2007-01-29 18:12:14 UTC (rev 72254)
@@ -15,10 +15,13 @@
$Id$
"""
import unittest
+import Testing
+
import os
import re
from zope.component import getSiteManager
+from zope.testing.cleanup import cleanUp
from Products.CMFCore.interfaces import ICachingPolicyManager
from Products.CMFCore.interfaces import ISkinsTool
@@ -26,8 +29,8 @@
from Products.CMFCore.tests.base.testcase import FSDVTest
from Products.CMFCore.tests.base.testcase import RequestTest
from Products.CMFCore.tests.base.testcase import SecurityTest
-from Products.CMFCore.tests.base.utils import _setUpDefaultTraversable
+
class FSSTXMaker(FSDVTest):
def _makeOne( self, id, filename ):
@@ -102,12 +105,12 @@
def setUp(self):
_TemplateSwitcher.setUp(self)
+ RequestTest.setUp(self)
FSSTXMaker.setUp(self)
- RequestTest.setUp(self)
def tearDown(self):
+ FSSTXMaker.tearDown(self)
RequestTest.tearDown(self)
- FSSTXMaker.tearDown(self)
_TemplateSwitcher.tearDown(self)
def test___call___with_DTML( self ):
@@ -121,7 +124,6 @@
self._setWhichTemplate('ZPT')
script = self._makeOne( 'testSTX', 'testSTX.stx' )
script = script.__of__(self.app)
- _setUpDefaultTraversable()
self.assertEqual(_normalize_whitespace(script(self.REQUEST)),
_normalize_whitespace(_EXPECTED_HTML))
@@ -181,6 +183,7 @@
self.assertEqual( data, '' )
self.assertEqual( self.RESPONSE.getStatus(), 304 )
+
ADD_ZPT = 'Add page templates'
ZPT_META_TYPES = ( { 'name' : 'Page Template'
, 'action' : 'manage_addPageTemplate'
@@ -189,16 +192,18 @@
,
)
+
class FSSTXMethodCustomizationTests(SecurityTest,
FSSTXMaker,
_TemplateSwitcher,
):
- def setUp( self ):
+ def setUp(self):
from OFS.Folder import Folder
+
+ _TemplateSwitcher.setUp(self)
+ SecurityTest.setUp(self)
FSSTXMaker.setUp(self)
- SecurityTest.setUp( self )
- _TemplateSwitcher.setUp( self )
self.root._setObject( 'portal_skins', Folder( 'portal_skins' ) )
self.skins = self.root.portal_skins
@@ -216,10 +221,11 @@
self.fsSTX = self.fsdir.testSTX
- def tearDown( self ):
- _TemplateSwitcher.tearDown( self )
- FSSTXMaker.tearDown( self )
- SecurityTest.tearDown( self )
+ def tearDown(self):
+ cleanUp()
+ FSSTXMaker.tearDown(self)
+ SecurityTest.tearDown(self)
+ _TemplateSwitcher.tearDown(self)
def test_customize_with_DTML( self ):
from OFS.DTMLDocument import DTMLDocument
@@ -282,11 +288,7 @@
self.assertEqual(custom_pt.ZCacheable_getManagerId(), cache_id)
- def tearDown(self):
- SecurityTest.tearDown(self)
- FSSTXMaker.tearDown(self)
-
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(FSSTXMethodTests),
@@ -294,4 +296,5 @@
))
if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+ from Products.CMFCore.testing import run
+ run(test_suite())
Modified: CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_MemberDataTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_MemberDataTool.py 2007-01-29 18:08:16 UTC (rev 72253)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_MemberDataTool.py 2007-01-29 18:12:14 UTC (rev 72254)
@@ -21,6 +21,7 @@
import Acquisition
from zope.component import getSiteManager
+from zope.testing.cleanup import cleanUp
from Products.CMFCore.interfaces import IMemberDataTool
from Products.CMFCore.interfaces import IMembershipTool
@@ -75,6 +76,9 @@
return MemberDataTool(*args, **kw)
+ def tearDown(self):
+ cleanUp()
+
def test_z2interfaces(self):
from Interface.Verify import verifyClass
from Products.CMFCore.interfaces.portal_actions \
@@ -108,7 +112,7 @@
from OFS.Folder import Folder
from Products.CMFCore.MembershipTool import MembershipTool
folder = Folder('test')
- sm = getSiteManager(folder)
+ sm = getSiteManager()
folder._setObject('portal_memberdata', self._makeOne())
sm.registerUtility(folder.portal_memberdata, IMemberDataTool)
folder._setObject('portal_membership', MembershipTool())
Modified: CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_PortalContent.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_PortalContent.py 2007-01-29 18:08:16 UTC (rev 72253)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_PortalContent.py 2007-01-29 18:12:14 UTC (rev 72254)
@@ -23,6 +23,7 @@
from OFS.Folder import Folder
from zope.component import getSiteManager
+from zope.testing.cleanup import cleanUp
from Products.CMFCore.exceptions import NotFound
from Products.CMFCore.interfaces import ITypesTool
@@ -37,6 +38,9 @@
class PortalContentTests(unittest.TestCase):
+ def tearDown(self):
+ cleanUp()
+
def test_z2interfaces(self):
from Interface.Verify import verifyClass
from Products.CMFCore.interfaces.Contentish \
Modified: CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_PortalFolder.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_PortalFolder.py 2007-01-29 18:08:16 UTC (rev 72253)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_PortalFolder.py 2007-01-29 18:12:14 UTC (rev 72254)
@@ -27,7 +27,6 @@
from DateTime import DateTime
from OFS.Image import manage_addFile
-from zope.component import getGlobalSiteManager
from zope.component import getSiteManager
from zope.component.interfaces import IFactory
from zope.interface import implements
@@ -72,14 +71,14 @@
from Products.CMFCore.PortalFolder import PortalFolder
SecurityTest.setUp(self)
- gsm = getGlobalSiteManager()
- gsm.registerUtility(self._getTargetObject(), IFactory, 'cmf.folder')
+ sm = getSiteManager()
+ sm.registerUtility(self._getTargetObject(), IFactory, 'cmf.folder')
self.site = DummySite('site').__of__(self.root)
acl_users = self.site._setObject('acl_users', DummyUserFolder())
newSecurityManager(None, acl_users.all_powerful_Oz)
ttool = self.site._setObject('portal_types', TypesTool())
- gsm.registerUtility(self.site.portal_types, ITypesTool)
+ sm.registerUtility(self.site.portal_types, ITypesTool)
ttool._setObject(self._PORTAL_TYPE,
FTI(id=self._PORTAL_TYPE,
title='Folder or Directory',
@@ -131,11 +130,7 @@
self._getTargetClass()(id, *args, **kw))
def setUp(self):
- from Products.CMFCore.PortalFolder import PortalFolderFactory
-
SecurityTest.setUp(self)
- gsm = getGlobalSiteManager()
- gsm.registerUtility(PortalFolderFactory, IFactory, 'cmf.folder')
self.site = DummySite('site').__of__(self.root)
def test_z2interfaces(self):
@@ -151,7 +146,7 @@
verifyClass(IOrderedContainer, self._getTargetClass())
def test_contents_methods(self):
- sm = getSiteManager()
+ sm = getSiteManager(self.site)
ttool = self.site._setObject( 'portal_types', TypesTool() )
sm.registerUtility(ttool, ITypesTool)
f = self._makeOne('foo')
@@ -298,7 +293,7 @@
#
from Products.CMFCore.PortalFolder import PortalFolder
- sm = getSiteManager()
+ sm = getSiteManager(self.site)
test = self._makeOne('test')
ttool = self.site._setObject( 'portal_types', TypesTool() )
@@ -353,7 +348,7 @@
#
# _verifyObjectPaste() should honor allowed content types
#
- sm = getSiteManager()
+ sm = getSiteManager(self.site)
ttool = self.site._setObject( 'portal_types', TypesTool() )
sm.registerUtility(ttool, ITypesTool)
fti = FTIDATA_DUMMY[0].copy()
@@ -403,7 +398,7 @@
self.assertRaises(BadRequest, test._checkId, 'acl_users')
def test__checkId_MethodAlias(self):
- sm = getSiteManager()
+ sm = getSiteManager(self.site)
test = self._makeOne('test')
test._setPortalTypeName('Dummy Content 15')
ttool = self.site._setObject('portal_types', TypesTool())
Modified: CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_TypesTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_TypesTool.py 2007-01-29 18:08:16 UTC (rev 72253)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_TypesTool.py 2007-01-29 18:12:14 UTC (rev 72254)
@@ -26,7 +26,7 @@
from Products.PythonScripts.PythonScript import PythonScript
from Products.PythonScripts.standard import html_quote
from webdav.NullResource import NullResource
-from zope.component import getGlobalSiteManager
+from zope.component import getSiteManager
from zope.component.interfaces import IFactory
from zope.testing.cleanup import cleanUp
@@ -447,8 +447,8 @@
def setUp(self):
SecurityTest.setUp(self)
- gsm = getGlobalSiteManager()
- gsm.registerUtility(DummyFactory, IFactory, 'test.dummy')
+ sm = getSiteManager()
+ sm.registerUtility(DummyFactory, IFactory, 'test.dummy')
self.f = DummyFolder()
self.ti = self._makeOne('Foo', meta_type='Dummy',
@@ -456,8 +456,8 @@
newSecurityManager(None, UserWithRoles('FooAdder').__of__(self.f))
def tearDown(self):
+ cleanUp()
SecurityTest.tearDown(self)
- cleanUp()
def test_suite():
Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/browser/folder.txt
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/browser/folder.txt 2007-01-29 18:08:16 UTC (rev 72253)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/browser/folder.txt 2007-01-29 18:12:14 UTC (rev 72254)
@@ -108,3 +108,8 @@
>>> view.validateClipboardData()
(False, u'Please copy or cut one or more items to paste first.')
+
+ Finally we have to clean up::
+
+ >>> from zope.testing.cleanup import cleanUp
+ >>> cleanUp()
Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/tests/RegistrationTool.txt
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/tests/RegistrationTool.txt 2007-01-29 18:08:16 UTC (rev 72253)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/tests/RegistrationTool.txt 2007-01-29 18:12:14 UTC (rev 72254)
@@ -8,7 +8,8 @@
... def getProperty(self, id): return 'foo at example.org'
... def getPassword(self): return 'secret'
- >>> class MembershipTool:
+ >>> from Acquisition import Implicit
+ >>> class MembershipTool(Implicit):
... def getMemberById(self, id): return Member()
>>> class MailHost:
@@ -25,14 +26,16 @@
Now we can set up a RegistrationTool with dummy context::
- >>> from Products.CMFDefault.RegistrationTool import RegistrationTool
- >>> from Products.CMFCore.interfaces import IMembershipTool
+ >>> from zope.app.component.hooks import setSite
>>> from zope.component import getSiteManager
- >>> rtool = RegistrationTool()
- >>> rtool.MailHost = MailHost()
- >>> rtool.portal_membership = MembershipTool()
+ >>> from zope.component import getUtility
+ >>> from Products.CMFCore.interfaces import IMembershipTool
+ >>> from Products.MailHost.interfaces import IMailHost
+ >>> setSite(app.site)
>>> sm = getSiteManager()
- >>> sm.registerUtility(rtool.portal_membership, IMembershipTool)
+ >>> sm.registerUtility(MembershipTool(), IMembershipTool)
+ >>> sm.registerUtility(MailHost(), IMailHost)
+ >>> rtool = app.site.portal_registration
>>> rtool.password_email = password_email
>>> rtool.mail_password_response = mail_password_response
>>> rtool.registered_email = registered_email
@@ -42,79 +45,34 @@
>>> rtool.mailPassword('foo', None)
'done'
- >>> rtool.MailHost.lastMessage
+ >>> getUtility(IMailHost).lastMessage
'Reminder: foo, secret'
registeredNotify sends a welcome message::
>>> rtool.registeredNotify('foo')
- >>> rtool.MailHost.lastMessage
+ >>> getUtility(IMailHost).lastMessage
'Welcome: foo, secret, foo at example.org'
+ Now we have to restore the normal MembershipTool::
+
+ >>> sm.registerUtility(app.site.portal_membership, IMembershipTool)
+
password_email and registered_email
-----------------------------------
- First we need some dummy code::
+ First we have to set up some site properties::
- >>> from os.path import join
- >>> from OFS.Folder import Folder
- >>> from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
- >>> from Products.PythonScripts.PythonScript import PythonScript
- >>> class DummySite(Folder):
- ... def getPhysicalRoot(self): return self
- ... def getPhysicalPath(self): return ('root',)
- ... def addResource(self, dir, f_name):
- ... r_name, f_type = f_name.split('.')
- ... if f_type == 'pt': r = ZopePageTemplate(r_name)
- ... if f_type == 'py': r = PythonScript(r_name)
- ... f = file(join(dir, f_name), 'r')
- ... r.write(f.read())
- ... f.close()
- ... setattr(self, r_name, r)
-
- >>> class DummyTool(Folder):
- ... def getActionInfo(self, action_chain): return self.login_action
- ... def getProperty(self, id, d=None): return getattr(self, id, d)
- ... def title(self): return self.Title
- ... def __call__(self): return self.url
-
- And have to set up security::
-
- >>> from AccessControl.SecurityManagement import newSecurityManager
- >>> from AccessControl.User import UnrestrictedUser
- >>> newSecurityManager(None, UnrestrictedUser('god', '', ['Manager'], ''))
-
- Now we can set up password_email and registered_email with dummy context::
-
- >>> from Testing.makerequest import makerequest
- >>> from Products.CMFCore.interfaces import IActionsTool
- >>> from Products.CMFCore.interfaces import IPropertiesTool
- >>> from Products.CMFCore.interfaces import IURLTool
- >>> s = makerequest(DummySite())
+ >>> s = app.site
>>> s.REQUEST.environ['HTTP_X_FORWARDED_FOR'] = 'NNN.NNN.NNN.NNN'
- >>> s.portal_actions = s.portal_properties = s.portal_url = DummyTool()
- >>> sm = getSiteManager()
- >>> sm.registerUtility(s.portal_actions, IActionsTool)
- >>> sm.registerUtility(s.portal_properties, IPropertiesTool)
- >>> sm.registerUtility(s.portal_url, IURLTool)
>>> s.ZopeTime = 'NNNN/NN/NN'
>>> s.description = 'THE SITE DESCRIPTION.'
>>> s.default_charset = 'utf-8'
>>> s.email_from_name = u'WEBMASTER \xc4\xd6\xdc'.encode('utf-8')
>>> s.email_from_address = 'WEBMASTER at EXAMPLE.ORG'
- >>> s.Title = 'WWW.EXAMPLE.ORG'
- >>> s.url = 'PORTAL_URL'
- >>> s.login_action = {'url': 'LOGIN_URL'}
+ >>> s.title = 'WWW.EXAMPLE.ORG'
- >>> from os.path import dirname
- >>> from Products import CMFDefault
- >>> dir = join(dirname(CMFDefault.__file__), 'skins', 'zpt_generic')
- >>> s.addResource(dir, 'password_email.py')
- >>> s.addResource(dir, 'password_email_template.pt')
- >>> s.addResource(dir, 'registered_email.py')
- >>> s.addResource(dir, 'registered_email_template.pt')
-
password_email creates a complete reminder email::
>>> s.email_charset = 'iso-8859-1'
@@ -164,7 +122,7 @@
<BLANKLINE>
THE SITE DESCRIPTION.
<BLANKLINE>
- [[cmf_default][Visit us at PORTAL_URL]]
+ [[cmf_default][Visit us at http://nohost/site]]
<BLANKLINE>
[[cmf_default][Here is your login data (mind upper and lower case):]]
<BLANKLINE>
@@ -173,7 +131,7 @@
<BLANKLINE>
[[cmf_default][You can use this URL to log in:]]
<BLANKLINE>
- LOGIN_URL
+ http://nohost/site/login_form
<BLANKLINE>
<BLANKLINE>
WEBMASTER =C4=D6=DC
@@ -191,8 +149,3 @@
<BLANKLINE>
W1tj...
<BLANKLINE>
-
- Finally we have to clean up::
-
- >>> from AccessControl.SecurityManagement import noSecurityManager
- >>> noSecurityManager()
Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_DiscussionTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_DiscussionTool.py 2007-01-29 18:08:16 UTC (rev 72253)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_DiscussionTool.py 2007-01-29 18:12:14 UTC (rev 72254)
@@ -19,6 +19,7 @@
import Testing
from zope.component import getSiteManager
+from zope.testing.cleanup import cleanUp
from Products.CMFCore.interfaces import IDiscussionTool
from Products.CMFCore.interfaces import IMembershipTool
@@ -45,6 +46,9 @@
self.site._setObject( 'portal_types', DummyTool() )
sm.registerUtility(self.site.portal_types, ITypesTool)
+ def tearDown(self):
+ cleanUp()
+
def test_z2interfaces(self):
from Interface.Verify import verifyClass
from Products.CMFCore.interfaces.portal_actions \
Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Discussions.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Discussions.py 2007-01-29 18:08:16 UTC (rev 72253)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Discussions.py 2007-01-29 18:12:14 UTC (rev 72254)
@@ -111,7 +111,7 @@
def setUp(self):
SecurityTest.setUp(self)
self.site = DummySite('site').__of__(self.root)
- sm = getSiteManager(self.site)
+ sm = getSiteManager()
self.site._setObject( 'portal_discussion', DiscussionTool() )
sm.registerUtility(self.site.portal_discussion, IDiscussionTool)
self.site._setObject( 'portal_membership', DummyTool() )
@@ -205,7 +205,7 @@
assert parents[ 0 ] == reply1
def test_itemCataloguing( self ):
- sm = getSiteManager(self.site)
+ sm = getSiteManager()
ctool = self.site._setObject( 'portal_catalog', CatalogTool() )
sm.registerUtility(ctool, ICatalogTool)
dtool = self.site.portal_discussion
@@ -269,7 +269,7 @@
DiscussionItem.notifyWorkflowCreated = old_method
def test_deletePropagation( self ):
- sm = getSiteManager(self.site)
+ sm = getSiteManager()
ctool = self.site._setObject( 'portal_catalog', CatalogTool() )
sm.registerUtility(ctool, ICatalogTool)
dtool = self.site.portal_discussion
@@ -285,7 +285,7 @@
self.assertEqual( len(ctool), 0 )
def test_deleteReplies(self):
- sm = getSiteManager(self.site)
+ sm = getSiteManager()
dtool = self.site.portal_discussion
ctool = self.site._setObject( 'portal_catalog', CatalogTool() )
sm.registerUtility(ctool, ICatalogTool)
Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_DublinCore.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_DublinCore.py 2007-01-29 18:08:16 UTC (rev 72253)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_DublinCore.py 2007-01-29 18:12:14 UTC (rev 72254)
@@ -23,6 +23,7 @@
from DateTime.DateTime import DateTime
from zope.component import getSiteManager
+from zope.testing.cleanup import cleanUp
from Products.CMFCore.interfaces import IMembershipTool
from Products.CMFCore.interfaces import IMetadataTool
@@ -32,7 +33,6 @@
from Products.CMFDefault.MembershipTool import MembershipTool
-
def _DateIndexConvert(value):
# Duplicate date conversion done by DateIndex._convert
t_tup = value.toZone('UTC').parts()
@@ -70,6 +70,10 @@
return DummyContent(id, *args, **kw)
+ def tearDown(self):
+ cleanUp()
+ SecurityTest.tearDown(self)
+
def test_z2interfaces(self):
from Interface.Verify import verifyClass
from Products.CMFCore.interfaces.DublinCore \
Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Favorite.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Favorite.py 2007-01-29 18:08:16 UTC (rev 72253)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Favorite.py 2007-01-29 18:12:14 UTC (rev 72254)
@@ -19,6 +19,7 @@
import Testing
from zope.component import getSiteManager
+from zope.testing.cleanup import cleanUp
from Products.CMFCore.interfaces import IMembershipTool
from Products.CMFCore.interfaces import IURLTool
@@ -45,6 +46,9 @@
self.site._setObject( 'portal_url', DummyTool() )
sm.registerUtility(self.site.portal_url, IURLTool)
+ def tearDown(self):
+ cleanUp()
+
def test_z3interfaces(self):
from zope.interface.verify import verifyClass
from Products.CMFDefault.interfaces import IFavorite
Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_File.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_File.py 2007-01-29 18:08:16 UTC (rev 72253)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_File.py 2007-01-29 18:12:14 UTC (rev 72254)
@@ -20,8 +20,8 @@
from os.path import join as path_join
-from zope.app.component.hooks import setHooks
from zope.component import getSiteManager
+from zope.testing.cleanup import cleanUp
from Products.CMFCore.interfaces import ICachingPolicyManager
from Products.CMFCore.testing import ConformsToContent
@@ -79,10 +79,6 @@
class CachingTests(RequestTest):
- def setUp(self):
- RequestTest.setUp(self)
- setHooks()
-
def _getTargetClass(self):
from Products.CMFDefault.File import File
@@ -103,11 +99,15 @@
def _setupCachingPolicyManager(self, cpm_object):
self.root.caching_policy_manager = cpm_object
- sm = getSiteManager(self.root)
+ sm = getSiteManager()
sm.registerUtility( self.root.caching_policy_manager
, ICachingPolicyManager
)
+ def tearDown(self):
+ cleanUp()
+ RequestTest.tearDown(self)
+
def test_index_html_with_304_from_cpm( self ):
self._setupCachingPolicyManager(DummyCachingManagerWithPolicy())
path, ref = self._extractFile()
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-29 18:08:16 UTC (rev 72253)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Image.py 2007-01-29 18:12:14 UTC (rev 72254)
@@ -21,9 +21,9 @@
from os.path import join as path_join
from cStringIO import StringIO
-from zope.app.component.hooks import setHooks
from zope.app.component.hooks import setSite
from zope.component import getSiteManager
+from zope.testing.cleanup import cleanUp
import transaction
from AccessControl.SecurityManagement import newSecurityManager
@@ -180,10 +180,6 @@
class TestCaching(RequestTest):
- def setUp(self):
- RequestTest.setUp(self)
- setHooks()
-
def _extractFile( self ):
f = open( TEST_JPG, 'rb' )
@@ -204,11 +200,15 @@
def _setupCachingPolicyManager(self, cpm_object):
self.root.caching_policy_manager = cpm_object
- sm = getSiteManager(self.root)
+ sm = getSiteManager()
sm.registerUtility( self.root.caching_policy_manager
, ICachingPolicyManager
)
+ def tearDown(self):
+ cleanUp()
+ RequestTest.tearDown(self)
+
def test_index_html_with_304_from_cpm( self ):
self._setupCachingPolicyManager(DummyCachingManagerWithPolicy())
path, ref = self._extractFile()
Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_MembershipTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_MembershipTool.py 2007-01-29 18:08:16 UTC (rev 72253)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_MembershipTool.py 2007-01-29 18:12:14 UTC (rev 72254)
@@ -21,6 +21,7 @@
from AccessControl.SecurityManagement import newSecurityManager
from zope.component import getSiteManager
+from zope.testing.cleanup import cleanUp
from Products.CMFCore.interfaces import IConfigurableWorkflowTool
from Products.CMFCore.interfaces import IMembershipTool
@@ -88,6 +89,10 @@
self.site = DummySite('site').__of__(self.root)
self.site._setObject( 'portal_membership', self._makeOne() )
+ def tearDown(self):
+ cleanUp()
+ SecurityTest.tearDown(self)
+
def test_createMemberArea(self):
mtool = self.site.portal_membership
members = self.site._setObject( 'Members', PortalFolder('Members') )
Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_RegistrationTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_RegistrationTool.py 2007-01-29 18:08:16 UTC (rev 72253)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_RegistrationTool.py 2007-01-29 18:12:14 UTC (rev 72254)
@@ -19,7 +19,8 @@
from Testing import ZopeTestCase
from Acquisition import Implicit
-from zope.component import getGlobalSiteManager
+from zope.component import getSiteManager
+from zope.testing.cleanup import cleanUp
from Products.CMFCore.interfaces import IMembershipTool
from Products.CMFCore.tests.base.testcase import RequestTest
@@ -42,6 +43,10 @@
def _makeOne(self, *args, **kw):
return self._getTargetClass()(*args, **kw)
+ def tearDown(self):
+ cleanUp()
+ RequestTest.tearDown(self)
+
def test_z2interfaces(self):
from Interface.Verify import verifyClass
from Products.CMFCore.interfaces.portal_actions \
@@ -73,7 +78,7 @@
rtool = self._makeOne()
mtool = FauxMembershipTool()
- sm = getGlobalSiteManager()
+ sm = getSiteManager()
sm.registerUtility(mtool, IMembershipTool)
props = { 'email' : INJECTED_HEADERS
@@ -84,9 +89,7 @@
self.failIf( result is None, 'Invalid e-mail passed inspection' )
- sm.unregisterUtility(mtool, IMembershipTool)
-
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(RegistrationToolTests))
Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_SyndicationTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_SyndicationTool.py 2007-01-29 18:08:16 UTC (rev 72253)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_SyndicationTool.py 2007-01-29 18:12:14 UTC (rev 72254)
@@ -21,6 +21,7 @@
from DateTime.DateTime import DateTime
from zope.component import getSiteManager
+from zope.testing.cleanup import cleanUp
from Products.CMFCore.interfaces import ITypesTool
from Products.CMFCore.tests.base.testcase import SecurityTest
@@ -41,6 +42,10 @@
def _makeOne(self, *args, **kw):
return self._getTargetClass()(*args, **kw)
+ def tearDown(self):
+ cleanUp()
+ SecurityTest.tearDown(self)
+
def test_empty(self):
ONE_MINUTE = (24.0 * 60.0) / 86400
Modified: CMF/branches/jens_tools_as_utilities/CMFTopic/tests/test_Topic.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFTopic/tests/test_Topic.py 2007-01-29 18:08:16 UTC (rev 72253)
+++ CMF/branches/jens_tools_as_utilities/CMFTopic/tests/test_Topic.py 2007-01-29 18:12:14 UTC (rev 72254)
@@ -143,7 +143,7 @@
self._getTargetClass()(id, *args, **kw))
def _initSite(self, max_items=15, index_ids=()):
- sm = getSiteManager(self.site)
+ sm = getSiteManager()
self.site.portal_catalog = DummyCatalog( index_ids )
sm.registerUtility(self.site.portal_catalog, ICatalogTool)
self.site.portal_syndication = DummySyndicationTool( max_items )
Modified: CMF/branches/jens_tools_as_utilities/CMFUid/tests/test_uidhandling.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFUid/tests/test_uidhandling.py 2007-01-29 18:08:16 UTC (rev 72253)
+++ CMF/branches/jens_tools_as_utilities/CMFUid/tests/test_uidhandling.py 2007-01-29 18:12:14 UTC (rev 72254)
@@ -19,6 +19,7 @@
import Testing
from zope.component import getSiteManager
+from zope.testing.cleanup import cleanUp
from Products.CMFCore.interfaces import ICatalogTool
from Products.CMFCore.tests.base.dummy import DummyContent
@@ -65,6 +66,10 @@
sm.registerUtility(self.root.portal_uidgenerator, IUniqueIdGenerator)
sm.registerUtility(self.root.portal_uidhandler, IUniqueIdHandler)
+ def tearDown(self):
+ cleanUp()
+ SecurityTest.tearDown(self)
+
def test_z3interfaces(self):
from zope.interface.verify import verifyClass
from Products.CMFUid.interfaces import IUniqueIdBrainQuery
More information about the CMF-checkins
mailing list