Back to index

plone3  3.1.7
Public Member Functions
CMFEditions.tests.test_IntegrationTests.TestIntegration Class Reference

List of all members.

Public Member Functions

def afterSetUp
def test01_assertApplyVersionControlSavesOnlyOnce
def test02_storeAndRevertToPreviousVersion
def test03_revertToSpecificVersion
def test04_storeAndRevertToPreviousVersionAndStoreAgain
def test05_getHistory
def test06_retrieveSpecificVersion
def test07_cloneObjectUnderVersionControlRemovesOriginalsHistory
def test08_loopOverHistory
def test09_retrieveAndRevertRetainWorkingCopiesWorkflowInfo
def test10_versionAStandardFolder
def test11_versionAFolderishObjectThatTreatsChildrensAsInsideRefs
def test12_retrieveAndRevertRetainWorkingCopiesPermissions
def test13_revertUpdatesCatalog
def test14_retrieveFolderWithAddedOrDeletedObjects
def test15_retrieveInsideRefsFolderWithAddedOrDeletedObjects
def test16_revertInsideRefsUpdatesCatalog
def test17_moveInsideRefThenRevertChangesUid
def test18_retrieveObjectWhichHasBeenReplaced
def disabled_test19_retrieveDeletedObjectWhichHasBeenReplacedInAnInsideRefsFolder
def disabled_test20_retrieveMovedObjectWhichHasBeenReplacedInAnInsideRefsFolder
def test21_DontLeaveDanglingCatalogEntriesWhenInvokingFactory
def test21_RevertObjectWithChangedIdMaintainsConsistentCatalog
def test21_RestoreMovedObject

Detailed Description

Definition at line 32 of file test_IntegrationTests.py.


Member Function Documentation

Definition at line 34 of file test_IntegrationTests.py.

00034 
00035     def afterSetUp(self):
00036         # we need to have the Manager role to be able to add things
00037         # to the portal root
00038         self.setRoles(['Manager',])
00039 
00040         # add an additional user
00041         self.portal.acl_users.userFolderAddUser('reviewer', 'reviewer',
00042                                                 ['Manager'], '')
00043         # add a document
00044         self.portal.invokeFactory('Document', 'doc')
00045 
00046         # add a folder with two documents in it
00047         self.portal.invokeFactory('Folder', 'fol')
00048         self.portal.fol.invokeFactory('Document', 'doc1')
00049         self.portal.fol.invokeFactory('Document', 'doc2')

Here is the call graph for this function:

Definition at line 705 of file test_IntegrationTests.py.

00705 
00706     def disabled_test19_retrieveDeletedObjectWhichHasBeenReplacedInAnInsideRefsFolder(self):
00707         # disabled by gregweb/21-10-2006
00708         # reason: Needs concentrated and deeper look. 
00709         # --> Ideas exist, pleas contact us on the list if you like to work on that.
00710         # I know one should not do that! But solving this would bring more risks
00711         # into the 1.0final than leaving the bug to be solved afterwards.
00712         portal_repo = self.portal.portal_repository
00713         fol = self.portal.fol
00714         doc1 = fol.doc1
00715         doc2 = fol.doc2
00716 
00717         portal_modifier = self.portal.portal_modifier
00718         portal_modifier.edit("OMOutsideChildrensModifier", enabled=False,
00719                              condition="python: False")
00720         portal_modifier.edit("OMInsideChildrensModifier", enabled=True,
00721                              condition="python: portal_type=='Folder'")
00722 
00723         # save change no 1
00724         fol.setTitle('v1 of fol')
00725         doc1.setTitle("v1 of doc1")
00726         doc2.setTitle("v1 of doc2")
00727 
00728         portal_repo.applyVersionControl(fol, comment='first save')
00729 
00730         fol.manage_delObjects(['doc1'])
00731         transaction.savepoint(optimistic=True)
00732         fol.manage_renameObjects(['doc2'],['doc1'])
00733 
00734         doc2 = fol.doc1
00735 
00736         doc1.setTitle('v2 of doc1_renamed')
00737         doc2.setTitle('v2 of doc1 (was doc2)')
00738 
00739         portal_repo.save(fol, comment='second save')
00740 
00741         retrieved_data = portal_repo.retrieve(fol, 0)
00742         ret_fol = retrieved_data.object
00743         self.assertEqual(ret_fol.objectIds(), ['doc1', 'doc2'])
00744         ret_doc1 = ret_fol.doc1
00745         ret_doc2 = ret_fol.doc2
00746         self.assertEqual(ret_doc1.getId(), 'doc1')
00747         self.assertEqual(ret_doc1.Title(), 'v1 of doc1')
00748         self.assertEqual(ret_doc2.getId(), 'doc2')
00749         self.assertEqual(ret_doc2.Title(), 'v1 of doc2')
00750 
00751         portal_repo.revert(fol, 0)
00752         rev_fol = self.portal.fol
00753         self.assertEqual(rev_fol.objectIds(), ['doc1', 'doc2'])
00754         rev_doc1 = rev_fol.doc1
00755         rev_doc2 = rev_fol.doc2
00756         self.assertEqual(rev_doc1.getId(), 'doc1')
00757         self.assertEqual(rev_doc1.Title(), 'v1 of doc1')
00758         self.assertEqual(rev_doc2.getId(), 'doc2')
00759         self.assertEqual(rev_doc2.Title(), 'v1 of doc2')

Definition at line 760 of file test_IntegrationTests.py.

