Back to index

plone3  3.1.7
Public Member Functions | Private Member Functions
CMFEditions.tests.test_KeepLastNVersionsTool.TestKeepLastNVersionsTool Class Reference

List of all members.

Public Member Functions

def afterSetUp
def test00_interface
def test01_beforeSaveHookInfinite
def test02_beforeSaveHookKeepsMaximumTwoVersions
def test03_retrieveOlderSubstitute

Private Member Functions

def _setDummyTool

Detailed Description

Definition at line 36 of file test_KeepLastNVersionsTool.py.


Member Function Documentation

Definition at line 49 of file test_KeepLastNVersionsTool.py.

00049 
00050     def _setDummyTool(self, tool):
00051         setattr(self.portal, tool.getId(), tool)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 38 of file test_KeepLastNVersionsTool.py.

00038 
00039     def afterSetUp(self):
00040         # we need to have the Manager role to be able to add things
00041         # to the portal root
00042         self.setRoles(['Manager',])
00043         # add an additional user
00044         self.portal.acl_users.userFolderAddUser('reviewer', 'reviewer',
00045                                                 ['Manager'], '')
00046         
00047         # install test storage 
00048         self._setDummyTool(PurgePolicyTestDummyStorage())
        

Here is the call graph for this function:

Definition at line 52 of file test_KeepLastNVersionsTool.py.

00052 
00053     def test00_interface(self):
00054         portal_purgepolicy = self.portal.portal_purgepolicy
00055 
00056         # test interface conformance
00057         verifyObject(IPurgePolicy, portal_purgepolicy)

Definition at line 58 of file test_KeepLastNVersionsTool.py.

00058 
00059     def test01_beforeSaveHookInfinite(self):
00060         purgepolicy = self.portal.portal_purgepolicy
00061         storage = self.portal.portal_historiesstorage
00062         
00063         storage.save(history_id=1, obj=DummyData(0))
00064         res = purgepolicy.beforeSaveHook(history_id=1, obj=2, metadata={})
00065         self.failUnless(res)
00066         self.assertEqual(len(storage.getHistory(history_id=1)), 1)

Definition at line 67 of file test_KeepLastNVersionsTool.py.

00067 
00068     def test02_beforeSaveHookKeepsMaximumTwoVersions(self):
00069         purgepolicy = self.portal.portal_purgepolicy
00070         storage = self.portal.portal_historiesstorage
00071         purgepolicy.maxNumberOfVersionsToKeep = 2
00072         
00073         # call hook explicitely before save (dummy tool doesn't call it, 
00074         # we wan't to do it explicitely)
00075         res = purgepolicy.beforeSaveHook(history_id=1, obj=2, metadata={})
00076         self.failUnless(res)
00077         storage.save(history_id=1, obj=DummyData(0))
00078         self.assertEqual(len(storage.getHistory(history_id=1)), 1)
00079         
00080         # call hook explicitely before save (dummy tool doesn't call it, 
00081         # we wan't to do it explicitely)
00082         res = purgepolicy.beforeSaveHook(history_id=1, obj=2, metadata={})
00083         self.failUnless(res)
00084         storage.save(history_id=1, obj=DummyData(1))
00085         self.assertEqual(len(storage.getHistory(history_id=1)), 2)
00086         
00087         # check the first saved version was purged
00088         res = purgepolicy.beforeSaveHook(history_id=1, obj=2, metadata={})
00089         self.failUnless(res)
00090         storage.save(history_id=1, obj=DummyData(2))
00091         history = storage.getHistory(history_id=1)
00092         self.assertEqual(len(history), 2)
00093         self.assertEqual(history[0].data, 1)
00094         self.assertEqual(history[1].data, 2)

Definition at line 95 of file test_KeepLastNVersionsTool.py.

00095 
00096     def test03_retrieveOlderSubstitute(self):
00097         purgepolicy = self.portal.portal_purgepolicy
00098         storage = self.portal.portal_historiesstorage
00099         
00100         # build history
00101         storage.save(history_id=1, obj=RemovedData())
00102         storage.save(history_id=1, obj=DummyData(1))
00103         storage.save(history_id=1, obj=RemovedData())
00104         storage.save(history_id=1, obj=RemovedData())
00105         storage.save(history_id=1, obj=DummyData(4))
00106         
00107         # next newer
00108         data = purgepolicy.retrieveSubstitute(history_id=1, selector=0)
00109         self.assertEquals(data.data, 1)
00110         # next older
00111         data = purgepolicy.retrieveSubstitute(history_id=1, selector=2)
00112         self.assertEquals(data.data, 1)
00113         # next older
00114         data = purgepolicy.retrieveSubstitute(history_id=1, selector=3)
00115         self.assertEquals(data.data, 1)
00116 


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