Back to index

plone3  3.1.7
Public Member Functions
CMFEditions.tests.test_ArchivistTool.TestArchivistToolZStorage Class Reference
Inheritance diagram for CMFEditions.tests.test_ArchivistTool.TestArchivistToolZStorage:
Inheritance graph
[legend]
Collaboration diagram for CMFEditions.tests.test_ArchivistTool.TestArchivistToolZStorage:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def installStorageTool
def afterSetUp
def test00_interface
def test01_registerAttachesAHistoryId
def test02_retrieve
def test03_retrieveById
def test04_getHistory
def test05_iterateOverHistory
def test06_getHistoryById
def test07_prepareObjectWithReferences
def test08_retrieveWithReferences
def test09_isUpToDate

Detailed Description

Definition at line 344 of file test_ArchivistTool.py.


Member Function Documentation

Definition at line 44 of file test_ArchivistTool.py.

00044 
00045     def afterSetUp(self):
00046         self.setRoles(['Manager',])
00047         self.portal.acl_users.userFolderAddUser('reviewer', 'reviewer',
00048                                                 ['Manager'], '')
00049         self.portal.invokeFactory('Document', 'doc')
00050         self.portal.invokeFactory('Folder', 'fol')
00051         self.portal.fol.invokeFactory('Document', 'doc1_inside')
00052         self.portal.fol.invokeFactory('Document', 'doc2_inside')
00053         self.portal.fol.invokeFactory('Document', 'doc3_outside')
00054         tools = (
00055             DummyModifier(),
00056             DummyHistoryIdHandler(),
00057             )
00058         for tool in tools:
00059             self._setDummyTool(tool)
00060 
00061         self.installStorageTool()
00062 
00063         # delete purge policy if there is one installed
00064         try:
00065             del self.portal.portal_purgepolicy
00066         except AttributeError:
00067             pass

Here is the call graph for this function:

Test with a real ZODB storage overriding the storage installation
   in the super class.

Reimplemented from CMFEditions.tests.test_ArchivistTool.TestArchivistToolMemoryStorage.

Definition at line 346 of file test_ArchivistTool.py.

00346 
00347    def installStorageTool(self):
00348        """Test with a real ZODB storage overriding the storage installation
00349           in the super class.
00350        """
00351        pass
00352 

Here is the caller graph for this function:

Definition at line 74 of file test_ArchivistTool.py.

00074 
00075     def test00_interface(self):
00076         portal_archivist = self.portal.portal_archivist
00077         verifyObject(IArchivist, portal_archivist)
00078         verifyObject(IPurgeSupport, portal_archivist)

Definition at line 79 of file test_ArchivistTool.py.

00079 
00080     def test01_registerAttachesAHistoryId(self):
00081         portal_archivist = self.portal.portal_archivist
00082         portal_historyidhandler = self.portal.portal_historyidhandler
00083         portal_historiesstorage = self.portal.portal_historiesstorage
00084         doc = self.portal.doc
00085         prep = portal_archivist.prepare(doc, app_metadata='save number 1')
00086         portal_archivist.register(prep)
00087         history_id = portal_historyidhandler.queryUid(doc)
00088         self.failUnless(history_id)

Definition at line 89 of file test_ArchivistTool.py.

00089 
00090     def test02_retrieve(self):
00091         portal_archivist = self.portal.portal_archivist
00092         portal_historyidhandler = self.portal.portal_historyidhandler
00093         portal_historiesstorage = self.portal.portal_historiesstorage
00094         doc = self.portal.doc
00095         doc.text = 'text v1'
00096         prep = portal_archivist.prepare(doc, app_metadata='save number 1')
00097         portal_archivist.register(prep)
00098         doc.text = 'text v2'
00099         prep = portal_archivist.prepare(doc, app_metadata='save number 2')
00100         portal_archivist.save(prep)
00101         vdata = portal_archivist.retrieve(obj=doc, selector=0, preserve=('gaga', 'gugus'))
00102         retr_doc = vdata.data.object
00103         retr_meta = vdata.app_metadata
00104         doc_histid = portal_historyidhandler.queryUid(doc)
00105         retr_histid = portal_historyidhandler.queryUid(retr_doc)
00106         self.assertEqual(doc_histid, retr_histid)
00107         # check if correct version retrieved and working object unchanged
00108         self.assertEqual(retr_doc.text , 'text v1')
00109         self.assertEqual(retr_meta , 'save number 1')
00110         self.assertEqual(doc.text , 'text v2')
00111         self.assertEqual(len(vdata.preserved_data), 2)
00112         self.assertEqual(vdata.preserved_data['gaga'], 'gaga')
00113         self.assertEqual(vdata.preserved_data['gugus'], 'gugus')