00760 
00761     def disabled_test20_retrieveMovedObjectWhichHasBeenReplacedInAnInsideRefsFolder(self):
00762         # disabled by gregweb/21-10-2006
00763         # reason: Needs concentrated and deeper look. 
00764         # --> Ideas exist, pleas contact us on the list if you like to work on that.
00765         # I know one should not do that! But solving this would bring more risks
00766         # into the 1.0final than leaving the bug to be solved afterwards.
00767         portal_repo = self.portal.portal_repository
00768         fol = self.portal.fol
00769         doc1 = fol.doc1
00770         doc2 = fol.doc2
00771 
00772         portal_modifier = self.portal.portal_modifier
00773         portal_modifier.edit("OMOutsideChildrensModifier", enabled=False,
00774                              condition="python: False")
00775         portal_modifier.edit("OMInsideChildrensModifier", enabled=True,
00776                              condition="python: portal_type=='Folder'")
00777 
00778         # save change no 1
00779         fol.setTitle('v1 of fol')
00780         doc1.setTitle("v1 of doc1")
00781         doc2.setTitle("v1 of doc2")
00782 
00783         portal_repo.applyVersionControl(fol, comment='first save')
00784 
00785         transaction.savepoint(optimistic=True)
00786         self.portal.manage_pasteObjects(fol.manage_cutObjects(['doc1']))
00787         fol.manage_renameObjects(['doc2'],['doc1'])
00788 
00789         doc2 = fol.doc1
00790         doc1 = self.portal.doc1
00791 
00792         doc1.setTitle('v2 of doc1 (now in portal root)')
00793         doc2.setTitle('v2 of doc1 (was doc2)')
00794 
00795         portal_repo.save(fol, comment='second save')
00796 
00797         retrieved_data = portal_repo.retrieve(fol, 0)
00798         ret_fol = retrieved_data.object
00799         self.assertEqual(ret_fol.objectIds(), ['doc1', 'doc2'])
00800         ret_doc1 = ret_fol.doc1
00801         ret_doc2 = ret_fol.doc2
00802         self.assertEqual(ret_doc1.getId(), 'doc1')
00803         self.assertEqual(ret_doc1.Title(), 'v1 of doc1')
00804         self.assertEqual(ret_doc2.getId(), 'doc2')
00805         self.assertEqual(ret_doc2.Title(), 'v1 of doc2')
00806 
00807         retrieved_data = portal_repo.revert(fol, 0)
00808         rev_fol = self.portal.fol
00809         self.assertEqual(rev_fol.objectIds(), ['doc1', 'doc2'])
00810         rev_doc1 = rev_fol.doc1
00811         rev_doc2 = rev_fol.doc2
00812         self.assertEqual(rev_doc1.getId(), 'doc1')
00813         self.assertEqual(rev_doc1.Title(), 'v1 of doc1')
00814         self.assertEqual(rev_doc2.getId(), 'doc2')
00815         self.assertEqual(rev_doc2.Title(), 'v1 of doc2')

Definition at line 50 of file test_IntegrationTests.py.

00050 
00051     def test01_assertApplyVersionControlSavesOnlyOnce(self):
00052         portal_repo = self.portal.portal_repository
00053         doc = self.portal.doc
00054 
00055         doc.setTitle('doc title v1')
00056         portal_repo.applyVersionControl(doc, comment='First version')
00057 
00058         # there should be only one history entry and not two or more
00059         self.assertEqual(len(portal_repo.getHistory(doc)), 1)

Definition at line 60 of file test_IntegrationTests.py.

00060 
00061     def test02_storeAndRevertToPreviousVersion(self):
00062         portal_repo = self.portal.portal_repository
00063         doc = self.portal.doc
00064 
00065         doc.setTitle("v1")
00066         portal_repo.applyVersionControl(doc)
00067         doc.setTitle("v2")
00068         portal_repo.save(doc)
00069         doc.setTitle("v3")
00070 
00071         self.assertEqual(doc.Title(), "v3")
00072 
00073         portal_repo.revert(doc)
00074         # just a remark: we don't do "doc = self.portal.doc" to check for
00075         # inplace replacement
00076         self.assertEqual(doc.Title(), "v2")

Definition at line 77 of file test_IntegrationTests.py.

00077 
00078     def test03_revertToSpecificVersion(self):
00079         portal_repo = self.portal.portal_repository
00080         doc = self.portal.doc
00081 
00082         # store the work edition two times
00083         doc.setTitle("v1")
00084         portal_repo.applyVersionControl(doc)
00085         doc.setTitle("v2")
00086         portal_repo.save(doc)
00087         doc.setTitle("v3")
00088         portal_repo.save(doc)
00089         doc.setTitle("v4")
00090         self.assertEqual(doc.Title(), "v4")
00091 
00092         # revert to the the last but one version
00093         portal_repo.revert(doc, 1)
00094         self.assertEqual(doc.Title(), "v2")

Definition at line 95 of file test_IntegrationTests.py.

00095 
00096     def test04_storeAndRevertToPreviousVersionAndStoreAgain(self):
00097         portal_repo = self.portal.portal_repository
00098         doc = self.portal.doc
00099 
00100         doc.setTitle("v1")
00101         portal_repo.applyVersionControl(doc)
00102         doc.setTitle("v2")
00103         portal_repo.save(doc)
00104         doc.setTitle("v3")
00105         self.assertEqual(doc.Title(), "v3")
00106 
00107         portal_repo.revert(doc, 0)
00108         doc = self.portal.doc
00109         self.assertEqual(doc.Title(), "v1")
00110         doc.setTitle("v4")
00111         portal_repo.save(doc)
00112         self.assertEqual(doc.Title(), "v4")

Definition at line 113 of file test_IntegrationTests.py.

00113 
00114     def test05_getHistory(self):
00115         portal_repo = self.portal.portal_repository
00116         doc = self.portal.doc
00117 
00118         # store and publish certain times
00119         portal_repo.applyVersionControl(doc)
00120 
00121         portal_repo.save(doc, metadata="v2\nsecond line")
00122         portal_repo.save(doc)
00123 
00124         history = portal_repo.getHistory(doc)
00125 
00126         # test the number of history entries
00127         self.assertEqual(len(history), 3)
00128 
00129         """XXX we like to test that but implementation isn't there yet
00130         # test some of the log entries"""
00131         h1 = history[1]
00132         self.assertEqual(h1.version_id, 1)
00133         #self.assertEqual(h1.action, h1.ACTION_CHECKIN)
00134         #self.assertEqual(h1.message, 'v2\nsecond line')
00135         #self.failUnless(h1.user_id)
00136         #self.assertEqual(h1.path, '/'.join(doc.getPhysicalPath()))
00137         #self.failUnless(h1.timestamp)
00138         """"""

Definition at line 139 of file test_IntegrationTests.py.

00139 
00140     def test06_retrieveSpecificVersion(self):
00141         portal_repo = self.portal.portal_repository
00142         doc = self.portal.doc
00143 
00144         review_state = self.portal.portal_workflow.getInfoFor(doc, 'review_state')
00145 
00146         # store the work edition two times
00147         doc.setTitle("v1")
00148         portal_repo.applyVersionControl(doc)
00149         doc.setTitle("v2")
00150         portal_repo.save(doc)
00151         doc.setTitle("v3")
00152         portal_repo.save(doc)
00153         doc.setTitle("v4")
00154         self.assertEqual(doc.Title(), "v4")
00155 
00156         retrieved_doc = portal_repo.retrieve(doc, 1)
00157 
00158         self.assertEqual(retrieved_doc.object.Title(), "v2")
00159         self.assertEqual(doc.Title(), "v4")
00160         self.assertEqual(self.portal.doc.Title(), "v4")
00161 
00162         # since 1.0beta1 the workflows review state is saved to the
00163         # system metadata by a modifier.
00164         self.assertEqual(retrieved_doc.sys_metadata["review_state"], review_state)

Definition at line 165 of file test_IntegrationTests.py.

00165 
00166     def test07_cloneObjectUnderVersionControlRemovesOriginalsHistory(self):
00167         portal_repo = self.portal.portal_repository
00168         portal_historyidhandler = self.portal.portal_historyidhandler
00169         UniqueIdError = portal_historyidhandler.UniqueIdError
00170         doc = self.portal.doc
00171 
00172         # put the object under version control
00173         portal_repo.applyVersionControl(doc)
00174 
00175         # copy
00176         self.portal.manage_pasteObjects(self.portal.manage_copyObjects(ids=['doc']))
00177         copy = self.portal.copy_of_doc
00178 
00179         # the copy shall not have a history yet: that's correct
00180         self.failIf(portal_repo.getHistory(copy))
00181 
00182         # just to be sure the history is definitivels different
00183         self.failIfEqual(
00184             portal_historyidhandler.queryUid(doc),
00185             portal_historyidhandler.queryUid(copy)) # may be None

Definition at line 186 of file test_IntegrationTests.py.

00186 
00187     def test08_loopOverHistory(self):
00188         portal_repo = self.portal.portal_repository
00189         portal_historyidhandler = self.portal.portal_historyidhandler
00190         UniqueIdError = portal_historyidhandler.UniqueIdError
00191         doc = self.portal.doc
00192 
00193         # put the object under version control
00194         portal_repo.applyVersionControl(doc)
00195 
00196         counter = 0
00197         for v in portal_repo.getHistory(doc):
00198             counter += 1
00199 
00200         # check if history iterator returned just one element
00201         self.assertEquals(counter, 1)

Definition at line 202 of file test_IntegrationTests.py.

00202 
00203     def test09_retrieveAndRevertRetainWorkingCopiesWorkflowInfo(self):
00204         portal_repo = self.portal.portal_repository
00205         doc = self.portal.doc
00206 
00207         doc.review_state = "fake rev state v1"
00208         doc.workflow_history = {0: "fake wf history v1"}
00209 
00210         portal_repo.applyVersionControl(doc)
00211 
00212         doc.review_state = "fake rev state v2"
00213         doc.workflow_history = {0: "fake wf history v2"}
00214         portal_repo.save(doc)
00215 
00216         # just check the original is unchanged
00217         self.assertEqual(doc.review_state, "fake rev state v2")
00218         self.assertEqual(doc.workflow_history[0], "fake wf history v2")
00219 
00220         # ----- retrieve
00221         # check if retrieved object carries the working copies workflow info
00222         retrieved_data = portal_repo.retrieve(doc, 0, preserve=['review_state',
00223                                                       'workflow_history'])
00224         self.assertEqual(retrieved_data.object.review_state,
00225                          "fake rev state v2")
00226         self.assertEqual(retrieved_data.object.workflow_history[0],
00227                          "fake wf history v2")
00228 
00229         # check that the working copies workflow info is unchanged
00230         self.assertEqual(doc.review_state, "fake rev state v2")
00231         self.assertEqual(doc.workflow_history[0], "fake wf history v2")
00232 
00233         # check if the preserved data is returned correctly
00234         preserved_rvs = retrieved_data.preserved_data['review_state']
00235         self.assertEqual(preserved_rvs, "fake rev state v1")
00236         preserved_wfh = retrieved_data.preserved_data['workflow_history'][0]
00237         self.assertEqual(preserved_wfh, "fake wf history v1")
00238 
00239         # ----- revert
00240         # check that the working copies workflow info is unchanged after
00241         portal_repo.revert(doc, 0)
00242         self.assertEqual(doc.review_state, "fake rev state v2")
00243         self.assertEqual(doc.workflow_history[0], "fake wf history v2")

