[CMF-checkins] SVN: CMF/trunk/ - switched tests to layer based ZCML
setup
Yvo Schubbe
y.2006_ at wcm-solutions.de
Mon Nov 6 06:01:28 EST 2006
Log message for revision 71087:
- switched tests to layer based ZCML setup
- removed installProduct('CMFDefault') test dependencies
Changed:
U CMF/trunk/CHANGES.txt
A CMF/trunk/CMFCalendar/testing.py
U CMF/trunk/CMFCalendar/tests/test_Calendar.py
U CMF/trunk/CMFCore/testing.py
A CMF/trunk/CMFCore/testing.zcml
U CMF/trunk/CMFCore/tests/base/testcase.py
U CMF/trunk/CMFCore/tests/test_ActionInformation.py
U CMF/trunk/CMFCore/tests/test_CMFCatalogAware.py
U CMF/trunk/CMFCore/tests/test_CachingPolicyManager.py
U CMF/trunk/CMFCore/tests/test_FSPageTemplate.py
U CMF/trunk/CMFCore/tests/test_OpaqueItems.py
U CMF/trunk/CMFCore/tests/test_PortalContent.py
U CMF/trunk/CMFCore/tests/test_PortalFolder.py
U CMF/trunk/CMFCore/tests/test_TypesTool.py
A CMF/trunk/CMFDefault/testing.py
U CMF/trunk/CMFDefault/tests/RegistrationTool.txt
U CMF/trunk/CMFDefault/tests/test_DiscussionReply.py
U CMF/trunk/CMFDefault/tests/test_Discussions.py
U CMF/trunk/CMFDefault/tests/test_Image.py
U CMF/trunk/CMFDefault/tests/test_Portal.py
U CMF/trunk/CMFDefault/tests/test_RegistrationTool.py
U CMF/trunk/CMFDefault/tests/test_join.py
U CMF/trunk/CMFTopic/tests/test_DateC.py
U CMF/trunk/CMFTopic/tests/test_Topic.py
U CMF/trunk/CMFUid/tests/test_uidannotation.py
U CMF/trunk/DCWorkflow/tests/test_exportimport.py
-=-
Modified: CMF/trunk/CHANGES.txt
===================================================================
--- CMF/trunk/CHANGES.txt 2006-11-06 09:35:01 UTC (rev 71086)
+++ CMF/trunk/CHANGES.txt 2006-11-06 11:01:25 UTC (rev 71087)
@@ -2,6 +2,8 @@
New Features
+ - testing: Added test layers for setting up ZCML.
+
- CMFDefault formlib: Added zope.formlib support.
This includes some CMF specific base classes and an 'EmailLine' field.
Added: CMF/trunk/CMFCalendar/testing.py
===================================================================
--- CMF/trunk/CMFCalendar/testing.py 2006-11-06 09:35:01 UTC (rev 71086)
+++ CMF/trunk/CMFCalendar/testing.py 2006-11-06 11:01:25 UTC (rev 71087)
@@ -0,0 +1,33 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors. All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (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.
+#
+##############################################################################
+""" Unit test layers.
+
+$Id$
+"""
+
+from Products.Five import zcml
+
+from Products.CMFDefault.testing import FunctionalZCMLLayer
+
+
+class FunctionalZCMLLayer(FunctionalZCMLLayer):
+
+ @classmethod
+ def setUp(cls):
+ import Products.CMFCalendar
+
+ zcml.load_config('configure.zcml', Products.CMFCalendar)
+
+ @classmethod
+ def tearDown(cls):
+ pass
Property changes on: CMF/trunk/CMFCalendar/testing.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: CMF/trunk/CMFCalendar/tests/test_Calendar.py
===================================================================
--- CMF/trunk/CMFCalendar/tests/test_Calendar.py 2006-11-06 09:35:01 UTC (rev 71086)
+++ CMF/trunk/CMFCalendar/tests/test_Calendar.py 2006-11-06 11:01:25 UTC (rev 71087)
@@ -19,26 +19,22 @@
from Testing import ZopeTestCase
ZopeTestCase.installProduct('ZCTextIndex', 1)
ZopeTestCase.installProduct('CMFCore', 1)
-ZopeTestCase.installProduct('CMFDefault', 1)
ZopeTestCase.utils.setupCoreSessions()
import locale
-import Products
import transaction
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import noSecurityManager
from AccessControl.User import UnrestrictedUser
from DateTime import DateTime
-from Products.Five import zcml
-from zope.testing.cleanup import cleanUp
from Products.CMFCore import Skinnable
-from Products.CMFCore.tests.base.testcase import setUpEvents
-from Products.CMFCore.tests.base.testcase import setUpGenericSetup
-from Products.CMFCore.tests.base.testcase import setUpTraversing
+from Products.CMFDefault.factory import addConfiguredSite
+from Products.CMFCalendar.testing import FunctionalZCMLLayer
+
class CalendarTests(unittest.TestCase):
def _getTargetClass(self):
@@ -115,19 +111,9 @@
class CalendarRequestTests(unittest.TestCase):
- def setUp(self):
- import Products.DCWorkflow
+ layer = FunctionalZCMLLayer
- setUpEvents()
- setUpTraversing()
- setUpGenericSetup()
- zcml.load_config('permissions.zcml', Products.Five)
- zcml.load_config('configure.zcml', Products.Five.browser)
- zcml.load_config('configure.zcml', Products.Five.skin)
- zcml.load_config('configure.zcml', Products.CMFCalendar)
- zcml.load_config('configure.zcml', Products.CMFCore)
- zcml.load_config('configure.zcml', Products.CMFDefault)
- zcml.load_config('configure.zcml', Products.DCWorkflow)
+ def setUp(self):
self._oldSkindata = Skinnable.SKINDATA.copy()
transaction.begin()
@@ -135,9 +121,9 @@
# Log in as a god :-)
newSecurityManager( None, UnrestrictedUser('god', 'god', ['Manager'], '') )
- factory = app.manage_addProduct['CMFDefault'].addConfiguredSite
- factory('CalendarTest', 'Products.CMFDefault:default', snapshot=False,
- extension_ids=('Products.CMFCalendar:default',))
+ addConfiguredSite(app, 'CalendarTest', 'Products.CMFDefault:default',
+ snapshot=False,
+ extension_ids=('Products.CMFCalendar:default',))
self.Site = app.CalendarTest
self.Tool = app.CalendarTest.portal_calendar
@@ -150,7 +136,6 @@
transaction.abort()
ZopeTestCase.close(self.app)
Skinnable.SKINDATA = self._oldSkindata
- cleanUp()
def _testURL(self,url,params=None):
Site = self.Site
@@ -558,11 +543,11 @@
# Bug in catalog_getevents included events starting at 00:00:00 on the next day
self.Site.invokeFactory('Event', id='today', title='today',
- start_date='2002/05/31 23:50:00',
+ start_date='2002/05/31 23:50:00',
end_date='2002/05/31 23:59:59')
self.Site.invokeFactory('Event', id='tomorrow', title='tomorrow',
- start_date='2002/06/01 00:00:00',
+ start_date='2002/06/01 00:00:00',
end_date='2002/06/01 00:10:00')
self.Site.portal_workflow.doActionFor(self.Site.today, 'publish')
@@ -586,11 +571,11 @@
# Double check it works on the other boundary as well
self.Site.invokeFactory('Event', id='yesterday', title='yesterday',
- start_date='2002/05/31 23:50:00',
+ start_date='2002/05/31 23:50:00',
end_date='2002/05/31 23:59:59')
self.Site.invokeFactory('Event', id='today', title='today',
- start_date='2002/06/01 00:00:00',
+ start_date='2002/06/01 00:00:00',
end_date='2002/06/01 00:10:00')
self.Site.portal_workflow.doActionFor(self.Site.yesterday, 'publish')
@@ -614,33 +599,33 @@
# Calendar should return events in all of the selected workflow states
self.Site.invokeFactory('Event', id='meeting',
- start_date='2002/05/01 11:00:00',
+ start_date='2002/05/01 11:00:00',
end_date='2002/05/01 13:30:00')
self.Site.invokeFactory('Event', id='dinner',
- start_date='2002/05/01 20:00:00',
+ start_date='2002/05/01 20:00:00',
end_date='2002/05/01 22:00:00')
self.assertEqual(len(self.Site.portal_catalog(portal_type='Event')), 2)
# No published events
- self.assertEqual(len(self.Site.portal_calendar.getEventsForThisDay(DateTime('2002/05/01'))), 0)
-
+ self.assertEqual(len(self.Site.portal_calendar.getEventsForThisDay(DateTime('2002/05/01'))), 0)
+
# One published event
self.Site.portal_workflow.doActionFor(self.Site.meeting, 'publish')
self.assertEqual(len(self.Site.portal_catalog(review_state='published')), 1)
- self.assertEqual(len(self.Site.portal_calendar.getEventsForThisDay(DateTime('2002/05/01'))), 1)
+ self.assertEqual(len(self.Site.portal_calendar.getEventsForThisDay(DateTime('2002/05/01'))), 1)
# One pending event
self.Site.portal_workflow.doActionFor(self.Site.dinner, 'submit')
self.assertEqual(len(self.Site.portal_catalog(review_state='pending')), 1)
- self.assertEqual(len(self.Site.portal_calendar.getEventsForThisDay(DateTime('2002/05/01'))), 1)
+ self.assertEqual(len(self.Site.portal_calendar.getEventsForThisDay(DateTime('2002/05/01'))), 1)
# Make calendar return pending events
- self.Site.portal_calendar.edit_configuration(show_types=('Event',),
- show_states=('pending', 'published'),
+ self.Site.portal_calendar.edit_configuration(show_types=('Event',),
+ show_states=('pending', 'published'),
use_session='')
self.assertEqual(len(self.Site.portal_calendar.getEventsForThisDay(DateTime('2002/05/01'))), 2)
@@ -687,4 +672,5 @@
))
if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+ from Products.CMFCore.testing import run
+ run(test_suite())
Modified: CMF/trunk/CMFCore/testing.py
===================================================================
--- CMF/trunk/CMFCore/testing.py 2006-11-06 09:35:01 UTC (rev 71086)
+++ CMF/trunk/CMFCore/testing.py 2006-11-06 11:01:25 UTC (rev 71087)
@@ -10,11 +10,24 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-""" Unit tests mixin classes.
+""" Unit test mixin classes and layers.
$Id$
"""
+from Acquisition import aq_acquire
+from Products.Five import i18n
+from Products.Five import zcml
+from zope.component import adapts
+from zope.i18n.interfaces import INegotiator
+from zope.i18n.interfaces import IUserPreferredLanguages
+from zope.i18n.testmessagecatalog import TestMessageFallbackDomain
+from zope.interface import implements
+from zope.publisher.interfaces.http import IHTTPRequest
+from zope.testing import testrunner
+from zope.testing.cleanup import cleanUp
+
+
class ConformsToFolder:
def test_folder_z2interfaces(self):
@@ -78,3 +91,88 @@
verifyClass(IDublinCore, self._getTargetClass())
verifyClass(IDynamicType, self._getTargetClass())
verifyClass(IMutableDublinCore, self._getTargetClass())
+
+
+class BrowserLanguages(object):
+
+ implements(IUserPreferredLanguages)
+ adapts(IHTTPRequest)
+
+ def __init__(self, context):
+ self.context = context
+
+ def getPreferredLanguages(self):
+ return ('test',)
+
+
+class _Negotiator(object):
+
+ implements(INegotiator)
+
+ def getLanguage(*ignored):
+ return 'test'
+
+negotiator = _Negotiator()
+
+
+class _FallbackTranslationService(object):
+
+ def translate(self, domain, msgid, mapping, context, target_language,
+ default):
+ util = TestMessageFallbackDomain(domain)
+ if context is not None:
+ context = aq_acquire(context, 'REQUEST', None)
+ return util.translate(msgid, mapping, context, target_language,
+ default)
+
+
+class EventZCMLLayer:
+
+ @classmethod
+ def setUp(cls):
+ import Products
+
+ zcml.load_config('meta.zcml', Products.Five)
+ zcml.load_config('event.zcml', Products.Five)
+ zcml.load_config('event.zcml', Products.CMFCore)
+
+ @classmethod
+ def tearDown(cls):
+ cleanUp()
+
+
+class TraversingZCMLLayer:
+
+ @classmethod
+ def setUp(cls):
+ import Products.Five
+
+ zcml.load_config('meta.zcml', Products.Five)
+ zcml.load_config('traversing.zcml', Products.Five)
+
+ @classmethod
+ def tearDown(cls):
+ cleanUp()
+
+
+class FunctionalZCMLLayer:
+
+ @classmethod
+ def setUp(cls):
+ import Products
+
+ cls._fallback_translation_service = i18n._fallback_translation_service
+ i18n._fallback_translation_service = _FallbackTranslationService()
+ zcml.load_config('testing.zcml', Products.CMFCore)
+
+ @classmethod
+ def tearDown(cls):
+ i18n._fallback_translation_service = cls._fallback_translation_service
+ cleanUp()
+
+
+def run(test_suite):
+ options = testrunner.get_options()
+ options.resume_layer = None
+ options.resume_number = 0
+ testrunner.run_with_options(options, test_suite)
Added: CMF/trunk/CMFCore/testing.zcml
===================================================================
--- CMF/trunk/CMFCore/testing.zcml 2006-11-06 09:35:01 UTC (rev 71086)
+++ CMF/trunk/CMFCore/testing.zcml 2006-11-06 11:01:25 UTC (rev 71087)
@@ -0,0 +1,31 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:five="http://namespaces.zope.org/five">
+
+ <include
+ package="Products.Five"
+ file="meta.zcml"
+ />
+
+ <include
+ package="Products.GenericSetup"
+ file="meta.zcml"
+ />
+
+ <include package="Products.Five"/>
+
+ <include package="Products.GenericSetup"/>
+
+ <include package="Products.CMFCore"/>
+
+ <five:deprecatedManageAddDelete
+ class="Products.CMFCore.tests.base.dummy.DummyContent"/>
+
+ <utility component=".testing.negotiator"/>
+
+ <utility
+ component="zope.i18n.testmessagecatalog.TestMessageFallbackDomain"/>
+
+ <adapter factory=".testing.BrowserLanguages"/>
+
+</configure>
Property changes on: CMF/trunk/CMFCore/testing.zcml
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: CMF/trunk/CMFCore/tests/base/testcase.py
===================================================================
--- CMF/trunk/CMFCore/tests/base/testcase.py 2006-11-06 09:35:01 UTC (rev 71086)
+++ CMF/trunk/CMFCore/tests/base/testcase.py 2006-11-06 11:01:25 UTC (rev 71087)
@@ -14,51 +14,12 @@
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import noSecurityManager
from AccessControl.SecurityManager import setSecurityPolicy
-from Products.Five import zcml
from dummy import DummyFolder
from security import AnonymousUser
from security import PermissiveSecurityPolicy
-_REQUEST_ZCML = """
-<configure
- xmlns:five="http://namespaces.zope.org/five"
- >
-
- <!-- make Zope 2's REQUEST implement the right thing -->
- <five:implements
- class="ZPublisher.HTTPRequest.HTTPRequest"
- interface="zope.publisher.interfaces.browser.IBrowserRequest"
- />
-
-</configure>
-"""
-
-def setUpTraversing():
- import Products
-
- zcml.load_config('meta.zcml', Products.Five)
- zcml.load_string(_REQUEST_ZCML)
- zcml.load_config('traversing.zcml', Products.Five)
-
-def setUpEvents():
- import Products
-
- # First, set up "stock" OFS event propagation
- zcml.load_config('meta.zcml', Products.Five)
- zcml.load_config('event.zcml', Products.Five)
- # Now, register the CMF-specific handler
- zcml.load_config('event.zcml', Products.CMFCore)
-
-def setUpGenericSetup():
- import Products
-
- zcml.load_config('meta.zcml', Products.Five)
- zcml.load_config('meta.zcml', Products.GenericSetup)
- zcml.load_config('configure.zcml', Products.GenericSetup)
-
-
class LogInterceptor:
logged = None
@@ -239,7 +200,7 @@
def _addedOrRemoved(self, old_mtime):
# Called after adding/removing a file from self.skin_path_name.
-
+
if sys.platform == 'win32':
# Windows doesn't reliably update directory mod times, so
# DirectoryView has an expensive workaround. The
Modified: CMF/trunk/CMFCore/tests/test_ActionInformation.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_ActionInformation.py 2006-11-06 09:35:01 UTC (rev 71086)
+++ CMF/trunk/CMFCore/tests/test_ActionInformation.py 2006-11-06 11:01:25 UTC (rev 71087)
@@ -18,19 +18,16 @@
import unittest
import Testing
-import Products.Five
from OFS.Folder import manage_addFolder
-from Products.Five import zcml
from Products.PythonScripts.PythonScript import manage_addPythonScript
-from zope.testing.cleanup import cleanUp
from Products.CMFCore.Expression import createExprContext
from Products.CMFCore.Expression import Expression
+from Products.CMFCore.testing import FunctionalZCMLLayer
from Products.CMFCore.tests.base.dummy import DummyContent
from Products.CMFCore.tests.base.dummy import DummySite
from Products.CMFCore.tests.base.dummy import DummyTool as DummyMembershipTool
from Products.CMFCore.tests.base.testcase import SecurityTest
-from Products.CMFCore.tests.base.testcase import setUpTraversing
from Products.CMFCore.tests.base.testcase import TransactionalTest
@@ -325,12 +322,10 @@
class ActionInformationTests(TransactionalTest):
+ layer = FunctionalZCMLLayer
+
def setUp(self):
- import Products.CMFCore
TransactionalTest.setUp(self)
- setUpTraversing()
- zcml.load_config('permissions.zcml', Products.Five)
- zcml.load_config('configure.zcml', Products.CMFCore)
root = self.root
root._setObject('portal', DummyContent('portal', 'url_portal'))
@@ -339,10 +334,6 @@
self.folder = DummyContent('foo', 'url_foo')
self.object = DummyContent('bar', 'url_bar')
- def tearDown(self):
- TransactionalTest.tearDown(self)
- cleanUp()
-
def _makeOne(self, *args, **kw):
from Products.CMFCore.ActionInformation import ActionInformation
@@ -468,4 +459,5 @@
))
if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+ from Products.CMFCore.testing import run
+ run(test_suite())
Modified: CMF/trunk/CMFCore/tests/test_CMFCatalogAware.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_CMFCatalogAware.py 2006-11-06 09:35:01 UTC (rev 71086)
+++ CMF/trunk/CMFCore/tests/test_CMFCatalogAware.py 2006-11-06 11:01:25 UTC (rev 71087)
@@ -23,16 +23,15 @@
from OFS.Folder import Folder
from OFS.SimpleItem import SimpleItem
from zope.interface import implements
-from zope.testing.cleanup import cleanUp
from Products.CMFCore.CMFCatalogAware import CMFCatalogAware
from Products.CMFCore.exceptions import NotFound
from Products.CMFCore.interfaces import IContentish
+from Products.CMFCore.testing import EventZCMLLayer
from Products.CMFCore.tests.test_PortalFolder import _AllowedUser
from Products.CMFCore.tests.test_PortalFolder import _SensitiveSecurityPolicy
from Products.CMFCore.tests.base.testcase import LogInterceptor
from Products.CMFCore.tests.base.testcase import SecurityRequestTest
-from Products.CMFCore.tests.base.testcase import setUpEvents
CMF_SECURITY_INDEXES = CMFCatalogAware._cmf_security_indexes
@@ -216,14 +215,8 @@
class CMFCatalogAware_CopySupport_Tests(SecurityRequestTest):
- def setUp(self):
- SecurityRequestTest.setUp(self)
- setUpEvents()
+ layer = EventZCMLLayer
- def tearDown(self):
- SecurityRequestTest.tearDown(self)
- cleanUp()
-
def _makeSite(self):
self.app._setObject('site', SimpleFolder('site'))
site = self.app._getOb('site')
@@ -344,4 +337,5 @@
))
if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+ from Products.CMFCore.testing import run
+ run(test_suite())
Modified: CMF/trunk/CMFCore/tests/test_CachingPolicyManager.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_CachingPolicyManager.py 2006-11-06 09:35:01 UTC (rev 71086)
+++ CMF/trunk/CMFCore/tests/test_CachingPolicyManager.py 2006-11-06 11:01:25 UTC (rev 71087)
@@ -21,21 +21,19 @@
import base64
import os
-import Products.Five
from AccessControl.SecurityManagement import newSecurityManager
from App.Common import rfc1123_date
from DateTime.DateTime import DateTime
-from Products.Five import zcml
-from zope.testing.cleanup import cleanUp
from Products.CMFCore.FSPageTemplate import FSPageTemplate
+from Products.CMFCore.testing import FunctionalZCMLLayer
+from Products.CMFCore.testing import TraversingZCMLLayer
from Products.CMFCore.tests.base.dummy import DummyContent
from Products.CMFCore.tests.base.dummy import DummySite
from Products.CMFCore.tests.base.dummy import DummyTool
from Products.CMFCore.tests.base.dummy import DummyUserFolder
from Products.CMFCore.tests.base.testcase import FSDVTest
from Products.CMFCore.tests.base.testcase import RequestTest
-from Products.CMFCore.tests.base.testcase import setUpTraversing
ACCLARK = DateTime( '2001/01/01' )
portal_owner = 'portal_owner'
@@ -57,6 +55,8 @@
class CachingPolicyTests(unittest.TestCase):
+ layer = TraversingZCMLLayer
+
def _makePolicy( self, policy_id, **kw ):
from Products.CMFCore.CachingPolicyManager import CachingPolicy
@@ -68,12 +68,8 @@
, 'foo_view', kw, self._epoch )
def setUp(self):
- setUpTraversing()
self._epoch = DateTime(0)
- def tearDown(self):
- cleanUp()
-
def test_z3interfaces(self):
from zope.interface.verify import verifyClass
from Products.CMFCore.CachingPolicyManager import CachingPolicy
@@ -394,18 +390,16 @@
class CachingPolicyManagerTests(unittest.TestCase):
+ layer = TraversingZCMLLayer
+
def _makeOne(self, *args, **kw):
from Products.CMFCore.CachingPolicyManager import CachingPolicyManager
return CachingPolicyManager(*args, **kw)
def setUp(self):
- setUpTraversing()
self._epoch = DateTime()
- def tearDown(self):
- cleanUp()
-
def assertEqualDelta( self, lhs, rhs, delta ):
self.failUnless( abs( lhs - rhs ) <= delta )
@@ -466,7 +460,7 @@
self.assertEqual(p.getLastModified(), 0)
self.assertEqual(p.getPreCheck(), 2)
self.assertEqual(p.getPostCheck(), 3)
-
+
mgr.updatePolicy('first', 'python:0', 'mtime2', 2, 1, 0, 1, 'vary2',
'etag2', None, 1, 0, 1, 0, 1, 0, 1, 3, 2)
p = mgr._policies['first']
@@ -611,14 +605,13 @@
class CachingPolicyManager304Tests(RequestTest, FSDVTest):
+ layer = FunctionalZCMLLayer
+
def setUp(self):
from Products.CMFCore import CachingPolicyManager
RequestTest.setUp(self)
FSDVTest.setUp(self)
- setUpTraversing()
- zcml.load_config('permissions.zcml', Products.Five)
- zcml.load_config('configure.zcml', Products.CMFCore)
now = DateTime()
@@ -626,7 +619,7 @@
self.portal = DummySite(id='portal').__of__(self.root)
self.portal._setObject('portal_types', DummyTool())
- # This is a FSPageTemplate that will be used as the View for
+ # This is a FSPageTemplate that will be used as the View for
# our content objects. It doesn't matter what it returns.
path = os.path.join(self.skin_path_name, 'testPT2.pt')
self.portal._setObject('dummy_view', FSPageTemplate('dummy_view', path))
@@ -640,7 +633,7 @@
newSecurityManager(None, user)
owner_auth = '%s:%s' % (portal_owner, password)
self.auth_header = "Basic %s" % base64.encodestring(owner_auth)
-
+
self.portal._setObject('doc1', DummyContent('doc1'))
self.portal._setObject('doc2', DummyContent('doc2'))
self.portal._setObject('doc3', DummyContent('doc3'))
@@ -664,7 +657,7 @@
etag_func = '',
enable_304s = 1)
- # This policy only applies to doc2. It will emit an ETag with
+ # This policy only applies to doc2. It will emit an ETag with
# the constant value "abc" and also enable if-modified-since handling.
cpm.addPolicy(policy_id = 'policy_etag',
predicate = 'python:object.getId()=="doc2"',
@@ -693,7 +686,6 @@
def tearDown(self):
RequestTest.tearDown(self)
FSDVTest.tearDown(self)
- cleanUp()
def _cleanup(self):
# Clean up request and response
@@ -735,7 +727,7 @@
# want the full rendering. This must return a 304 response.
request.environ['IF_MODIFIED_SINCE'] = rfc1123_date(doc1.modified_date)
request.environ['HTTP_AUTHORIZATION'] = self.auth_header
- doc1()
+ doc1()
self.assertEqual(response.getStatus(), 304)
self._cleanup()
@@ -747,7 +739,7 @@
self.assertEqual(response.getStatus(), 200)
self._cleanup()
- # We are asking for an ETag as well as modifications after doc2 has
+ # We are asking for an ETag as well as modifications after doc2 has
# been created. Both won't match and wwe get the full rendering.
request.environ['IF_NONE_MATCH'] = '"123"'
request.environ['IF_MODIFIED_SINCE'] = rfc1123_date(doc1.modified_date)
@@ -797,8 +789,8 @@
doc2()
self.assertEqual(response.getStatus(), 304)
self._cleanup()
-
- # We specify an ETag and a modification time condition that dooes not
+
+ # We specify an ETag and a modification time condition that dooes not
# match, so we get the full rendering
request.environ['IF_MODIFIED_SINCE'] = rfc1123_date(doc2.modified_date)
request.environ['IF_NONE_MATCH'] = '"123"'
@@ -816,7 +808,7 @@
doc2()
self.assertEqual(response.getStatus(), 200)
self._cleanup()
-
+
# Now we pass an ETag that matches the policy and a modified time
# condition that is not fulfilled. It is safe to serve a 304.
request.environ['IF_MODIFIED_SINCE'] = rfc1123_date(doc2.modified_date)
@@ -825,7 +817,7 @@
doc2()
self.assertEqual(response.getStatus(), 304)
self._cleanup()
-
+
def testConditionalGETDisabled(self):
yesterday = DateTime() - 1
doc3 = self.portal.doc3
@@ -839,7 +831,7 @@
doc3()
self.assertEqual(response.getStatus(), 200)
self._cleanup()
-
+
# Now both the ETag and the modified condition would trigger a 304
# response *if* 304-handling was enabled. It is not in our policy, so
# we get the full rendering again.
@@ -850,7 +842,7 @@
self.assertEqual(response.getStatus(), 200)
self._cleanup()
-
+
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(CachingPolicyTests),
@@ -859,4 +851,5 @@
))
if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+ from Products.CMFCore.testing import run
+ run(test_suite())
Modified: CMF/trunk/CMFCore/tests/test_FSPageTemplate.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_FSPageTemplate.py 2006-11-06 09:35:01 UTC (rev 71086)
+++ CMF/trunk/CMFCore/tests/test_FSPageTemplate.py 2006-11-06 11:01:25 UTC (rev 71087)
@@ -24,15 +24,14 @@
from OFS.Folder import Folder
from Products.StandardCacheManagers import RAMCacheManager
from zope.tales.tales import Undefined
-from zope.testing.cleanup import cleanUp
from Products.CMFCore.FSPageTemplate import FSPageTemplate
from Products.CMFCore.FSMetadata import FSMetadata
+from Products.CMFCore.testing import TraversingZCMLLayer
from Products.CMFCore.tests.base.dummy import DummyCachingManager
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.testcase import setUpTraversing
class FSPTMaker(FSDVTest):
@@ -46,15 +45,15 @@
class FSPageTemplateTests( RequestTest, FSPTMaker ):
+ layer = TraversingZCMLLayer
+
def setUp(self):
FSPTMaker.setUp(self)
RequestTest.setUp(self)
- setUpTraversing()
def tearDown(self):
RequestTest.tearDown(self)
FSPTMaker.tearDown(self)
- cleanUp()
def test_Call( self ):
script = self._makeOne( 'testPT', 'testPT.pt' )
@@ -192,4 +191,5 @@
))
if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+ from Products.CMFCore.testing import run
+ run(test_suite())
Modified: CMF/trunk/CMFCore/tests/test_OpaqueItems.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_OpaqueItems.py 2006-11-06 09:35:01 UTC (rev 71086)
+++ CMF/trunk/CMFCore/tests/test_OpaqueItems.py 2006-11-06 11:01:25 UTC (rev 71087)
@@ -14,11 +14,11 @@
$Id$
"""
+
import unittest
import Testing
from zope.interface import implements
-from zope.testing.cleanup import cleanUp
from Products.CMFCore.interfaces import ICallableOpaqueItem
from Products.CMFCore.interfaces import ICallableOpaqueItemEvents
@@ -28,10 +28,10 @@
from Products.CMFCore.interfaces.IOpaqueItems \
import ICallableOpaqueItemEvents as z2ICallableOpaqueItemEvents
from Products.CMFCore.PortalFolder import PortalFolder
+from Products.CMFCore.testing import EventZCMLLayer
from Products.CMFCore.tests.base.dummy \
import DummyContent as OriginalDummyContent
from Products.CMFCore.tests.base.testcase import SecurityTest
-from Products.CMFCore.tests.base.testcase import setUpEvents
from Products.CMFCore.TypesTool import TypesTool
@@ -90,10 +90,10 @@
self.addCounter = self.cloneCounter = self.deleteCounter = 1
self.id = id
setattr(obj, id, self)
-
+
def __call__():
return
-
+
def getId(self):
return self.id
@@ -114,7 +114,7 @@
__implements__ = (
z2ICallableOpaqueItemEvents,
)
-
+
def manage_afterAdd(self, item, container):
self.addCount = self.addCounter
self.addCounter += 1
@@ -140,9 +140,10 @@
class ManageBeforeAfterTests(SecurityTest):
+ layer = EventZCMLLayer
+
def setUp(self):
SecurityTest.setUp(self)
- setUpEvents()
root = self.root
@@ -177,10 +178,6 @@
except AttributeError:
pass
- def tearDown(self):
- SecurityTest.tearDown(self)
- cleanUp()
-
def test_nonCallableItem(self):
# no exception should be raised
folder = self.folder
@@ -287,4 +284,5 @@
))
if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+ from Products.CMFCore.testing import run
+ run(test_suite())
Modified: CMF/trunk/CMFCore/tests/test_PortalContent.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_PortalContent.py 2006-11-06 09:35:01 UTC (rev 71086)
+++ CMF/trunk/CMFCore/tests/test_PortalContent.py 2006-11-06 11:01:25 UTC (rev 71087)
@@ -21,16 +21,15 @@
from AccessControl.SecurityManagement import newSecurityManager
from Acquisition import aq_base
from OFS.Folder import Folder
-from zope.testing.cleanup import cleanUp
from Products.CMFCore.exceptions import NotFound
+from Products.CMFCore.testing import EventZCMLLayer
from Products.CMFCore.tests.base.dummy import DummyContent
from Products.CMFCore.tests.base.dummy import DummyObject
from Products.CMFCore.tests.base.dummy import DummySite
from Products.CMFCore.tests.base.dummy import DummyTool
from Products.CMFCore.tests.base.dummy import DummyUserFolder
from Products.CMFCore.tests.base.testcase import SecurityRequestTest
-from Products.CMFCore.tests.base.testcase import setUpEvents
class PortalContentTests(unittest.TestCase):
@@ -96,18 +95,15 @@
# Tests related to http://www.zope.org/Collectors/CMF/205
# Copy/pasting a content item must set ownership to pasting user
+ layer = EventZCMLLayer
+
def setUp(self):
SecurityRequestTest.setUp(self)
- setUpEvents()
self.root._setObject('site', DummySite('site'))
self.site = self.root.site
self.acl_users = self.site._setObject('acl_users', DummyUserFolder())
- def tearDown(self):
- SecurityRequestTest.tearDown(self)
- cleanUp()
-
def _initContent(self, folder, id):
from Products.CMFCore.PortalContent import PortalContent
@@ -154,4 +150,5 @@
))
if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+ from Products.CMFCore.testing import run
+ run(test_suite())
Modified: CMF/trunk/CMFCore/tests/test_PortalFolder.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_PortalFolder.py 2006-11-06 09:35:01 UTC (rev 71086)
+++ CMF/trunk/CMFCore/tests/test_PortalFolder.py 2006-11-06 11:01:25 UTC (rev 71087)
@@ -26,21 +26,20 @@
from Acquisition import Implicit
from DateTime import DateTime
from OFS.Image import manage_addFile
-from Products.Five import zcml
from zope.component import getGlobalSiteManager
from zope.component.interfaces import IFactory
-from zope.testing.cleanup import cleanUp
from Products.CMFCore.CatalogTool import CatalogTool
from Products.CMFCore.exceptions import BadRequest
from Products.CMFCore.testing import ConformsToFolder
+from Products.CMFCore.testing import EventZCMLLayer
+from Products.CMFCore.testing import FunctionalZCMLLayer
from Products.CMFCore.tests.base.dummy import DummyContent
from Products.CMFCore.tests.base.dummy import DummyFactoryDispatcher
from Products.CMFCore.tests.base.dummy import DummySite
from Products.CMFCore.tests.base.dummy import DummyUserFolder
from Products.CMFCore.tests.base.testcase import SecurityRequestTest
from Products.CMFCore.tests.base.testcase import SecurityTest
-from Products.CMFCore.tests.base.testcase import setUpEvents
from Products.CMFCore.tests.base.tidata import FTIDATA_CMF15
from Products.CMFCore.tests.base.tidata import FTIDATA_DUMMY
from Products.CMFCore.tests.base.utils import has_path
@@ -56,6 +55,7 @@
class PortalFolderFactoryTests(SecurityTest):
+ layer = EventZCMLLayer
_PORTAL_TYPE = 'Test Folder'
def _getTargetObject(self):
@@ -67,7 +67,6 @@
from Products.CMFCore.PortalFolder import PortalFolder
SecurityTest.setUp(self)
- setUpEvents()
gsm = getGlobalSiteManager()
gsm.registerUtility(self._getTargetObject(), IFactory, 'cmf.folder')
self.site = DummySite('site').__of__(self.root)
@@ -86,10 +85,6 @@
self.f = self.site._setObject('container', PortalFolder('container'))
self.f._setPortalTypeName(self._PORTAL_TYPE)
- def tearDown(self):
- SecurityTest.tearDown(self)
- cleanUp()
-
def test_invokeFactory(self):
f = self.f
self.failIf( 'foo' in f.objectIds() )
@@ -118,6 +113,8 @@
class PortalFolderTests(ConformsToFolder, SecurityTest):
+ layer = FunctionalZCMLLayer
+
def _getTargetClass(self):
from Products.CMFCore.PortalFolder import PortalFolder
@@ -128,21 +125,13 @@
self._getTargetClass()(id, *args, **kw))
def setUp(self):
- import Products
from Products.CMFCore.PortalFolder import PortalFolderFactory
SecurityTest.setUp(self)
- setUpEvents()
- zcml.load_config('permissions.zcml', Products.Five)
- zcml.load_config('content.zcml', Products.CMFCore)
gsm = getGlobalSiteManager()
gsm.registerUtility(PortalFolderFactory, IFactory, 'cmf.folder')
self.site = DummySite('site').__of__(self.root)
- def tearDown(self):
- SecurityTest.tearDown(self)
- cleanUp()
-
def test_z2interfaces(self):
from Interface.Verify import verifyClass
from OFS.IOrderSupport import IOrderedContainer
@@ -436,16 +425,13 @@
class PortalFolderMoveTests(SecurityTest):
+ layer = EventZCMLLayer
+
def setUp(self):
SecurityTest.setUp(self)
- setUpEvents()
self.root._setObject( 'site', DummySite('site') )
self.site = self.root.site
- def tearDown(self):
- SecurityTest.tearDown(self)
- cleanUp()
-
def _makeOne(self, id, *args, **kw):
from Products.CMFCore.PortalFolder import PortalFolder
@@ -863,18 +849,8 @@
class PortalFolderCopySupportTests(SecurityRequestTest):
- def setUp(self):
- import Products
+ layer = FunctionalZCMLLayer
- SecurityRequestTest.setUp(self)
- zcml.load_config('meta.zcml', Products.Five)
- zcml.load_config('permissions.zcml', Products.Five)
- zcml.load_config('content.zcml', Products.CMFCore)
-
- def tearDown(self):
- SecurityRequestTest.tearDown(self)
- cleanUp()
-
def _initFolders(self):
from Products.CMFCore.PortalFolder import PortalFolder
@@ -1257,4 +1233,5 @@
))
if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+ from Products.CMFCore.testing import run
+ run(test_suite())
Modified: CMF/trunk/CMFCore/tests/test_TypesTool.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_TypesTool.py 2006-11-06 09:35:01 UTC (rev 71086)
+++ CMF/trunk/CMFCore/tests/test_TypesTool.py 2006-11-06 11:01:25 UTC (rev 71087)
@@ -18,13 +18,11 @@
import unittest
import Testing
-import Products
from AccessControl import Unauthorized
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import noSecurityManager
from AccessControl.SecurityManager import setSecurityPolicy
from Acquisition import aq_base
-from Products.Five import zcml
from Products.PythonScripts.PythonScript import PythonScript
from Products.PythonScripts.standard import html_quote
from webdav.NullResource import NullResource
@@ -34,6 +32,7 @@
from Products.CMFCore.ActionInformation import ActionInformation
from Products.CMFCore.PortalFolder import PortalFolder
+from Products.CMFCore.testing import FunctionalZCMLLayer
from Products.CMFCore.tests.base.dummy import DummyFactory
from Products.CMFCore.tests.base.dummy import DummyFactoryDispatcher
from Products.CMFCore.tests.base.dummy import DummyFolder
@@ -43,7 +42,6 @@
from Products.CMFCore.tests.base.security import OmnipotentUser
from Products.CMFCore.tests.base.security import UserWithRoles
from Products.CMFCore.tests.base.testcase import SecurityTest
-from Products.CMFCore.tests.base.testcase import setUpTraversing
from Products.CMFCore.tests.base.testcase import WarningInterceptor
from Products.CMFCore.tests.base.tidata import FTIDATA_ACTIONS
from Products.CMFCore.tests.base.tidata import FTIDATA_CMF15
@@ -53,6 +51,8 @@
class TypesToolTests(SecurityTest, WarningInterceptor):
+ layer = FunctionalZCMLLayer
+
def _makeOne(self):
from Products.CMFCore.TypesTool import TypesTool
@@ -62,11 +62,6 @@
from Products.CMFCore.TypesTool import FactoryTypeInformation as FTI
SecurityTest.setUp(self)
- setUpTraversing()
- zcml.load_config('permissions.zcml', Products.Five)
- zcml.load_config('configure.zcml', Products.Five.browser)
- zcml.load_config('configure.zcml', Products.CMFCore)
-
self.site = DummySite('site').__of__(self.root)
self.acl_users = self.site._setObject( 'acl_users', DummyUserFolder() )
self.ttool = self.site._setObject( 'portal_types', self._makeOne() )
@@ -75,7 +70,6 @@
def tearDown(self):
SecurityTest.tearDown(self)
- cleanUp()
self._free_warning_output()
def test_z2interfaces(self):
@@ -433,7 +427,7 @@
class FTIOldstyleConstructionTests(FTIConstructionTestCase):
-
+
def setUp(self):
self.f = DummyFolder(fake_product=1)
self.ti = self._makeOne('Foo', product='FooProduct', factory='addFoo')
@@ -476,4 +470,5 @@
))
if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+ from Products.CMFCore.testing import run
+ run(test_suite())
Added: CMF/trunk/CMFDefault/testing.py
===================================================================
--- CMF/trunk/CMFDefault/testing.py 2006-11-06 09:35:01 UTC (rev 71086)
+++ CMF/trunk/CMFDefault/testing.py 2006-11-06 11:01:25 UTC (rev 71087)
@@ -0,0 +1,37 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors. All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (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.
+#
+##############################################################################
+""" Unit test layers.
+
+$Id$
+"""
+
+from Products.Five import zcml
+
+from Products.CMFCore.testing import FunctionalZCMLLayer
+
+
+class FunctionalZCMLLayer(FunctionalZCMLLayer):
+
+ @classmethod
+ def setUp(cls):
+ import Products.CMFDefault
+ import Products.CMFTopic
+ import Products.DCWorkflow
+
+ zcml.load_config('configure.zcml', Products.CMFDefault)
+ zcml.load_config('configure.zcml', Products.CMFTopic)
+ zcml.load_config('configure.zcml', Products.DCWorkflow)
+
+ @classmethod
+ def tearDown(cls):
+ pass
Property changes on: CMF/trunk/CMFDefault/testing.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: CMF/trunk/CMFDefault/tests/RegistrationTool.txt
===================================================================
--- CMF/trunk/CMFDefault/tests/RegistrationTool.txt 2006-11-06 09:35:01 UTC (rev 71086)
+++ CMF/trunk/CMFDefault/tests/RegistrationTool.txt 2006-11-06 11:01:25 UTC (rev 71087)
@@ -75,35 +75,12 @@
... def title(self): return self.Title
... def __call__(self): return self.url
- >>> from zope import interface
- >>> from zope.i18n.interfaces import INegotiator
- >>> class Negotiator:
- ... interface.implements(INegotiator)
- ... def getLanguage(*ignored): return 'test'
+ And have to set up security::
- >>> from zope.i18n.testmessagecatalog import TestMessageFallbackDomain
- >>> class DummyFallbackTranslationService:
- ... def translate(self, domain, msgid, mapping, context,
- ... target_language, default):
- ... util = TestMessageFallbackDomain(domain)
- ... return util.translate(msgid, mapping, context,
- ... target_language, default)
-
- And have to set up traversing, security and dummy translations::
-
- >>> from Products.CMFCore.tests.base.testcase import setUpTraversing
- >>> setUpTraversing()
-
>>> from AccessControl.SecurityManagement import newSecurityManager
>>> from AccessControl.User import UnrestrictedUser
>>> newSecurityManager(None, UnrestrictedUser('god', '', ['Manager'], ''))
- >>> from zope import component
- >>> component.provideUtility(Negotiator())
- >>> from Products.Five import i18n
- >>> old_fallback_translation_service = i18n._fallback_translation_service
- >>> i18n._fallback_translation_service = DummyFallbackTranslationService()
-
Now we can set up password_email and registered_email with dummy context::
>>> from Testing.makerequest import makerequest
@@ -206,8 +183,5 @@
Finally we have to clean up::
- >>> i18n._fallback_translation_service = old_fallback_translation_service
>>> from AccessControl.SecurityManagement import noSecurityManager
>>> noSecurityManager()
- >>> from zope.testing.cleanup import cleanUp
- >>> cleanUp()
Modified: CMF/trunk/CMFDefault/tests/test_DiscussionReply.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_DiscussionReply.py 2006-11-06 09:35:01 UTC (rev 71086)
+++ CMF/trunk/CMFDefault/tests/test_DiscussionReply.py 2006-11-06 11:01:25 UTC (rev 71087)
@@ -19,35 +19,24 @@
from Testing import ZopeTestCase
ZopeTestCase.installProduct('ZCTextIndex', 1)
ZopeTestCase.installProduct('CMFCore', 1)
-ZopeTestCase.installProduct('CMFDefault', 1)
-import Products
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import noSecurityManager
-from Products.Five import zcml
-from zope.testing.cleanup import cleanUp
from Products.CMFCore.tests.base.testcase import RequestTest
-from Products.CMFCore.tests.base.testcase import setUpGenericSetup
-from Products.CMFCore.tests.base.testcase import setUpTraversing
+from Products.CMFDefault.factory import addConfiguredSite
+from Products.CMFDefault.testing import FunctionalZCMLLayer
class DiscussionReplyTest(RequestTest):
- def setUp(self):
- import Products.DCWorkflow
+ layer = FunctionalZCMLLayer
+ def setUp(self):
RequestTest.setUp(self)
- setUpTraversing()
- setUpGenericSetup()
- zcml.load_config('permissions.zcml', Products.Five)
- zcml.load_config('configure.zcml', Products.Five.browser)
- zcml.load_config('configure.zcml', Products.CMFCore)
- zcml.load_config('configure.zcml', Products.CMFDefault)
- zcml.load_config('configure.zcml', Products.DCWorkflow)
try:
- factory = self.root.manage_addProduct['CMFDefault'].addConfiguredSite
- factory('cmf', 'Products.CMFDefault:default', snapshot=False)
+ addConfiguredSite(self.root, 'cmf', 'Products.CMFDefault:default',
+ snapshot=False)
self.portal = self.root.cmf
# Become a Manager
self.uf = self.portal.acl_users
@@ -67,7 +56,6 @@
def tearDown(self):
noSecurityManager()
RequestTest.tearDown(self)
- cleanUp()
def login(self, name):
user = self.uf.getUserById(name)
@@ -104,4 +92,5 @@
return suite
if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+ from Products.CMFCore.testing import run
+ run(test_suite())
Modified: CMF/trunk/CMFDefault/tests/test_Discussions.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_Discussions.py 2006-11-06 09:35:01 UTC (rev 71086)
+++ CMF/trunk/CMFDefault/tests/test_Discussions.py 2006-11-06 11:01:25 UTC (rev 71087)
@@ -18,14 +18,12 @@
import unittest
import Testing
-from zope.testing.cleanup import cleanUp
-
from Products.CMFCore.CatalogTool import CatalogTool
+from Products.CMFCore.testing import EventZCMLLayer
from Products.CMFCore.tests.base.dummy import DummyContent
from Products.CMFCore.tests.base.dummy import DummySite
from Products.CMFCore.tests.base.dummy import DummyTool
from Products.CMFCore.tests.base.testcase import SecurityTest
-from Products.CMFCore.tests.base.testcase import setUpEvents
from Products.CMFCore.tests.base.tidata import FTIDATA_DUMMY
from Products.CMFCore.tests.base.utils import has_path
from Products.CMFCore.TypesTool import FactoryTypeInformation as FTI
@@ -103,18 +101,15 @@
class DiscussionTests(SecurityTest):
+ layer = EventZCMLLayer
+
def setUp(self):
SecurityTest.setUp(self)
- setUpEvents()
self.site = DummySite('site').__of__(self.root)
self.site._setObject( 'portal_discussion', DiscussionTool() )
self.site._setObject( 'portal_membership', DummyTool() )
self.site._setObject( 'portal_types', TypesTool() )
- def tearDown(self):
- SecurityTest.tearDown(self)
- cleanUp()
-
def _makeDummyContent(self, id, *args, **kw):
return self.site._setObject( id, DummyContent(id, *args, **kw) )
@@ -351,4 +346,5 @@
))
if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+ from Products.CMFCore.testing import run
+ run(test_suite())
Modified: CMF/trunk/CMFDefault/tests/test_Image.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_Image.py 2006-11-06 09:35:01 UTC (rev 71086)
+++ CMF/trunk/CMFDefault/tests/test_Image.py 2006-11-06 11:01:25 UTC (rev 71087)
@@ -19,17 +19,13 @@
from Testing import ZopeTestCase
ZopeTestCase.installProduct('ZCTextIndex', 1)
ZopeTestCase.installProduct('CMFCore', 1)
-ZopeTestCase.installProduct('CMFDefault', 1)
from os.path import join as path_join
from cStringIO import StringIO
-import Products
import transaction
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import noSecurityManager
-from Products.Five import zcml
-from zope.testing.cleanup import cleanUp
from Products.CMFCore.testing import ConformsToContent
from Products.CMFCore.tests.base.dummy import DummyCachingManager
@@ -39,10 +35,9 @@
from Products.CMFCore.tests.base.security import OmnipotentUser
from Products.CMFCore.tests.base.testcase import RequestTest
from Products.CMFCore.tests.base.testcase import SecurityRequestTest
-from Products.CMFCore.tests.base.testcase import setUpEvents
-from Products.CMFCore.tests.base.testcase import setUpGenericSetup
-from Products.CMFCore.tests.base.testcase import setUpTraversing
from Products.CMFDefault import tests
+from Products.CMFDefault.factory import addConfiguredSite
+from Products.CMFDefault.testing import FunctionalZCMLLayer
TESTS_HOME = tests.__path__[0]
TEST_JPG = path_join(TESTS_HOME, 'TestImage.jpg')
@@ -114,21 +109,13 @@
# Tests related to http://www.zope.org/Collectors/CMF/176
# Copy/pasting an image (or file) should reset the object's workflow state.
- def setUp(self):
- import Products.DCWorkflow
+ layer = FunctionalZCMLLayer
+ def setUp(self):
SecurityRequestTest.setUp(self)
- setUpEvents()
- setUpTraversing()
- setUpGenericSetup()
- zcml.load_config('permissions.zcml', Products.Five)
- zcml.load_config('configure.zcml', Products.Five.browser)
- zcml.load_config('configure.zcml', Products.CMFCore)
- zcml.load_config('configure.zcml', Products.CMFDefault)
- zcml.load_config('configure.zcml', Products.DCWorkflow)
try:
- factory = self.root.manage_addProduct['CMFDefault'].addConfiguredSite
- factory('cmf', 'Products.CMFDefault:default', snapshot=False)
+ addConfiguredSite(self.root, 'cmf', 'Products.CMFDefault:default',
+ snapshot=False)
self.site = self.root.cmf
newSecurityManager(None, OmnipotentUser().__of__(self.site))
self.site.invokeFactory('File', id='file')
@@ -146,11 +133,10 @@
def tearDown(self):
noSecurityManager()
SecurityRequestTest.tearDown(self)
- cleanUp()
def test_File_CopyPasteResetsWorkflowState(self):
# Copy/pasting a File should reset wf state to private
- cb = self.site.manage_copyObjects(['file'])
+ cb = self.site.manage_copyObjects(['file'])
self.subfolder.manage_pasteObjects(cb)
review_state = self.workflow.getInfoFor(self.subfolder.file, 'review_state')
self.assertEqual(review_state, 'private')
@@ -163,20 +149,20 @@
def test_File_CutPasteKeepsWorkflowState(self):
# Cut/pasting a File should keep the wf state
- cb = self.site.manage_cutObjects(['file'])
+ cb = self.site.manage_cutObjects(['file'])
self.subfolder.manage_pasteObjects(cb)
review_state = self.workflow.getInfoFor(self.subfolder.file, 'review_state')
self.assertEqual(review_state, 'published')
def test_File_RenameKeepsWorkflowState(self):
# Renaming a File should keep the wf state
- self.site.manage_renameObjects(['file'], ['file2'])
+ self.site.manage_renameObjects(['file'], ['file2'])
review_state = self.workflow.getInfoFor(self.site.file2, 'review_state')
self.assertEqual(review_state, 'published')
def test_Image_CopyPasteResetsWorkflowState(self):
# Copy/pasting an Image should reset wf state to private
- cb = self.site.manage_copyObjects(['image'])
+ cb = self.site.manage_copyObjects(['image'])
self.subfolder.manage_pasteObjects(cb)
review_state = self.workflow.getInfoFor(self.subfolder.image, 'review_state')
self.assertEqual(review_state, 'private')
@@ -189,14 +175,14 @@
def test_Image_CutPasteKeepsWorkflowState(self):
# Cut/pasting an Image should keep the wf state
- cb = self.site.manage_cutObjects(['image'])
+ cb = self.site.manage_cutObjects(['image'])
self.subfolder.manage_pasteObjects(cb)
review_state = self.workflow.getInfoFor(self.subfolder.image, 'review_state')
self.assertEqual(review_state, 'published')
def test_Image_RenameKeepsWorkflowState(self):
# Renaming an Image should keep the wf state
- self.site.manage_renameObjects(['image'], ['image2'])
+ self.site.manage_renameObjects(['image'], ['image2'])
review_state = self.workflow.getInfoFor(self.site.image2, 'review_state')
self.assertEqual(review_state, 'published')
@@ -305,8 +291,9 @@
self.failUnless(len(headers) >= original_len + 3)
self.failUnless('foo' in headers.keys())
self.failUnless('bar' in headers.keys())
- self.assertEqual(headers['test_path'], '/test_image')
+ self.assertEqual(headers['test_path'], '/test_image')
+
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(TestImageElement),
@@ -315,4 +302,5 @@
))
if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+ from Products.CMFCore.testing import run
+ run(test_suite())
Modified: CMF/trunk/CMFDefault/tests/test_Portal.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_Portal.py 2006-11-06 09:35:01 UTC (rev 71086)
+++ CMF/trunk/CMFDefault/tests/test_Portal.py 2006-11-06 11:01:25 UTC (rev 71087)
@@ -19,21 +19,17 @@
from Testing import ZopeTestCase
ZopeTestCase.installProduct('ZCTextIndex', 1)
ZopeTestCase.installProduct('CMFCore', 1)
-ZopeTestCase.installProduct('CMFDefault', 1)
-import Products
from Acquisition import aq_base
-from Products.Five import zcml
-from zope.testing.cleanup import cleanUp
from Products.CMFCore.tests.base.testcase import SecurityRequestTest
-from Products.CMFCore.tests.base.testcase import setUpEvents
-from Products.CMFCore.tests.base.testcase import setUpGenericSetup
-from Products.CMFCore.tests.base.testcase import setUpTraversing
+from Products.CMFDefault.testing import FunctionalZCMLLayer
class CMFSiteTests(SecurityRequestTest):
+ layer = FunctionalZCMLLayer
+
def _makeSite( self, id='testsite' ):
from Products.CMFDefault.factory import addConfiguredSite
@@ -52,23 +48,6 @@
return content
- def setUp(self):
- import Products.DCWorkflow
-
- SecurityRequestTest.setUp(self)
- setUpEvents()
- setUpTraversing()
- setUpGenericSetup()
- zcml.load_config('permissions.zcml', Products.Five)
- zcml.load_config('configure.zcml', Products.Five.browser)
- zcml.load_config('configure.zcml', Products.CMFCore)
- zcml.load_config('configure.zcml', Products.CMFDefault)
- zcml.load_config('configure.zcml', Products.DCWorkflow)
-
- def tearDown(self):
- SecurityRequestTest.tearDown(self)
- cleanUp()
-
def test_new( self ):
site = self._makeSite()
@@ -117,11 +96,11 @@
self.assertEqual( _getMetadata( catalog, rid ), 'Bar' )
site._delObject( doc.getId() )
-
+
if isUidEnabledFavorite:
# unindex the site root by hand
catalog.unindexObject(site)
-
+
self.assertEqual( len( catalog ), 0 )
def test_DocumentEditCataloguing( self ):
@@ -223,4 +202,5 @@
))
if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+ from Products.CMFCore.testing import run
+ run(test_suite())
Modified: CMF/trunk/CMFDefault/tests/test_RegistrationTool.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_RegistrationTool.py 2006-11-06 09:35:01 UTC (rev 71086)
+++ CMF/trunk/CMFDefault/tests/test_RegistrationTool.py 2006-11-06 11:01:25 UTC (rev 71087)
@@ -17,10 +17,10 @@
import unittest
import Testing
-
from zope.testing import doctest
from Products.CMFCore.tests.base.testcase import RequestTest
+from Products.CMFDefault.testing import FunctionalZCMLLayer
class FauxMembershipTool:
@@ -81,11 +81,14 @@
def test_suite():
- return unittest.TestSuite((
- unittest.makeSuite(RegistrationToolTests),
- doctest.DocFileSuite('RegistrationTool.txt',
- optionflags=(doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE)),
- ))
+ suite = unittest.TestSuite()
+ suite.addTest(unittest.makeSuite(RegistrationToolTests))
+ s = doctest.DocFileSuite('RegistrationTool.txt',
+ optionflags=(doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE))
+ s.layer = FunctionalZCMLLayer
+ suite.addTest(s)
+ return suite
if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+ from Products.CMFCore.testing import run
+ run(test_suite())
Modified: CMF/trunk/CMFDefault/tests/test_join.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_join.py 2006-11-06 09:35:01 UTC (rev 71086)
+++ CMF/trunk/CMFDefault/tests/test_join.py 2006-11-06 11:01:25 UTC (rev 71087)
@@ -19,38 +19,20 @@
from Testing import ZopeTestCase
ZopeTestCase.installProduct('ZCTextIndex', 1)
ZopeTestCase.installProduct('CMFCore', 1)
-ZopeTestCase.installProduct('CMFDefault', 1)
-import Products
-from Products.Five import zcml
-from zope.testing.cleanup import cleanUp
-
-from Products.CMFCore.tests.base.testcase import setUpGenericSetup
from Products.CMFCore.tests.base.testcase import TransactionalTest
+from Products.CMFDefault.factory import addConfiguredSite
+from Products.CMFDefault.testing import FunctionalZCMLLayer
class MembershipTests(TransactionalTest):
- def setUp(self):
- import Products.DCWorkflow
+ layer = FunctionalZCMLLayer
- TransactionalTest.setUp(self)
- setUpGenericSetup()
- zcml.load_config('permissions.zcml', Products.Five)
- zcml.load_config('configure.zcml', Products.Five.browser)
- zcml.load_config('configure.zcml', Products.CMFCore)
- zcml.load_config('configure.zcml', Products.CMFDefault)
- zcml.load_config('configure.zcml', Products.DCWorkflow)
-
- def tearDown(self):
- TransactionalTest.tearDown(self)
- cleanUp()
-
def _makePortal(self):
# Create a portal instance suitable for testing
- factory = self.root.manage_addProduct['CMFDefault'].addConfiguredSite
- factory('site', 'Products.CMFDefault:default', snapshot=False)
-
+ addConfiguredSite(self.root, 'site', 'Products.CMFDefault:default',
+ snapshot=False)
return self.root.site
def test_join( self ):
@@ -127,4 +109,5 @@
))
if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+ from Products.CMFCore.testing import run
+ run(test_suite())
Modified: CMF/trunk/CMFTopic/tests/test_DateC.py
===================================================================
--- CMF/trunk/CMFTopic/tests/test_DateC.py 2006-11-06 09:35:01 UTC (rev 71086)
+++ CMF/trunk/CMFTopic/tests/test_DateC.py 2006-11-06 11:01:25 UTC (rev 71087)
@@ -19,16 +19,13 @@
from Testing import ZopeTestCase
ZopeTestCase.installProduct('ZCTextIndex', 1)
ZopeTestCase.installProduct('CMFCore', 1)
-ZopeTestCase.installProduct('CMFDefault', 1)
-import Products
from DateTime.DateTime import DateTime
-from Products.Five import zcml
-from zope.testing.cleanup import cleanUp
from Products.CMFCore.tests.base.testcase import RequestTest
-from Products.CMFCore.tests.base.testcase import setUpGenericSetup
from Products.CMFCore.tests.base.dummy import DummyContent
+from Products.CMFDefault.factory import addConfiguredSite
+from Products.CMFDefault.testing import FunctionalZCMLLayer
from Products.CMFTopic.Topic import Topic
from common import CriterionTestCase
@@ -129,7 +126,7 @@
self.assertEqual( result[0][1]['range'], 'min:max' )
def test_FiveDaysOld( self ):
- # This should create a query
+ # This should create a query
friendly = self._makeOne('foo', 'foofield')
friendly.apply( self.lessThanFiveDaysOld )
@@ -155,7 +152,11 @@
self.assertEqual( expect_now.Date(), DateTime().Date() )
self.assertEqual( result[0][1]['range'], 'min:max' )
+
class FriendlyDateCriterionFunctionalTests(RequestTest):
+
+ layer = FunctionalZCMLLayer
+
# Test the date criterion using a "real CMF" with catalog etc.
selectable_diffs = [0, 1, 2, 5, 7, 14, 31, 93, 186, 365, 730]
nonzero_diffs = [1, 2, 5, 7, 14, 31, 93, 186, 365, 730]
@@ -163,18 +164,10 @@
day_diffs.extend(selectable_diffs)
def setUp(self):
- import Products.DCWorkflow
-
RequestTest.setUp(self)
- setUpGenericSetup()
- zcml.load_config('permissions.zcml', Products.Five)
- zcml.load_config('configure.zcml', Products.Five.browser)
- zcml.load_config('configure.zcml', Products.CMFCore)
- zcml.load_config('configure.zcml', Products.CMFDefault)
- zcml.load_config('configure.zcml', Products.DCWorkflow)
- factory = self.root.manage_addProduct['CMFDefault'].addConfiguredSite
- factory('site', 'Products.CMFDefault:default', snapshot=False)
+ addConfiguredSite(self.root, 'site', 'Products.CMFDefault:default',
+ snapshot=False)
self.site = self.root.site
self.site._setObject( 'topic', Topic('topic') )
self.topic = self.site.topic
@@ -194,10 +187,6 @@
dummy_ob.modified_date = self.now + i
dummy_ob.reindexObject()
- def tearDown(self):
- RequestTest.tearDown(self)
- cleanUp()
-
def test_Harness(self):
# Make sure the test harness is set up OK
ob_values = self.site.objectValues(['Dummy'])
@@ -246,11 +235,11 @@
, daterange='old'
)
results = self.topic.queryCatalog()
-
- # As we move up in our date difference range, we must find as
- # many items as we have "modified" values <= the current value
- # in our sequence of user-selectable time differences. As we
- # increase the "value", we actually move backwards in time, so
+
+ # As we move up in our date difference range, we must find as
+ # many items as we have "modified" values <= the current value
+ # in our sequence of user-selectable time differences. As we
+ # increase the "value", we actually move backwards in time, so
# the expected count of results *decreases*
self.assertEquals(len(results), resultset_size)
for brain in results:
@@ -262,7 +251,7 @@
# What items are modified "More than 0 days ago"?
# This represents a special case. The "special munging"
# that corrects the query terms to what a human would expect
- # are not applied and the search is a simple
+ # are not applied and the search is a simple
# "everything in the future" search.
resultset_size = len(self.selectable_diffs)
self.criterion.edit( value=0
@@ -273,7 +262,6 @@
self.assertEquals(len(results), resultset_size)
for brain in results:
self.failUnless(brain.modified >= self.now)
-
def test_MoreThanDaysAhead(self):
# What items are modified "More than X days ahead"
@@ -285,11 +273,11 @@
, daterange='ahead'
)
results = self.topic.queryCatalog()
-
- # As we move up in our date difference range, we must find as
- # many items as we have "modified" values >= the current value
- # in our sequence of user-selectable time differences. As we
- # increase the "value", we actually move formward in time, so
+
+ # As we move up in our date difference range, we must find as
+ # many items as we have "modified" values >= the current value
+ # in our sequence of user-selectable time differences. As we
+ # increase the "value", we actually move formward in time, so
# the expected count of results *decreases*
self.assertEquals(len(results), resultset_size)
for brain in results:
@@ -301,7 +289,7 @@
# What items are modified "More than 0 days ahead"?
# This represents a special case. The "special munging"
# that corrects the query terms to what a human would expect
- # are not applied and the search is a simple
+ # are not applied and the search is a simple
# "everything in the future" search.
resultset_size = len(self.selectable_diffs)
self.criterion.edit( value=0
@@ -323,7 +311,7 @@
, daterange='old'
)
results = self.topic.queryCatalog()
-
+
# With this query we are looking for items modified "less than
# X days ago", meaning between the given time and now. As we move
# through the selectable day values we increase the range to
@@ -338,7 +326,7 @@
# What items are modified "Less than 0 days ago"?
# This represents a special case. The "special munging"
# that corrects the query terms to what a human would expect
- # are not applied and the search is a simple
+ # are not applied and the search is a simple
# "everything in the past" search.
resultset_size = len(self.selectable_diffs)
self.criterion.edit( value=0
@@ -349,7 +337,7 @@
self.assertEquals(len(results), resultset_size)
for brain in results:
self.failUnless(brain.modified <= self.now)
-
+
def test_LessThanDaysAhead(self):
# What items are modified "Less than X days ahead"
resultset_size = 2
@@ -360,7 +348,7 @@
, daterange='ahead'
)
results = self.topic.queryCatalog()
-
+
# With this query we are looking for items modified "less than
# X days ahead", meaning between now and the given time. As we move
# through the selectable day values we increase the range to
@@ -375,7 +363,7 @@
# What items are modified "Less than 0 days ahead"?
# This represents a special case. The "special munging"
# that corrects the query terms to what a human would expect
- # are not applied and the search is a simple
+ # are not applied and the search is a simple
# "everything in the past" search.
resultset_size = len(self.selectable_diffs)
self.criterion.edit( value=0
@@ -395,4 +383,5 @@
))
if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+ from Products.CMFCore.testing import run
+ run(test_suite())
Modified: CMF/trunk/CMFTopic/tests/test_Topic.py
===================================================================
--- CMF/trunk/CMFTopic/tests/test_Topic.py 2006-11-06 09:35:01 UTC (rev 71086)
+++ CMF/trunk/CMFTopic/tests/test_Topic.py 2006-11-06 11:01:25 UTC (rev 71087)
@@ -20,12 +20,11 @@
ZopeTestCase.installProduct('CMFTopic', 1)
from Acquisition import Implicit
-from zope.testing.cleanup import cleanUp
from Products.CMFCore.testing import ConformsToFolder
+from Products.CMFCore.testing import EventZCMLLayer
from Products.CMFCore.tests.base.dummy import DummySite
from Products.CMFCore.tests.base.testcase import SecurityTest
-from Products.CMFCore.tests.base.testcase import setUpEvents
from Products.CMFCore.TypesTool import FactoryTypeInformation as FTI
from Products.CMFCore.TypesTool import TypesTool
@@ -125,6 +124,8 @@
""" Test all the general Topic cases.
"""
+ layer = EventZCMLLayer
+
def _getTargetClass(self):
from Products.CMFTopic.Topic import Topic
@@ -149,13 +150,8 @@
def setUp(self):
SecurityTest.setUp(self)
- setUpEvents()
self.site = DummySite('site').__of__(self.root)
- def tearDown(self):
- SecurityTest.tearDown(self)
- cleanUp()
-
def test_z2interfaces(self):
from Interface.Verify import verifyClass
from OFS.IOrderSupport import IOrderedContainer
@@ -344,4 +340,5 @@
))
if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+ from Products.CMFCore.testing import run
+ run(test_suite())
Modified: CMF/trunk/CMFUid/tests/test_uidannotation.py
===================================================================
--- CMF/trunk/CMFUid/tests/test_uidannotation.py 2006-11-06 09:35:01 UTC (rev 71086)
+++ CMF/trunk/CMFUid/tests/test_uidannotation.py 2006-11-06 11:01:25 UTC (rev 71087)
@@ -21,19 +21,19 @@
from OFS.event import ObjectClonedEvent
from zope.app.container.contained import ObjectAddedEvent
from zope.event import notify
-from zope.testing.cleanup import cleanUp
from Products.CMFCore.PortalFolder import PortalFolder
+from Products.CMFCore.testing import EventZCMLLayer
from Products.CMFCore.tests.base.dummy import DummyContent
from Products.CMFCore.tests.base.testcase import SecurityTest
-from Products.CMFCore.tests.base.testcase import setUpEvents
-
UID_ATTRNAME = 'cmf_uid'
class UniqueIdAnnotationToolTests(SecurityTest):
+ layer = EventZCMLLayer
+
def _getTargetClass(self):
from Products.CMFUid.UniqueIdAnnotationTool \
import UniqueIdAnnotationTool
@@ -42,14 +42,9 @@
def setUp(self):
SecurityTest.setUp(self)
- setUpEvents()
self.root._setObject('portal_uidannotation', self._getTargetClass()())
self.root._setObject('dummy', DummyContent(id='dummy'))
- def tearDown(self):
- SecurityTest.tearDown(self)
- cleanUp()
-
def test_z3interfaces(self):
from zope.interface.verify import verifyClass
from Products.CMFUid.interfaces import IUniqueIdAnnotation
@@ -151,4 +146,5 @@
))
if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+ from Products.CMFCore.testing import run
+ run(test_suite())
Modified: CMF/trunk/DCWorkflow/tests/test_exportimport.py
===================================================================
--- CMF/trunk/DCWorkflow/tests/test_exportimport.py 2006-11-06 09:35:01 UTC (rev 71086)
+++ CMF/trunk/DCWorkflow/tests/test_exportimport.py 2006-11-06 11:01:25 UTC (rev 71087)
@@ -33,7 +33,6 @@
from Products.CMFCore.exportimport.tests.test_workflow import DummyWorkflow
from Products.CMFCore.exportimport.tests.test_workflow \
import DummyWorkflowTool
-from Products.CMFCore.tests.base.testcase import setUpGenericSetup
from Products.DCWorkflow.DCWorkflow import DCWorkflowDefinition
from Products.DCWorkflow.Transitions import TRIGGER_USER_ACTION
from Products.DCWorkflow.Transitions import TRIGGER_AUTOMATIC
@@ -78,8 +77,9 @@
def setUp(self):
WorkflowSetupBase.setUp(self)
- setUpGenericSetup()
zcml.load_config('permissions.zcml', Products.Five)
+ zcml.load_config('meta.zcml', Products.GenericSetup)
+ zcml.load_config('configure.zcml', Products.GenericSetup)
zcml.load_config('configure.zcml', Products.DCWorkflow)
def _initDCWorkflow( self, workflow_id ):
More information about the CMF-checkins
mailing list