Definition at line 114 of file test_ArchivistTool.py.

00114 
00115     def test03_retrieveById(self):
00116         portal_archivist = self.portal.portal_archivist
00117         portal_historyidhandler = self.portal.portal_historyidhandler
00118         portal_historiesstorage = self.portal.portal_historiesstorage
00119         doc = self.portal.doc
00120         doc.text = 'text v1'
00121         prep = portal_archivist.prepare(doc, app_metadata='save number 1')
00122         portal_archivist.register(prep)
00123         doc.text = 'text v2'
00124         prep = portal_archivist.prepare(doc, app_metadata='save number 2')
00125         portal_archivist.save(prep)
00126         doc_histid = portal_historyidhandler.queryUid(doc)
00127         vdata = portal_archivist.retrieve(history_id=doc_histid, selector=0, 
00128                                           preserve=('gaga', 'gugus'))
00129         retr_doc = vdata.data.object
00130         retr_meta = vdata.app_metadata
00131         # check if correct version retrieved and working object unchanged
00132         self.assertEqual(retr_doc.text , 'text v1')
00133         self.assertEqual(retr_meta , 'save number 1')
00134         self.assertEqual(doc.text , 'text v2')
00135         self.assertEqual(len(vdata.preserved_data), 2)
00136         self.assertEqual(vdata.preserved_data['gaga'], 'gaga')
00137         self.assertEqual(vdata.preserved_data['gugus'], 'gugus')

Definition at line 138 of file test_ArchivistTool.py.

00138 
00139     def test04_getHistory(self):
00140         portal_archivist = self.portal.portal_archivist
00141         portal_historyidhandler = self.portal.portal_historyidhandler
00142         portal_historiesstorage = self.portal.portal_historiesstorage
00143         doc = self.portal.doc
00144 
00145         doc.text = 'text v1'
00146         prep = portal_archivist.prepare(doc, app_metadata='save number 1')
00147         portal_archivist.register(prep)
00148 
00149         doc.text = 'text v2'
00150         prep = portal_archivist.prepare(doc, app_metadata='save number 2')
00151         portal_archivist.save(prep)
00152 
00153         history = portal_archivist.getHistory(doc)
00154 
00155         self.assertEqual(len(history), 2)
00156         # check if timestamp and principal available
00157         self.failUnless(history[0].sys_metadata['timestamp'])
00158         self.failUnless(history[0].sys_metadata['principal'])
00159         # check if correct data and metadata retrieved
00160         self.assertEqual(history[0].data.object.text, 'text v1')
00161         self.assertEqual(history[0].app_metadata, 'save number 1')
00162         self.assertEqual(history[1].data.object.text, 'text v2')
00163         self.assertEqual(history[1].app_metadata, 'save number 2')

Definition at line 164 of file test_ArchivistTool.py.

00164 
00165     def test05_iterateOverHistory(self):
00166         portal_archivist = self.portal.portal_archivist
00167         doc = self.portal.doc
00168 
00169         doc.text = 'text v1'
00170         prep = portal_archivist.prepare(doc, app_metadata='save number 1')
00171         portal_archivist.register(prep)
00172 
00173         doc.text = 'text v2'
00174         prep = portal_archivist.prepare(doc, app_metadata='save number 2')
00175         portal_archivist.save(prep)
00176 
00177         doc.text = 'text v3'
00178         prep = portal_archivist.prepare(doc, app_metadata='save number 3')
00179         portal_archivist.save(prep)
00180 
00181         counter = 0
00182         
00183         for vdata in portal_archivist.getHistory(doc):
00184             counter += 1
00185             self.assertEqual(vdata.data.object.text, 'text v%s' % counter)
00186             self.assertEqual(vdata.app_metadata, 'save number %s' % counter)