Definition at line 244 of file test_IntegrationTests.py.

00244 
00245     def test10_versionAStandardFolder(self):
00246         portal_repo = self.portal.portal_repository
00247         fol = self.portal.fol
00248         doc1 = fol.doc1
00249         doc2 = fol.doc2
00250 
00251         # save change no 1
00252         fol.setTitle('v1 of fol')
00253         doc1.setTitle("v1 of doc1")
00254         doc2.setTitle("v1 of doc2")
00255 
00256         portal_repo.applyVersionControl(fol, comment='first save')
00257 
00258         # save change no 2
00259         fol.setTitle('v2 of fol')
00260         doc1.setTitle("v2 of doc1")
00261         doc2.setTitle("v2 of doc2")
00262         portal_repo.save(fol, comment='second save')
00263 
00264         # change no 3 (without saving)
00265         fol.setTitle('v3 of fol')
00266         doc1.setTitle("v3 of doc1")
00267         doc2.setTitle("v3 of doc2")
00268 
00269         # revert to change no 2
00270         portal_repo.revert(fol)
00271 
00272         # check if revertion worked correctly
00273         fol = self.portal.fol
00274         doc1 = fol.doc1
00275         doc2 = fol.doc2
00276         self.assertEqual(fol.Title(), "v2 of fol")
00277         self.assertEqual(doc1.Title(), "v3 of doc1")
00278         self.assertEqual(doc2.Title(), "v3 of doc2")

Definition at line 279 of file test_IntegrationTests.py.

00279 
00280     def test11_versionAFolderishObjectThatTreatsChildrensAsInsideRefs(self):
00281         portal_repo = self.portal.portal_repository
00282         portal_historyidhandler = self.portal.portal_historyidhandler
00283         fol = self.portal.fol
00284         doc1 = fol.doc1
00285         doc2 = fol.doc2
00286 
00287         # just configure the standard folder to treat the childrens as
00288         # inside refrences. For this we reconfigure the standard modifiers.
00289         portal_modifier = self.portal.portal_modifier
00290         portal_modifier.edit("OMOutsideChildrensModifier", enabled=False,
00291                              condition="python: False")
00292         portal_modifier.edit("OMInsideChildrensModifier", enabled=True,
00293                              condition="python: portal_type=='Folder'")
00294 
00295         # save change no 1
00296         fol.setTitle('v1 of fol')
00297         doc1.setTitle("v1 of doc1")
00298         doc2.setTitle("v1 of doc2")
00299         portal_repo.applyVersionControl(fol, comment='first save')
00300         orig_uid1 = portal_historyidhandler.queryUid(doc1)
00301         orig_uid2 = portal_historyidhandler.queryUid(doc2)
00302 
00303         # save change no 2
00304         fol.setTitle('v2 of fol')
00305         doc1.setTitle("v2 of doc1")
00306         doc2.setTitle("v2 of doc2")
00307         portal_repo.save(fol, comment='second save after we deleted doc2')
00308 
00309         # save change no 3
00310         fol.setTitle('v3 of fol')
00311         doc1.setTitle("v3 of doc1")
00312         fol.manage_delObjects(ids=['doc2'])
00313         fol.invokeFactory('Document', 'doc3')
00314         doc3 = fol.doc3
00315         doc3.setTitle("v1 of doc3")
00316         portal_repo.save(fol, comment='second save with new doc3')
00317 
00318         # revert to change no 1 (version idexes start with index 0)
00319         portal_repo.revert(fol, selector=1)
00320 
00321         # check if revertion worked correctly
00322         fol = self.portal.fol
00323         doc1 = fol.doc1
00324         self.failUnless('doc2' in fol.objectIds())
00325         self.failIf('doc3' in fol.objectIds())
00326         doc2 = fol.doc2
00327         self.assertEqual(fol.Title(), "v2 of fol")
00328         self.assertEqual(doc1.Title(), "v2 of doc1")
00329         self.assertEqual(doc2.Title(), "v2 of doc2")
00330         self.assertEqual(portal_historyidhandler.queryUid(doc1), orig_uid1)
00331         self.assertEqual(portal_historyidhandler.queryUid(doc2), orig_uid2)
00332 

Definition at line 333 of file test_IntegrationTests.py.

