Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes
ZopeVersionControl.tests.testReferenceVersioning.ReferenceVCTests Class Reference

List of all members.

Public Member Functions

def testContainerVersioning

Static Public Attributes

 setUp = common_setUp
 tearDown = common_tearDown

Detailed Description

Definition at line 28 of file testReferenceVersioning.py.


Member Function Documentation

Definition at line 33 of file testReferenceVersioning.py.

00033 
00034     def testContainerVersioning(self):
00035         # Verify that containers and items are versioned independently,
00036         # except in the case of references.
00037         from OFS.DTMLDocument import addDTMLDocument
00038 
00039         repository = self.repository
00040         folder1 = self.app.folder1
00041         folder2 = folder1.folder2
00042         folder1.testattr = 'container_v1'
00043         folder2.testattr = 'item_v1'
00044         folder1._setOb("ref", PathReference("ref", folder1.folder2))
00045         folder2._true_id = "folder2"
00046         self.assertEqual(folder1.ref._true_id, "folder2")
00047 
00048         self.assert_(not repository.isUnderVersionControl(folder1))
00049         repository.applyVersionControl(folder1)
00050         folder1 = self.app.folder1
00051         self.assert_(repository.isUnderVersionControl(folder1))
00052         self.assert_(not repository.isUnderVersionControl(folder2))
00053         self.assert_(not repository.isUnderVersionControl(folder1.ref))
00054         repository.applyVersionControl(folder2)
00055         folder2 = folder1.folder2
00056         self.assert_(repository.isUnderVersionControl(folder2))
00057         self.assert_(not repository.isUnderVersionControl(folder2.document1))
00058 
00059         # Make the first version of folder1 and check it in.
00060         repository.checkoutResource(folder1)
00061         folder1 = self.app.folder1
00062         repository.checkinResource(folder1)
00063         folder1 = self.app.folder1
00064         folder2 = folder1.folder2
00065         info = repository.getVersionInfo(folder1)
00066         first_version = info.version_id
00067 
00068         # Change folder1 and check it in again
00069         repository.checkoutResource(folder1)
00070         folder1 = self.app.folder1
00071         folder1.testattr = 'container_v2'
00072         addDTMLDocument(folder1, 'document3', file='some more text')
00073         folder1.document3._true_id = "document3"
00074         repository.checkinResource(folder1)
00075         folder1 = self.app.folder1
00076         folder2 = folder1.folder2
00077 
00078         # Change ref to point to document3.
00079         folder1._delObject("ref")
00080         folder1._setOb("ref", PathReference("ref", folder1.document3))
00081         self.assertEqual(folder1.ref._true_id, "document3")
00082 
00083         # Change folder2
00084         repository.checkoutResource(folder2)
00085         folder2 = folder1.folder2
00086         folder2.testattr = 'item_v2'
00087 
00088         # Now revert folder1 and verify that folder2 was not reverted.
00089         # Also verify that ref now points back to folder2.
00090         repository.updateResource(folder1, first_version)
00091         folder1 = self.app.folder1
00092         folder2 = folder1.folder2
00093         self.assertEqual(folder1.testattr, 'container_v1')
00094         self.assertEqual(folder2.testattr, 'item_v2')
00095         self.assertEqual(folder1.ref._true_id, "folder2")
00096 
00097         # Verify that document3 remains an item of the reverted folder1.
00098         self.assert_(hasattr(folder1, 'document3'))
00099         self.assert_(str(folder1.document3) == 'some more text')
00100 
00101         # Remove document3 and verify that it doesn't reappear upon revert.
00102         folder1._delObject('document3')
00103         repository.updateResource(folder1, '')
00104         folder1 = self.app.folder1
00105         self.assertEqual(folder1.testattr, 'container_v2')
00106         self.assertEqual(folder1.folder2.testattr, 'item_v2')
00107         self.assert_(not hasattr(folder1, 'document3'))
00108 


Member Data Documentation

Definition at line 30 of file testReferenceVersioning.py.

Definition at line 31 of file testReferenceVersioning.py.


The documentation for this class was generated from the following file: