[Zope-CVS] CVS: Products/ZopeVersionControl/tests - testVersionControl.py:1.3
Shane Hathaway
shane@zope.com
Wed, 15 Jan 2003 17:17:50 -0500
Update of /cvs-repository/Products/ZopeVersionControl/tests
In directory cvs.zope.org:/tmp/cvs-serv29711/tests
Modified Files:
testVersionControl.py
Log Message:
Containers are now versioned independently of their ObjectManagerish contents.
This means it is now possible to put versioned objects in a hierarchy.
The current implementation ignores the fact that the user may actually want
to version the item names and item history IDs. Instead, it only
versions the aspects of the container that are not items.
=== Products/ZopeVersionControl/tests/testVersionControl.py 1.2 => 1.3 ===
--- Products/ZopeVersionControl/tests/testVersionControl.py:1.2 Thu May 9 13:43:41 2002
+++ Products/ZopeVersionControl/tests/testVersionControl.py Wed Jan 15 17:17:47 2003
@@ -78,7 +78,7 @@
def testIsVersionableResource(self):
- """Test checking whether an object is a versionable resource."""
+ # Test checking whether an object is a versionable resource.
repository = self.repository
document = self.document1
self.failUnless(repository.isAVersionableResource(document))
@@ -87,7 +87,7 @@
def testIsUnderVersionControl(self):
- """Test checking whether an object is under version control."""
+ # Test checking whether an object is under version control.
repository = self.repository
document = self.document1
self.failIf(repository.isUnderVersionControl(document))
@@ -97,7 +97,7 @@
def testIsResourceUpToDate(self):
- """Test checking whether a versioned resource is up to date."""
+ # Test checking whether a versioned resource is up to date.
repository = self.repository
document = repository.applyVersionControl(self.document1)
self.commit()
@@ -121,7 +121,7 @@
def testIsResourceChanged(self):
- """Test checking whether a versioned resource has changed."""
+ # Test checking whether a versioned resource has changed.
repository = self.repository
document = repository.applyVersionControl(self.document1)
self.commit()
@@ -145,7 +145,7 @@
def testVersionBookkeeping(self):
- """Check the consistency of the version bookkeeping info."""
+ # Check the consistency of the version bookkeeping info.
repository = self.repository
document = repository.applyVersionControl(self.document1)
@@ -201,7 +201,7 @@
def testApplyVersionControl(self):
- """Test checking whether a versioned resource is up to date."""
+ # Test checking whether a versioned resource is up to date.
from Products.ZopeVersionControl.Utility import VersionControlError
repository = self.repository
@@ -226,7 +226,7 @@
def testCheckoutResource(self):
- """Test checking out a version controlled resource."""
+ # Test checking out a version controlled resource.
from Products.ZopeVersionControl.Utility import VersionControlError
repository = self.repository
@@ -272,7 +272,7 @@
def testCheckinResource(self):
- """Test checking in a version controlled resource."""
+ # Test checking in a version controlled resource.
from Products.ZopeVersionControl.Utility import VersionControlError
repository = self.repository
@@ -317,7 +317,7 @@
def testUncheckoutResource(self):
- """Test uncheckout of a version controlled resource."""
+ # Test uncheckout of a version controlled resource.
from Products.ZopeVersionControl.Utility import VersionControlError
repository = self.repository
@@ -347,7 +347,7 @@
def testUpdateResource(self):
- """Test updating a version controlled resource."""
+ # Test updating a version controlled resource.
from Products.ZopeVersionControl.Utility import VersionControlError
repository = self.repository
@@ -387,7 +387,7 @@
def testLabelResource(self):
- """Test labelling a version controlled resource."""
+ # Test labeling a version controlled resource.
from Products.ZopeVersionControl.Utility import VersionControlError
repository = self.repository
@@ -538,7 +538,7 @@
def testSelectionByDate(self):
- """Test selection of versions by date."""
+ # Test selection of versions by date.
from Products.ZopeVersionControl.Utility import VersionControlError
from DateTime.DateTime import DateTime
import time
@@ -620,7 +620,7 @@
def testSelectionByLabel(self):
- """Test labeling and selection of versions using labels."""
+ # Test labeling and selection of versions using labels.
from Products.ZopeVersionControl.Utility import VersionControlError
repository = self.repository
@@ -658,7 +658,7 @@
def testGetVersionOfResource(self):
- """Test retrieving specific versions of resources."""
+ # Test retrieving specific versions of resources.
from Products.ZopeVersionControl.Utility import VersionControlError
repository = self.repository
@@ -698,7 +698,7 @@
def testDetectPersistentSubObjectChange(self):
- """Test detection of changes to persistent sub-objects."""
+ # Test detection of changes to persistent sub-objects.
repository = self.repository
folder2 = self.folder2
document = self.document1
@@ -714,6 +714,68 @@
self.failUnless(repository.isResourceChanged(folder2))
+ def testContainerVersioning(self):
+ # Verify that containers and items are versioned independently.
+ repository = self.repository
+ folder1 = self.app.folder1
+ folder2 = folder1.folder2
+ folder1.testattr = 'container_v1'
+ folder2.testattr = 'item_v1'
+
+ self.assert_(not repository.isUnderVersionControl(folder1))
+ repository.applyVersionControl(folder1)
+ folder1 = self.app.folder1
+ self.assert_(repository.isUnderVersionControl(folder1))
+ self.assert_(not repository.isUnderVersionControl(folder2))
+ repository.applyVersionControl(folder2)
+ folder2 = folder1.folder2
+ self.assert_(repository.isUnderVersionControl(folder2))
+ self.assert_(not repository.isUnderVersionControl(folder2.document1))
+
+ # Make the first version of folder1 and check it in.
+ repository.checkoutResource(folder1)
+ folder1 = self.app.folder1
+ repository.checkinResource(folder1)
+ folder1 = self.app.folder1
+ folder2 = folder1.folder2
+ info = repository.getVersionInfo(folder1)
+ first_version = info.version_id
+
+ # Change folder1 and check it in again
+ repository.checkoutResource(folder1)
+ folder1 = self.app.folder1
+ folder1.testattr = 'container_v2'
+ addDTMLDocument(folder1, 'document3', file='some more text')
+ repository.checkinResource(folder1)
+ folder1 = self.app.folder1
+ folder2 = folder1.folder2
+
+ # Change folder2
+ repository.checkoutResource(folder2)
+ folder2 = folder1.folder2
+ folder2.testattr = 'item_v2'
+
+ # Now revert folder1 and verify that folder2 was not reverted.
+ repository.updateResource(folder1, first_version)
+ folder1 = self.app.folder1
+ folder2 = folder1.folder2
+ self.assertEqual(folder1.testattr, 'container_v1')
+ self.assertEqual(folder2.testattr, 'item_v2')
+
+ # Verify that document3 remains an item of the reverted folder1.
+ self.assert_(hasattr(folder1, 'document3'))
+ self.assert_(str(folder1.document3) == 'some more text')
+
+ # Remove document3 and verify that it doesn't reappear upon revert.
+ folder1._delObject('document3')
+ repository.updateResource(folder1, '')
+ folder1 = self.app.folder1
+ self.assertEqual(folder1.testattr, 'container_v2')
+ self.assertEqual(folder1.folder2.testattr, 'item_v2')
+ self.assert_(not hasattr(folder1, 'document3'))
+
+
+
class VersionControlTestsWithCommits(VersionControlTests):
"""Version control test suite with transaction commits that mimic
the transaction commits that you would get with Web based usage."""
@@ -727,7 +789,7 @@
return suite
def main():
- unittest.TextTestRunner().run(test_suite())
+ unittest.main(defaultTest='test_suite')
if __name__ == '__main__':
main()