00333 
00334     def test12_retrieveAndRevertRetainWorkingCopiesPermissions(self):
00335         portal_repo = self.portal.portal_repository
00336         doc = self.portal.doc
00337         perm = 'Access contents information'
00338         roles = list(doc.valid_roles())
00339         member_role = 'p0r%s' % roles.index('Member')
00340         manager_role = 'p0r%s' % roles.index('Manager')
00341 
00342         doc.manage_permission(perm, ('Manager',), 0)
00343 
00344         portal_repo.applyVersionControl(doc)
00345 
00346         doc.manage_permission(perm, ('Manager', 'Member'), 1)
00347         portal_repo.save(doc)
00348 
00349         # just check the original is unchanged
00350         settings = doc.permission_settings(perm)[0]
00351         self.failUnless(settings['acquire'])
00352         role_enabled = [r for r in settings['roles']
00353                                         if r['name'] == member_role][0]
00354         self.failUnless(role_enabled['checked'])
00355 
00356         # ----- retrieve
00357         # check if retrieved object carries the working copy's permissions
00358         retrieved_data = portal_repo.retrieve(doc, 0,
00359                         preserve=['_Access_contents_information_Permission'])
00360         settings = retrieved_data.object.permission_settings(perm)[0]
00361         self.failUnless(settings['acquire'])
00362         role_enabled = [r for r in settings['roles']
00363                                         if r['name'] == member_role][0]
00364         self.failUnless(role_enabled['checked'])
00365 
00366         # check that the working copy's permissions are unchanged
00367         settings = doc.permission_settings(perm)[0]
00368         self.failUnless(settings['acquire'])
00369         role_enabled = [r for r in settings['roles']
00370                                         if r['name'] == member_role][0]
00371         self.failUnless(role_enabled['checked'])
00372 
00373         # check if the preserved data is returned correctly
00374         preserved = retrieved_data.preserved_data['_Access_contents_information_Permission']
00375         self.assertEqual(preserved, ('Manager',))
00376 
00377         # ----- revert
00378         # check that the working copies permissions are unchanged after revert
00379         portal_repo.revert(doc, 0)
00380         settings = doc.permission_settings(perm)[0]
00381         self.failUnless(settings['acquire'])
00382         role_enabled = [r for r in settings['roles']
00383                                         if r['name'] == member_role][0]
00384         self.failUnless(role_enabled['checked'])

Definition at line 385 of file test_IntegrationTests.py.

00385 
00386     def test13_revertUpdatesCatalog(self):
00387         portal_repo = self.portal.portal_repository
00388         cat = self.portal.portal_catalog
00389         doc = self.portal.doc
00390 
00391         doc.edit(text='Plain text')
00392         portal_repo.applyVersionControl(doc)
00393         doc.edit(text='blahblah')
00394         portal_repo.save(doc)
00395         # Test that catalog has current value
00396         results = cat(SearchableText='Plain Text')
00397         self.assertEqual(len(results), 0)
00398         results = cat(SearchableText='blahblah')
00399         self.assertEqual(len(results), 1)
00400         self.assertEqual(results[0].getObject(), doc)
00401 
00402         retrieved_data = portal_repo.retrieve(doc, 0,
00403                         preserve=['_Access_contents_information_Permission'])
00404         retrieved_doc = retrieved_data.object
00405         self.failUnless('Plain text' in retrieved_doc.getText())
00406         # Test that basic retrieval did not alter the catalog
00407         results = cat(SearchableText='Plain Text')
00408         self.assertEqual(len(results), 0)
00409         results = cat(SearchableText='blahblah')
00410         self.assertEqual(len(results), 1)
00411         self.assertEqual(results[0].getObject(), doc)
00412 
00413         portal_repo.revert(doc, 0)
00414         # Test that the catalog is updated on revert
00415         results = cat(SearchableText='blahblah')
00416         self.assertEqual(len(results), 0)
00417         results = cat(SearchableText='Plain Text')
00418         self.assertEqual(len(results), 1)
00419         self.assertEqual(results[0].getObject().getRawText(), 'Plain text')

Definition at line 420 of file test_IntegrationTests.py.

00420 
00421     def test14_retrieveFolderWithAddedOrDeletedObjects(self):
00422         portal_repo = self.portal.portal_repository
00423         fol = self.portal.fol
00424         doc1 = fol.doc1
00425         doc2 = fol.doc2
00426 
00427         # save change no 1
00428         fol.setTitle('v1 of fol')
00429         doc1.setTitle("v1 of doc1")
00430         doc2.setTitle("v1 of doc2")
00431 
00432         portal_repo.applyVersionControl(fol, comment='first save')
00433 
00434         retrieved_data = portal_repo.retrieve(fol, 0)
00435         ret_folder = retrieved_data.object
00436         self.assertEqual(ret_folder.objectIds(), fol.objectIds())
00437         self.assertEqual(ret_folder.objectValues(), fol.objectValues())
00438 
00439         # remove an item
00440         fol.manage_delObjects('doc2')
00441 
00442         # retrieve should update sub-objects
00443         retrieved_data = portal_repo.retrieve(fol, 0)
00444         ret_folder = retrieved_data.object
00445         self.assertEqual(ret_folder.objectIds(), fol.objectIds())
00446         self.assertEqual(ret_folder.objectValues(), fol.objectValues())
00447 
00448         # add it back
00449         fol.invokeFactory('Document', 'doc2')
00450         doc2 = fol.doc2
00451         doc2.setTitle('v2 of doc2')
00452 
00453         # retrieve should update sub-objects
00454         retrieved_data = portal_repo.retrieve(fol, 0)
00455         ret_folder = retrieved_data.object
00456         self.assertEqual(ret_folder.objectIds(), fol.objectIds())
00457         self.assertEqual(ret_folder.objectValues(), fol.objectValues())
00458         self.assertEqual(ret_folder.doc2.Title(), 'v2 of doc2')
00459 
00460         # add new item
00461         fol.invokeFactory('Document', 'doc3')
00462         doc3 = fol.doc3
00463         doc3.setTitle('v1 of doc3')
00464 
00465         # retrieve should copy new sub-objects
00466         retrieved_data = portal_repo.retrieve(fol, 0)
00467         ret_folder = retrieved_data.object
00468         self.assertEqual(ret_folder.objectIds(), fol.objectIds())
00469         self.assertEqual(ret_folder.objectValues(), fol.objectValues())
00470         self.assertEqual(ret_folder.doc3.Title(), 'v1 of doc3')
00471 
00472         orig_ids = fol.objectIds()
00473         orig_values = fol.objectValues()
00474         # revert to original state, ensure that subobject changes are
00475         # preserved
00476         portal_repo.revert(fol, 0)
00477 
00478         # check if reversion worked correctly
00479         self.assertEqual(fol.objectIds(), orig_ids)
00480         self.assertEqual(fol.objectValues(), orig_values)
00481 
00482         # XXX we should be preserving order as well

