[CMF-checkins] CVS: CMF/CMFStaging/tests -
testReferenceStaging.py:1.1 testLockTool.py:1.4
testStaging.py:1.10 testVersions.py:1.4
Shane Hathaway
cvs-admin at zope.org
Mon Oct 27 15:22:25 EST 2003
Update of /cvs-repository/CMF/CMFStaging/tests
In directory cvs.zope.org:/tmp/cvs-serv11975/tests
Modified Files:
testLockTool.py testStaging.py testVersions.py
Added Files:
testReferenceStaging.py
Log Message:
Added support for staging references. See CHANGES.txt for details.
=== Added File CMF/CMFStaging/tests/testReferenceStaging.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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 tests for staging reference objects.
$Id: testReferenceStaging.py,v 1.1 2003/10/27 20:21:54 shane Exp $
"""
import unittest
import Testing
import Zope
Zope.startup()
from Products.References.PathReference import PathReference
from Products.CMFStaging.tests.testStaging import StagingTests
class ReferenceStagingTests(StagingTests):
def _addContent(self):
# Unlike the standard StagingTests, adds references instead of
# standard folders.
self.dev_stage.manage_addProduct['OFSP'].manage_addFolder('real_c1')
self.dev_stage.manage_addProduct['OFSP'].manage_addFolder('real_c2')
# XXX this uses PathReference internals to create a relative
# rather than absolute path
c1 = PathReference("c1", self.dev_stage.real_c1)
c1.path = ("real_c1",)
self.dev_stage._setObject(c1.id, c1)
c2 = PathReference("c2", self.dev_stage.real_c2)
c2.path = ("real_c2",)
self.dev_stage._setObject(c2.id, c2)
repo = self.root.VersionRepository
repo.applyVersionControl(self.dev_stage.real_c1)
repo.applyVersionControl(self.dev_stage.real_c2)
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(ReferenceStagingTests),
))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
=== CMF/CMFStaging/tests/testLockTool.py 1.3 => 1.4 ===
--- CMF/CMFStaging/tests/testLockTool.py:1.3 Thu May 22 11:24:03 2003
+++ CMF/CMFStaging/tests/testLockTool.py Mon Oct 27 15:21:54 2003
@@ -22,8 +22,8 @@
import Zope
Zope.startup()
from OFS.Folder import Folder
-from AccessControl.SecurityManagement import newSecurityManager, \
- noSecurityManager
+from AccessControl.SecurityManagement \
+ import newSecurityManager, noSecurityManager
from AccessControl.User import SimpleUser
from Products.CMFStaging.LockTool import LockTool, LockingError
=== CMF/CMFStaging/tests/testStaging.py 1.9 => 1.10 ===
--- CMF/CMFStaging/tests/testStaging.py:1.9 Thu May 22 11:24:03 2003
+++ CMF/CMFStaging/tests/testStaging.py Mon Oct 27 15:21:54 2003
@@ -26,9 +26,11 @@
noSecurityManager
from Products.CMFStaging.StagingTool import StagingTool, StagingError
+from Products.CMFStaging.tests.testLockTool import TestUser
from Products.ZopeVersionControl.Utility import VersionControlError
-class Tests(unittest.TestCase):
+
+class StagingTests(unittest.TestCase):
def setUp(self):
# Set up an application with a repository, 3 stages, the tools,
@@ -50,28 +52,43 @@
self.stages.manage_addProduct['OFSP'].manage_addFolder('Production')
self.root.manage_addProduct['CMFStaging'].manage_addTool(
StagingTool.meta_type)
+ self.root.portal_staging._stages = (
+ ('dev', 'Development', 'Stages/Development'),
+ ('review', 'Review', 'Stages/Review'),
+ ('prod', 'Production', 'Stages/Production'),
+ )
+
dev_stage = self.stages.Development
- dev_stage.manage_addProduct['OFSP'].manage_addFolder('c1')
- dev_stage.manage_addProduct['OFSP'].manage_addFolder('c2')
dev_stage.manage_addProduct['OFSP'].manage_addFolder('nonv')
self.dev_stage = dev_stage
self.review_stage = self.stages.Review
self.prod_stage = self.stages.Production
+ self._addContent()
+
+ user = TestUser('sally')
+ newSecurityManager(None, user.__of__(self.root.acl_users))
+
+ def _addContent(self):
+ # This method is overridden by the reference staging tests.
+ self.dev_stage.manage_addProduct['OFSP'].manage_addFolder('c1')
+ self.dev_stage.manage_addProduct['OFSP'].manage_addFolder('c2')
repo = self.root.VersionRepository
- repo.applyVersionControl(dev_stage.c1)
- repo.applyVersionControl(dev_stage.c2)
+ repo.applyVersionControl(self.dev_stage.c1)
+ repo.applyVersionControl(self.dev_stage.c2)
def tearDown(self):
- app = self.app
- if hasattr(app, 'testroot'):
- app._delObject('testroot')
- get_transaction().commit()
- else:
- get_transaction().abort()
- self.conn.close()
noSecurityManager()
+ app = self.app
+ try:
+ if hasattr(app, 'testroot'):
+ app._delObject('testroot')
+ get_transaction().commit()
+ else:
+ get_transaction().abort()
+ finally:
+ self.conn.close()
def testStageable(self):
@@ -94,7 +111,7 @@
st = self.root.portal_staging
self.assert_('c1' not in self.review_stage.objectIds())
- st.updateStages(self.dev_stage.c1, 'dev', ['review'])
+ st.updateStages2(self.dev_stage.c1, ['review'])
versions = st.getVersionIds(self.dev_stage.c1)
self.assert_(versions['dev'])
self.assert_(versions['review'])
@@ -102,13 +119,13 @@
self.assert_('c1' in self.review_stage.objectIds())
self.assert_('c1' not in self.prod_stage.objectIds())
- st.updateStages(self.dev_stage.c2, 'dev', ['review', 'prod'])
+ st.updateStages2(self.dev_stage.c2, ['review', 'prod'])
versions = st.getVersionIds(self.dev_stage.c2)
self.assert_(versions['dev'])
self.assert_(versions['review'])
self.assert_(versions['prod'])
- st.updateStages(self.dev_stage.c1, 'dev', ['prod'])
+ st.updateStages2(self.dev_stage.c1, ['prod'])
versions = st.getVersionIds(self.dev_stage.c1)
self.assert_(versions['dev'])
self.assert_(versions['review'])
@@ -119,27 +136,27 @@
def testUpdateStagesExceptions(self):
st = self.root.portal_staging
# "nonv" is not under version control.
- self.assertRaises(VersionControlError, st.updateStages,
- self.dev_stage.nonv, 'dev', ['review'])
+ self.assertRaises(VersionControlError, st.updateStages2,
+ self.dev_stage.nonv, ['review'])
# Put something in the way and make sure it doesn't get overwritten.
self.review_stage.manage_addProduct['OFSP'].manage_addFolder('c1')
- self.assertRaises(StagingError, st.updateStages, self.dev_stage.c1,
- 'dev', ['review'])
+ self.assertRaises(
+ StagingError, st.updateStages2, self.dev_stage.c1, ['review'])
# Put the blocker under version control and verify it still doesn't
# get overwritten, since it is backed by a different version history.
repo = self.root.VersionRepository
repo.applyVersionControl(self.review_stage.c1)
- self.assertRaises(StagingError, st.updateStages, self.dev_stage.c1,
- 'dev', ['review'])
+ self.assertRaises(
+ StagingError, st.updateStages2, self.dev_stage.c1, ['review'])
# Move the blocker out of the way and verify updates can occur again.
self.review_stage._delObject('c1')
- st.updateStages(self.dev_stage.c1, 'dev', ['review'])
-
+ st.updateStages2(self.dev_stage.c1, ['review'])
+
def testRemoveStages(self):
st = self.root.portal_staging
self.assert_('c1' not in self.review_stage.objectIds())
- st.updateStages(self.dev_stage.c1, 'dev', ['review'])
+ st.updateStages2(self.dev_stage.c1, ['review'])
self.assert_('c1' in self.review_stage.objectIds())
st.removeStages(self.dev_stage.c1, ['review'])
self.assert_('c1' not in self.review_stage.objectIds())
@@ -183,8 +200,6 @@
self.assert_(lt.auto_version)
self.assert_(st.auto_checkin)
- from Products.CMFStaging.tests.testLockTool import TestUser
-
user = TestUser('andre')
newSecurityManager(None, user.__of__(self.root.acl_users))
@@ -192,7 +207,7 @@
# Lock with auto checkout
lt.lock(self.dev_stage.c1)
# Update with auto unlock and checkin
- st.updateStages(self.dev_stage.c1, 'dev', ['review'])
+ st.updateStages2(self.dev_stage.c1, ['review'])
versions = st.getVersionIds(self.dev_stage.c1)
self.assertEqual(versions['dev'], versions['review'])
self.assert_(not versions['prod'])
@@ -208,7 +223,7 @@
# Publish c1.
# Unlocked and checked in already
- st.updateStages(self.dev_stage.c1, 'dev', ['review', 'prod'])
+ st.updateStages2(self.dev_stage.c1, ['review', 'prod'])
versions = st.getVersionIds(self.dev_stage.c1)
self.assertEqual(versions['dev'], wanted_published)
self.assertEqual(versions['dev'], versions['review'])
@@ -218,7 +233,7 @@
def test_suite():
return unittest.TestSuite((
- unittest.makeSuite(Tests),
+ unittest.makeSuite(StagingTests),
))
if __name__ == '__main__':
=== CMF/CMFStaging/tests/testVersions.py 1.3 => 1.4 ===
--- CMF/CMFStaging/tests/testVersions.py:1.3 Thu Jan 2 16:56:42 2003
+++ CMF/CMFStaging/tests/testVersions.py Mon Oct 27 15:21:54 2003
@@ -17,15 +17,19 @@
"""
import unittest
+
import Testing
-from Acquisition import aq_base
import Zope
Zope.startup()
+
+from Acquisition import aq_base
from OFS.Folder import Folder
from AccessControl.User import SimpleUser
-
-from Products.CMFStaging.VersionsTool import VersionsTool
+from AccessControl.SecurityManagement \
+ import newSecurityManager, noSecurityManager
from Products.ZopeVersionControl.Utility import VersionControlError
+from Products.CMFStaging.VersionsTool import VersionsTool
+from Products.CMFStaging.tests.testLockTool import TestUser
class Tests(unittest.TestCase):
@@ -45,12 +49,16 @@
self.root.content = Folder()
self.root.content.id = 'content'
+ user = TestUser('sally')
+ newSecurityManager(None, user.__of__(self.root.acl_users))
+
def tearDown(self):
app = self.app
if hasattr(app, 'testroot'):
app._delObject('testroot')
self.app._p_jar.close()
+ noSecurityManager()
def testCheckinCheckout(self):
@@ -131,7 +139,7 @@
self.assertEqual(tuple(log), ())
vt.checkin(content)
- content = vt.checkout(content)
+ vt.checkout(content)
vt.checkin(content)
log = vt.getLogEntries(content, only_checkins=1)
More information about the CMF-checkins
mailing list