[CMF-checkins] CVS: CMF/CMFStaging/tests - test_all.py:1.1 testVersions.py:1.5

Shane Hathaway shane at zope.com
Mon Mar 29 15:14:21 EST 2004


Update of /cvs-repository/CMF/CMFStaging/tests
In directory cvs.zope.org:/tmp/cvs-serv13494/tests

Modified Files:
	testVersions.py 
Added Files:
	test_all.py 
Log Message:
Separated the auto-copy-forward tests.

One test tries a sticky tag.  The other tries an old but non-sticky tag.


=== Added File CMF/CMFStaging/tests/test_all.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
#
##############################################################################
"""Tests for CMFStaging.

$Id: test_all.py,v 1.1 2004/03/29 20:14:20 shane Exp $
"""

import unittest

from Products.CMFStaging.tests.testLockTool import test_suite as lock_tests
from Products.CMFStaging.tests.testVersions import test_suite as version_tests
from Products.CMFStaging.tests.testStaging import test_suite as staging_tests

def test_suite():
    suite = unittest.TestSuite()
    suite.addTest(lock_tests())
    suite.addTest(version_tests())
    suite.addTest(staging_tests())
    return suite
    
if __name__ == '__main__':
    unittest.main(defaultTest='test_suite')


=== CMF/CMFStaging/tests/testVersions.py 1.4 => 1.5 ===
--- CMF/CMFStaging/tests/testVersions.py:1.4	Mon Oct 27 15:21:54 2003
+++ CMF/CMFStaging/tests/testVersions.py	Mon Mar 29 15:14:20 2004
@@ -100,7 +100,8 @@
         self.assertEqual(old_id, current_id)
 
 
-    def testRevertThenCheckout(self):
+    def testRevertToStickyThenCheckout(self):
+        # Test that the versions tool automatically unsticks objects
         vt = self.tool
         content = self.root.content
         vt.checkin(content)
@@ -112,9 +113,6 @@
         content = self.root.content  # XXX ZopeVersionControl requires this
 
         vt.auto_copy_forward = 0
-        # Can't normally check out when the object is in an old state
-        self.assertRaises(VersionControlError, vt.checkout, content)
-
         # Can't check out when the object is in the current state
         # but there's a sticky tag.
         vt.revertToVersion(content, new_id)
@@ -124,6 +122,34 @@
         vt.revertToVersion(content, old_id)
         # Now we can check out, since the tool will remove the sticky tag
         # without losing data.
+        vt.checkout(content)
+        content = self.root.content  # XXX ZopeVersionControl requires this
+
+        current_id = vt.getVersionId(content)
+        self.assertNotEqual(current_id, old_id)
+        self.assertNotEqual(current_id, new_id)
+
+
+    def testRevertToOldThenCheckout(self):
+        # Test that the versions tool automatically copies old states forward
+        vt = self.tool
+        content = self.root.content
+        vt.checkin(content)
+        old_id = vt.getVersionId(content)
+        vt.checkout(content)
+        vt.checkin(content)
+        new_id = vt.getVersionId(content)
+        vt.revertToVersion(content, old_id)
+        content = self.root.content  # XXX ZopeVersionControl requires this
+        del content.__vc_info__.sticky  # Simulate non-sticky
+
+        vt.auto_copy_forward = 0
+        # Can't normally check out when the object is in an old state
+        self.assertRaises(VersionControlError, vt.checkout, content)
+
+        vt.auto_copy_forward = 1
+        # Now we can check out, since the tool will copy the old state forward
+        # before checking out.
         vt.checkout(content)
         content = self.root.content  # XXX ZopeVersionControl requires this
 




More information about the CMF-checkins mailing list