Definition at line 483 of file test_IntegrationTests.py.

00483 
00484     def test15_retrieveInsideRefsFolderWithAddedOrDeletedObjects(self):
00485         portal_repo = self.portal.portal_repository
00486         fol = self.portal.fol
00487         doc1 = fol.doc1
00488         doc2 = fol.doc2
00489 
00490         # just configure the standard folder to treat the childrens as
00491         # inside refrences. For this we reconfigure the standard modifiers.
00492         portal_modifier = self.portal.portal_modifier
00493         portal_modifier.edit("OMOutsideChildrensModifier", enabled=False,
00494                              condition="python: False")
00495         portal_modifier.edit("OMInsideChildrensModifier", enabled=True,
00496                              condition="python: portal_type=='Folder'")
00497 
00498         # save change no 1
00499         fol.setTitle('v1 of fol')
00500         doc1.setTitle("v1 of doc1")
00501         doc2.setTitle("v1 of doc2")
00502 
00503         orig_ids = fol.objectIds()
00504         orig_values = fol.objectValues()
00505 
00506         portal_repo.applyVersionControl(fol, comment='first save')
00507 
00508         retrieved_data = portal_repo.retrieve(fol, 0)
00509         ret_folder = retrieved_data.object
00510         self.assertEqual(ret_folder.objectIds(), orig_ids)
00511         ret_values = ret_folder.objectValues()
00512         # The values are not identical to the stored values because they are
00513         # retrieved from the repository.
00514         for i in range(len(ret_values)):
00515             self.assertEqual(ret_values[i].getId(), orig_values[i].getId())
00516             self.assertEqual(ret_values[i].Title(), orig_values[i].Title())
00517 
00518         # remove an item
00519         fol.manage_delObjects('doc2')
00520 
00521         cur_ids = fol.objectIds()
00522         self.assertEqual(len(cur_ids), 1)
00523 
00524         # retrieve should retrieve missing sub-objects
00525         retrieved_data = portal_repo.retrieve(fol, 0)
00526         ret_folder = retrieved_data.object
00527         self.assertEqual(ret_folder.objectIds(), orig_ids)
00528         ret_values = ret_folder.objectValues()
00529         for i in range(len(ret_values)):
00530             self.assertEqual(ret_values[i].getId(), orig_values[i].getId())
00531             self.assertEqual(ret_values[i].Title(), orig_values[i].Title())
00532         # We should not have altered the folder itself on retrieve
00533         self.assertEqual(fol.objectIds(), cur_ids)
00534 
00535         # add new item
00536         fol.invokeFactory('Document', 'doc3')
00537         doc3 = fol.doc3
00538         doc3.setTitle('v1 of doc3')
00539 
00540         cur_ids = fol.objectIds()
00541         self.assertEqual(len(cur_ids), 2)
00542 
00543         # retrieve should not add new sub-objects
00544         retrieved_data = portal_repo.retrieve(fol, 0)
00545         ret_folder = retrieved_data.object
00546         self.assertEqual(ret_folder.objectIds(), orig_ids)
00547         ret_values = ret_folder.objectValues()
00548         for i in range(len(ret_values)):
00549             self.assertEqual(ret_values[i].getId(), orig_values[i].getId())
00550             self.assertEqual(ret_values[i].Title(), orig_values[i].Title())
00551         # We should not have altered the folder itself on retrieve
00552         self.assertEqual(fol.objectIds(), cur_ids)
00553 
00554         # revert to original state, ensure that subobject changes are
00555         # reverted
00556         portal_repo.revert(fol, 0)
00557         fol = self.portal.fol
00558 
00559         # check if reversion worked correctly
00560         self.assertEqual(fol.objectIds(), orig_ids)
00561         rev_values = fol.objectValues()
00562         for i in range(len(ret_values)):
00563             self.assertEqual(ret_values[i].getId(), orig_values[i].getId())
00564             self.assertEqual(ret_values[i].Title(), orig_values[i].Title())

Definition at line 565 of file test_IntegrationTests.py.