Definition at line 187 of file test_ArchivistTool.py.

00187 
00188     def test06_getHistoryById(self):
00189         portal_archivist = self.portal.portal_archivist
00190         portal_historyidhandler = self.portal.portal_historyidhandler
00191         portal_historiesstorage = self.portal.portal_historiesstorage
00192         doc = self.portal.doc
00193 
00194         doc.text = 'text v1'
00195         prep = portal_archivist.prepare(doc, app_metadata='save number 1')
00196         portal_archivist.register(prep)
00197 
00198         doc.text = 'text v2'
00199         prep = portal_archivist.prepare(doc, app_metadata='save number 2')
00200         portal_archivist.save(prep)
00201 
00202         doc_histid = portal_historyidhandler.queryUid(doc)
00203         history = portal_archivist.getHistory(history_id=doc_histid)
00204 
00205         self.assertEqual(len(history), 2)
00206         # check if timestamp and principal available
00207         self.failUnless(history[0].sys_metadata['timestamp'])
00208         self.failUnless(history[0].sys_metadata['principal'])
00209         # check if correct data and metadata retrieved
00210         self.assertEqual(history[0].data.object.text, 'text v1')
00211         self.assertEqual(history[0].app_metadata, 'save number 1')
00212         self.assertEqual(history[1].data.object.text, 'text v2')
00213         self.assertEqual(history[1].app_metadata, 'save number 2')

Definition at line 214 of file test_ArchivistTool.py.

00214 
00215     def test07_prepareObjectWithReferences(self):
00216         # test with a different modifier
00217         self._setDummyTool(FolderishContentObjectModifier())
00218 
00219         portal_archivist = self.portal.portal_archivist
00220         portal_hidhandler = self.portal.portal_historyidhandler
00221         IVersionAwareReference = portal_archivist.interfaces.IVersionAwareReference
00222         fol = self.portal.fol
00223         fol.title = "BLOB title ..."
00224         doc1_inside = fol.doc1_inside
00225         doc2_inside = fol.doc2_inside
00226         doc3_outside = fol.doc3_outside
00227 
00228         doc1_inside.text = 'doc1_inside: inside reference'
00229         doc2_inside.text = 'doc2_inside: inside reference'
00230         doc3_outside.text = 'doc3_outside: outside reference'
00231 
00232         prep = portal_archivist.prepare(fol, app_metadata='save number 1')
00233 
00234         self.assertEqual(fol, prep.original.object)
00235 
00236         # it is important that the clones returned reference info contain
00237         # references to the outgoing references and the python refs are
00238         # replaced by 'IVersionAwareRefrence' objects
00239         inside_refs = prep.clone.inside_refs
00240         outside_refs = prep.clone.outside_refs
00241         self.assertEqual(len(inside_refs), 2)
00242         self.assertEqual(len(outside_refs), 1)
00243         refs = [ref.getAttribute() for ref in inside_refs+outside_refs]
00244         for ref in refs:
00245             self.failUnless(IVersionAwareReference.isImplementedBy(ref))
00246         cloneValues = prep.clone.object.objectValues()
00247         for sub in cloneValues:
00248             self.failUnless(sub in refs)
00249 
00250         # it is important that the originals returned reference info contain
00251         # references to the outgoing references
00252         inside_orefs = prep.original.inside_refs
00253         outside_orefs = prep.original.outside_refs
00254         self.assertEqual(len(inside_orefs), 2)
00255         self.assertEqual(len(outside_orefs), 1)
00256         refs = inside_orefs+outside_orefs
00257         originalValues = prep.original.object.objectValues()
00258 
00259         for sub in originalValues:
00260             self.failUnless(sub in refs)
00261 
00262         # the clones and the originals refs must also reference the
00263         # "same" object
00264         self.assertEqual(prep.clone.object.objectIds(),
00265                          prep.original.object.objectIds())
00266 
00267         self.assertEqual(len(prep.referenced_data), 1)
00268         self.failUnless(prep.referenced_data['title'] is fol.title)
00269         
00270         self.assertEqual(prep.metadata['app_metadata'], 'save number 1')
00271         self.failUnless('timestamp' in prep.metadata['sys_metadata'])
00272         self.failUnless('principal' in prep.metadata['sys_metadata'])
00273         
00274         self._setDummyTool(DummyModifier())

