[CMF-checkins] SVN: CMF/branches/1.6/CMFDefault/tests/test_ *
changing tests to use GenericSetup portal creation mechanism
Rob Miller
ra at burningman.com
Sat Nov 19 18:23:50 EST 2005
Log message for revision 40264:
* changing tests to use GenericSetup portal creation mechanism
(contributed by Brent Hendricks)
Changed:
U CMF/branches/1.6/CMFDefault/tests/test_DiscussionReply.py
U CMF/branches/1.6/CMFDefault/tests/test_Image.py
U CMF/branches/1.6/CMFDefault/tests/test_Portal.py
U CMF/branches/1.6/CMFDefault/tests/test_join.py
-=-
Modified: CMF/branches/1.6/CMFDefault/tests/test_DiscussionReply.py
===================================================================
--- CMF/branches/1.6/CMFDefault/tests/test_DiscussionReply.py 2005-11-19 21:15:56 UTC (rev 40263)
+++ CMF/branches/1.6/CMFDefault/tests/test_DiscussionReply.py 2005-11-19 23:23:49 UTC (rev 40264)
@@ -11,18 +11,26 @@
import Zope as Zope2
Zope2.startup()
+import Products
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import noSecurityManager
+from Products.Five import zcml
+from Products.CMFCore.tests.base.testcase import PlacelessSetup
from Products.CMFCore.tests.base.testcase import RequestTest
-class DiscussionReplyTest(RequestTest):
+class DiscussionReplyTest(PlacelessSetup, RequestTest):
def setUp(self):
+ PlacelessSetup.setUp(self)
RequestTest.setUp(self)
+ zcml.load_config('meta.zcml', Products.Five)
+ zcml.load_config('configure.zcml', Products.GenericSetup)
+ zcml.load_config('configure.zcml', Products.CMFCore)
try:
- self.root.manage_addProduct['CMFDefault'].manage_addCMFSite('cmf')
+ factory = self.root.manage_addProduct['CMFDefault'].addConfiguredSite
+ factory('cmf', 'CMFDefault:default', snapshot=False)
self.portal = self.root.cmf
# Become a Manager
self.uf = self.portal.acl_users
@@ -42,7 +50,8 @@
def tearDown(self):
noSecurityManager()
RequestTest.tearDown(self)
-
+ PlacelessSetup.tearDown(self)
+
def login(self, name):
user = self.uf.getUserById(name)
user = user.__of__(self.uf)
Modified: CMF/branches/1.6/CMFDefault/tests/test_Image.py
===================================================================
--- CMF/branches/1.6/CMFDefault/tests/test_Image.py 2005-11-19 21:15:56 UTC (rev 40263)
+++ CMF/branches/1.6/CMFDefault/tests/test_Image.py 2005-11-19 23:23:49 UTC (rev 40264)
@@ -30,6 +30,8 @@
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import noSecurityManager
from AccessControl.User import UnrestrictedUser
+from Products.Five import zcml
+import Products
try:
import transaction
except ImportError:
@@ -38,6 +40,7 @@
from Products.CMFCore.tests.base.dummy import DummySite
from Products.CMFCore.tests.base.dummy import DummyTool
+from Products.CMFCore.tests.base.testcase import PlacelessSetup
from Products.CMFCore.tests.base.testcase import RequestTest
from Products.CMFDefault import tests
from Products.CMFDefault.File import File
@@ -131,16 +134,21 @@
self.assertEqual(file.content_type, 'image/jpeg')
-class TestImageCopyPaste(RequestTest):
+class TestImageCopyPaste(PlacelessSetup, RequestTest):
# 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):
+ PlacelessSetup.setUp(self)
RequestTest.setUp(self)
+ zcml.load_config('meta.zcml', Products.Five)
+ zcml.load_config('configure.zcml', Products.GenericSetup)
+ zcml.load_config('configure.zcml', Products.CMFCore)
try:
newSecurityManager(None, UnrestrictedUser('manager', '', ['Manager'], []))
- self.root.manage_addProduct['CMFDefault'].manage_addCMFSite('cmf')
+ factory = self.root.manage_addProduct['CMFDefault'].addConfiguredSite
+ factory('cmf', 'CMFDefault:default', snapshot=False)
self.site = self.root.cmf
self.site.invokeFactory('File', id='file')
self.site.portal_workflow.doActionFor(self.site.file, 'publish')
@@ -157,6 +165,7 @@
def tearDown(self):
noSecurityManager()
RequestTest.tearDown(self)
+ PlacelessSetup.tearDown(self)
def test_File_CopyPasteResetsWorkflowState(self):
# Copy/pasting a File should reset wf state to private
Modified: CMF/branches/1.6/CMFDefault/tests/test_Portal.py
===================================================================
--- CMF/branches/1.6/CMFDefault/tests/test_Portal.py 2005-11-19 21:15:56 UTC (rev 40263)
+++ CMF/branches/1.6/CMFDefault/tests/test_Portal.py 2005-11-19 23:23:49 UTC (rev 40264)
@@ -23,28 +23,35 @@
import Zope as Zope2
Zope2.startup()
+import Products
from Acquisition import aq_base
+from Products.Five import zcml
+from Products.CMFCore.tests.base.testcase import PlacelessSetup
from Products.CMFCore.tests.base.testcase import SecurityRequestTest
from Products.CMFCore.tests.base.testcase import WarningInterceptor
-class CMFSiteTests( SecurityRequestTest
- , WarningInterceptor
- ):
+class CMFSiteTests( PlacelessSetup, SecurityRequestTest, WarningInterceptor):
def setUp( self ):
+ PlacelessSetup.setUp(self)
SecurityRequestTest.setUp( self )
self._trap_warning_output()
+ zcml.load_config('meta.zcml', Products.Five)
+ zcml.load_config('configure.zcml', Products.GenericSetup)
+ zcml.load_config('configure.zcml', Products.CMFCore)
def tearDown( self ):
self._free_warning_output()
SecurityRequestTest.tearDown( self )
+ PlacelessSetup.tearDown(self)
def _makeSite( self, id='testsite'):
- from Products.CMFDefault.Portal import manage_addCMFSite
- manage_addCMFSite( self.root, id )
+ from Products.CMFDefault.factory import addConfiguredSite
+
+ addConfiguredSite(self.root, id, 'CMFDefault:default', snapshot=False)
return getattr( self.root, id )
def _makeContent( self, site, portal_type, id='document', **kw ):
Modified: CMF/branches/1.6/CMFDefault/tests/test_join.py
===================================================================
--- CMF/branches/1.6/CMFDefault/tests/test_join.py 2005-11-19 21:15:56 UTC (rev 40263)
+++ CMF/branches/1.6/CMFDefault/tests/test_join.py 2005-11-19 23:23:49 UTC (rev 40264)
@@ -11,9 +11,15 @@
class MembershipTests( TransactionalTest ):
+ def _makePortal(self):
+ # Create a portal instance suitable for testing
+ factory = self.root.manage_addProduct['CMFDefault'].addConfiguredSite
+ factory('site', 'CMFDefault:default', snapshot=False)
+
+ return self.root.site
+
def test_join( self ):
- self.root.manage_addProduct[ 'CMFDefault' ].manage_addCMFSite( 'site' )
- site = self.root.site
+ site = self._makePortal()
member_id = 'test_user'
site.portal_registration.addMember( member_id
, 'zzyyzz'
@@ -25,8 +31,7 @@
self.failUnless(u)
def test_join_without_email( self ):
- self.root.manage_addProduct[ 'CMFDefault' ].manage_addCMFSite( 'site' )
- site = self.root.site
+ site = self._makePortal()
self.assertRaises(ValueError,
site.portal_registration.addMember,
'test_user',
@@ -35,8 +40,7 @@
)
def test_join_with_variable_id_policies( self ):
- self.root.manage_addProduct[ 'CMFDefault' ].manage_addCMFSite( 'site' )
- site = self.root.site
+ site = self._makePortal()
member_id = 'test.user'
# Test with the default policy: Names with "." should fail
More information about the CMF-checkins
mailing list