00565 
00566     def test16_revertInsideRefsUpdatesCatalog(self):
00567         portal_repo = self.portal.portal_repository
00568         cat = self.portal.portal_catalog
00569         fol = self.portal.fol
00570         doc = fol.doc1
00571 
00572         # just configure the standard folder to treat the childrens as
00573         # inside refrences. For this we reconfigure the standard modifiers.
00574         portal_modifier = self.portal.portal_modifier
00575         portal_modifier.edit("OMOutsideChildrensModifier", enabled=False,
00576                              condition="python: False")
00577         portal_modifier.edit("OMInsideChildrensModifier", enabled=True,
00578                              condition="python: portal_type=='Folder'")
00579 
00580         # save change no 1
00581         fol.setTitle('v1 of fol')
00582         doc.setTitle("v1 of doc1")
00583         fol.reindexObject()
00584         doc.reindexObject()
00585         portal_repo.applyVersionControl(fol, comment='first save')
00586 
00587         # save change no 2
00588         fol.setTitle('v2 of fol')
00589         doc.setTitle("v2 of doc1")
00590         fol.reindexObject()
00591         doc.reindexObject()
00592         portal_repo.save(fol, comment='second save')
00593 
00594         # Test that catalog has current value
00595         results = cat(SearchableText='v1')
00596         self.assertEqual(len(results), 0)
00597         results = cat(SearchableText='v2', portal_type='Document')
00598         self.assertEqual(len(results), 1)
00599         self.assertEqual(results[0].getObject(), doc)
00600 
00601         retrieved_data = portal_repo.retrieve(fol, 0,
00602                         preserve=['_Access_contents_information_Permission'])
00603         retrieved_doc = retrieved_data.object.doc1
00604         self.assertEqual(retrieved_doc.Title(), 'v1 of doc1')
00605         # Test that basic retrieval did not alter the catalog
00606         results = cat(SearchableText='v1', )
00607         self.assertEqual(len(results), 0)
00608         results = cat(SearchableText='v2',  portal_type='Document')
00609         self.assertEqual(len(results), 1)
00610         self.assertEqual(results[0].getObject(), doc)
00611 
00612         portal_repo.revert(fol, 0)
00613         reverted_doc = self.portal.fol.doc1
00614         self.assertEqual(reverted_doc.Title(), 'v1 of doc1')
00615         # Test that the catalog is updated on revert
00616         results = cat(SearchableText='v2')
00617         self.assertEqual(len(results), 0)
00618         results = cat(SearchableText='v1', portal_type='Document')
00619         self.assertEqual(len(results), 1)
00620         self.assertEqual(results[0].getObject().Title(), 'v1 of doc1')

Definition at line 621 of file test_IntegrationTests.py.

00621 
00622     def test17_moveInsideRefThenRevertChangesUid(self):
00623         # When an object is contained in an 'Inside references folder' and has been moved
00624         # into another location, it should maintain its CMF Uid, if the folder is then
00625         # reverted to a state where it contained the object (which now exists with the same
00626         # uid in a different location), the uid of the reverted object should be changed.
00627         portal_repo = self.portal.portal_repository
00628         portal_historyidhandler = self.portal.portal_historyidhandler
00629         fol = self.portal.fol
00630         doc1 = fol.doc1
00631 
00632         # just configure the standard folder to treat the childrens as
00633         # inside refrences. For this we reconfigure the standard modifiers.
00634         portal_modifier = self.portal.portal_modifier
00635         portal_modifier.edit("OMOutsideChildrensModifier", enabled=False,
00636                              condition="python: False")
00637         portal_modifier.edit("OMInsideChildrensModifier", enabled=True,
00638                              condition="python: portal_type=='Folder'")
00639 
00640         # save change no 1
00641         fol.setTitle('v1 of fol')
00642         doc1.setTitle("v1 of doc1")
00643 
00644         portal_repo.applyVersionControl(fol, comment='first save')
00645         orig_uid = portal_historyidhandler.queryUid(doc1)
00646 
00647         transaction.savepoint(optimistic=True)
00648         self.portal.manage_pasteObjects(fol.manage_cutObjects(ids=['doc1']))
00649         moved_doc = self.portal.doc1
00650         self.assertEqual(portal_historyidhandler.queryUid(moved_doc), orig_uid)
00651         transaction.savepoint(optimistic=True)
00652 
00653         # retrieve should change the uid if it already exists
00654         retrieved_data = portal_repo.retrieve(fol, 0)
00655         ret_folder = retrieved_data.object
00656         ret_doc = ret_folder.doc1
00657         self.failIf(portal_historyidhandler.queryUid(ret_doc) == orig_uid,
00658                          "UIDs should not be equal, current value: %s"%orig_uid)
00659 
00660         # revert to original state, ensure that subobject changes are
00661         # reverted and that uid is changed
00662         portal_repo.revert(fol, 0)
00663         fol = self.portal.fol
00664         reverted_doc = fol.doc1
00665 
00666         # check if reversion worked correctly
00667         self.failIf(portal_historyidhandler.queryUid(reverted_doc) == orig_uid,
00668                          "UIDs should not be equal, current value: %s"%orig_uid)

Definition at line 669 of file test_IntegrationTests.py.

00669 
00670     def test18_retrieveObjectWhichHasBeenReplaced(self):
00671         portal_repo = self.portal.portal_repository
00672         fol = self.portal.fol
00673         doc1 = fol.doc1
00674         doc2 = fol.doc2
00675 
00676         # save change no 1
00677         fol.setTitle('v1 of fol')
00678         doc1.setTitle("v1 of doc1")
00679         doc2.setTitle("v1 of doc2")
00680 
00681         portal_repo.applyVersionControl(doc1, comment='first save')
00682         portal_repo.applyVersionControl(doc2, comment='first save')
00683 
00684         transaction.savepoint(optimistic=True)
00685         fol.manage_renameObjects(['doc1','doc2'],['doc1_renamed', 'doc1'])
00686 
00687         doc1 = fol.doc1_renamed
00688         doc2 = fol.doc1
00689 
00690         doc1.setTitle('v2 of doc1_renamed')
00691         doc2.setTitle('v2 of doc1 (was doc2)')
00692 
00693         portal_repo.save(doc1, comment='second save')
00694         portal_repo.save(doc2, comment='second save')
00695 
00696         retrieved_data = portal_repo.retrieve(doc1, 0)
00697         ret_doc = retrieved_data.object
00698         self.assertEqual(ret_doc.getId(), 'doc1')
00699         self.assertEqual(ret_doc.Title(), 'v1 of doc1')
00700 
00701         portal_repo.revert(doc1, 0)
00702         rev_doc = fol.doc1_renamed
00703         self.assertEqual(rev_doc.getId(), 'doc1_renamed')
00704         self.assertEqual(rev_doc.Title(), 'v1 of doc1')