Here is the call graph for this function:

Definition at line 275 of file test_ArchivistTool.py.

00275 
00276     def test08_retrieveWithReferences(self):
00277         # test with a different modifier
00278         self._setDummyTool(FolderishContentObjectModifier())
00279         
00280         portal_archivist = self.portal.portal_archivist
00281         portal_hidhandler = self.portal.portal_historyidhandler
00282         IVersionAwareReference = portal_archivist.interfaces.IVersionAwareReference
00283         fol = self.portal.fol
00284         fol.title = "BLOB title ..."
00285         doc1_inside = fol.doc1_inside
00286         doc2_inside = fol.doc2_inside
00287         doc3_outside = fol.doc3_outside
00288         
00289         doc1_inside.text = 'doc1_inside: inside reference'
00290         doc2_inside.text = 'doc2_inside: inside reference'
00291         doc3_outside.text = 'doc3_outside: outside reference'
00292         
00293         prep = portal_archivist.prepare(fol, app_metadata='save number 1')
00294         
00295         # just set the info to some value before save to test if the 
00296         # reference stuff is saved and retrieved correctly
00297         inside_refs = prep.clone.inside_refs
00298         outside_refs = prep.clone.outside_refs
00299         refs = [ref.getAttribute() for ref in inside_refs+outside_refs]
00300         for ref in refs:
00301             ref.info = refs.index(ref)
00302         
00303         portal_archivist.save(prep, autoregister=True)
00304         
00305         retr = portal_archivist.retrieve(fol)
00306         
00307         # check metadata
00308         self.assertEqual(retr.app_metadata, 'save number 1')
00309         self.failUnless('timestamp' in retr.sys_metadata)
00310         self.failUnless('principal' in retr.sys_metadata)
00311         
00312         # check the references
00313         inside_refs = retr.data.inside_refs
00314         outside_refs = retr.data.outside_refs
00315         self.assertEqual(len(inside_refs), 2)
00316         self.assertEqual(len(outside_refs), 1)
00317         refs = [ref.getAttribute() for ref in inside_refs+outside_refs]
00318         for ref in refs:
00319             self.failUnless(IVersionAwareReference.isImplementedBy(ref))
00320             # check info value (see note above)
00321             self.assertEquals(ref.info, refs.index(ref))

Here is the call graph for this function:

Definition at line 322 of file test_ArchivistTool.py.

00322 
00323     def test09_isUpToDate(self):
00324         doc = self.portal.doc
00325         portal_archivist = self.portal.portal_archivist
00326         doc.text = 'text v1'
00327         prep = portal_archivist.prepare(doc, app_metadata='save number 1')
00328         v1 = portal_archivist.register(prep)
00329 
00330         self.failUnless(portal_archivist.isUpToDate(obj=doc))
00331         self.failUnless(portal_archivist.isUpToDate(obj=doc, selector=v1))
00332 
00333         doc.text = 'text v2'
00334         notifyModified(doc)
00335         self.failIf(portal_archivist.isUpToDate(obj=doc))
00336 
00337         prep = portal_archivist.prepare(doc, app_metadata='save number 2')
00338         v2 = portal_archivist.save(prep)
00339 
00340         self.failUnless(portal_archivist.isUpToDate(obj=doc))
00341         self.failUnless(portal_archivist.isUpToDate(obj=doc, selector=v2))
00342         self.failIf(portal_archivist.isUpToDate(obj=doc, selector=v1))
00343 

Here is the call graph for this function:


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