Definition at line 816 of file test_IntegrationTests.py.

00816 
00817     def test21_DontLeaveDanglingCatalogEntriesWhenInvokingFactory(self):
00818         portal_repo = self.portal.portal_repository
00819         catalog = self.portal.portal_catalog
00820         fol = self.portal.fol
00821         doc1 = fol.doc1
00822         doc2 = fol.doc2
00823 
00824         portal_modifier = self.portal.portal_modifier
00825         portal_modifier.edit("OMOutsideChildrensModifier", enabled=False,
00826                              condition="python: False")
00827         portal_modifier.edit("OMInsideChildrensModifier", enabled=True,
00828                              condition="python: portal_type=='Folder'")
00829 
00830         # save change no 1
00831         fol.setTitle('v1 of fol')
00832         doc1.setTitle("v1 of doc1")
00833         doc2.setTitle("v1 of doc2")
00834 
00835         portal_repo.applyVersionControl(fol, comment='first save')
00836 
00837         self.assertEqual(len(catalog(getId='doc1')), 1)
00838 
00839         fol.manage_delObjects(['doc2', 'doc1'])
00840 
00841         self.assertEqual(len(catalog(getId='doc1')), 0)
00842 
00843         portal_repo.save(fol, comment='second save')
00844 
00845 
00846         retrieved_data = portal_repo.retrieve(fol, 0)
00847         ret_fol = retrieved_data.object
00848         self.assertEqual(ret_fol.objectIds(), ['doc1', 'doc2'])
00849         self.assertEqual(len(catalog(getId='doc1')), 0)
00850 
00851         portal_repo.revert(fol, 0)
00852         rev_fol = self.portal.fol
00853         self.assertEqual(rev_fol.objectIds(), ['doc1', 'doc2'])
00854         self.assertEqual(len(catalog(getId='doc1')), 1)

Definition at line 886 of file test_IntegrationTests.py.

00886 
00887     def test21_RestoreMovedObject(self):
00888         portal_repo = self.portal.portal_repository
00889         catalog = self.portal.portal_catalog
00890         portal_hidhandler = self.portal.portal_historyidhandler
00891         fol = self.portal.fol
00892         doc1 = fol.doc1
00893 
00894         # save change no 1
00895         doc1.setTitle("v1 of doc1")
00896 
00897         portal_repo.applyVersionControl(doc1, comment='first save')
00898         # save the ``history_id`` to be able to retrieve the object after
00899         # it's deletion
00900         history_id = portal_hidhandler.queryUid(doc1)
00901 
00902         doc1.setTitle("v2 of doc1")
00903         transaction.savepoint()
00904         fol.manage_renameObject('doc1', 'doc1_changed')
00905         doc1 = fol.doc1_changed
00906         doc1.reindexObject()
00907 
00908         self.assertEqual(len(catalog(getId='doc1')), 0)
00909         self.assertEqual(len(catalog(getId='doc1_changed')), 1)
00910 
00911         portal_repo.save(doc1, comment='second save')
00912         portal_repo.restore(history_id, selector=0, container=fol)
00913         # Both documents should now be in place
00914         res_doc = fol.doc1
00915         self.assertEqual(res_doc.Title(), "v1 of doc1")
00916         self.assertEqual(len(catalog(getId='doc1')), 1)
00917         self.assertEqual(len(catalog(getId='doc1_changed')), 1)
00918         self.assertEqual(len(catalog(Title='v1 of doc1')), 1)
00919         self.assertEqual(len(catalog(Title='v2 of doc1')), 1)
00920         # The reverted document should have a new uid, because an object with
00921         # the original uid exists
00922         self.failIf(portal_hidhandler.queryUid(res_doc) == history_id)

Definition at line 855 of file test_IntegrationTests.py.

00855 
00856     def test21_RevertObjectWithChangedIdMaintainsConsistentCatalog(self):
00857         portal_repo = self.portal.portal_repository
00858         catalog = self.portal.portal_catalog
00859         fol = self.portal.fol
00860         doc1 = fol.doc1
00861 
00862         # save change no 1
00863         doc1.setTitle("v1 of doc1")
00864 
00865         portal_repo.applyVersionControl(doc1, comment='first save')
00866 
00867         self.assertEqual(len(catalog(getId='doc1')), 1)
00868 
00869         doc1.setTitle("v2 of doc1")
00870         transaction.savepoint()
00871         fol.manage_renameObject('doc1', 'doc1_changed')
00872         doc1 = fol.doc1_changed
00873         doc1.reindexObject()
00874 
00875         self.assertEqual(len(catalog(getId='doc1')), 0)
00876         self.assertEqual(len(catalog(getId='doc1_changed')), 1)
00877 
00878         portal_repo.save(doc1, comment='second save')
00879 
00880         portal_repo.revert(doc1, 0)
00881         rev_doc = fol.doc1_changed
00882         self.assertEqual(rev_doc.Title(), "v1 of doc1")
00883         self.assertEqual(len(catalog(getId='doc1')), 0)
00884         self.assertEqual(len(catalog(getId='doc1_changed')), 1)
00885         self.assertEqual(len(catalog(Title='v1 of doc1')), 1)


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