Back to index

plone3  3.1.7
Public Member Functions
CMFEditions.tests.test_ATReferences.TestATReferences Class Reference

List of all members.

Public Member Functions

def afterSetUp
def test_referencesDataGetSavedAndRestored
def test_referencesAreSavedAndRestored
def test_referencesDataGetSavedAndRestored2
def test_referencesAreSavedAndRestored2
def test_contentReferencesAreSavedAndRestored
def test_referencesAreDeleted
def test_refcatalogIsUpdatedWithInsideRefsAndATRefsBetweenChildrenObjs
def test_refOnWorkingCopyArePreserved

Detailed Description

Definition at line 6 of file test_ATReferences.py.


Member Function Documentation

Definition at line 8 of file test_ATReferences.py.

00008 
00009     def afterSetUp(self):
00010         # we need to have the Manager role to be able to add things
00011         # to the portal root
00012         self.setRoles(['Manager',])
00013 
00014         # add an additional user
00015         self.portal.acl_users.userFolderAddUser('reviewer', 'reviewer',
00016                                                 ['Manager'], '')
00017         
00018         # add a folder with two documents in it
00019         self.portal.invokeFactory('Folder', 'fol')
00020         self.portal.fol.invokeFactory('Document', 'doc1')
00021         self.portal.fol.invokeFactory('Document', 'doc2')

Here is the call graph for this function:

Definition at line 120 of file test_ATReferences.py.

00120 
00121     def test_contentReferencesAreSavedAndRestored(self):
00122 
00123         from Products.Archetypes.ReferenceEngine import ContentReference
00124         repo = self.portal.portal_repository
00125         fol = self.portal.fol
00126         doc1 = self.portal.fol.doc1
00127         doc2 = self.portal.fol.doc2
00128 
00129         repo.applyVersionControl(doc1)
00130         repo.applyVersionControl(doc2)
00131 
00132 #  XXX Simply using this kind of ref doesn't work
00133 #         doc1.addReference(doc2, referenceClass=ContentReference,
00134 #         contentType='Document')
00135 #         doc1.setTitle('v1')
00136 #         ref_doc = doc1.getReferenceImpl(targetObject=doc2)[0]
00137 #         ref_doc.setTitle('ref_doc v1')
00138 #         repo.save(doc1)
00139 #         doc1.deleteReference(doc2)
00140 #         self.failIf(doc1.getReferences(targetObject=doc2))
00141 #         repo.revert(doc1, 1)
00142 #         self.assertEqual(aq_base(doc1.getReferences(targetObject=doc2)[0]),
00143 #                          aq_base(doc2))
00144 #         ref_doc = doc1.getReferenceImpl(targetObject=doc2)[0]
00145 #         self.assertEqual('ref_doc v1', ref_doc.getTitle())

Definition at line 164 of file test_ATReferences.py.

00164 
00165     def test_refcatalogIsUpdatedWithInsideRefsAndATRefsBetweenChildrenObjs(self):
00166 
00167         repo = self.portal.portal_repository
00168         fol = self.portal.fol
00169         doc1 = self.portal.fol.doc1
00170         doc2 = self.portal.fol.doc2
00171 
00172         # just configure the standard folder to treat the childrens as
00173         # inside refrences. For this we reconfigure the standard modifiers.
00174         portal_modifier = self.portal.portal_modifier
00175         portal_modifier.edit("OMOutsideChildrensModifier", enabled=False, 
00176                              condition="python: False")
00177         portal_modifier.edit("OMInsideChildrensModifier", enabled=True, 
00178                              condition="python: portal_type=='Folder'")
00179         repo.applyVersionControl(fol)
00180         doc1.setTitle('v1')
00181         doc1.addReference(doc2)
00182         doc2.addReference(doc1)
00183         repo.save(fol)
00184         
00185         doc1.setTitle('changed')
00186         doc1.deleteReference(doc2)
00187         doc2.deleteReference(doc1)
00188         self.failIf(doc1.getReferences())
00189         self.failIf(doc2.getReferences())
00190         repo.revert(fol, 1)
00191         
00192         doc1 = self.portal.fol.doc1
00193         doc2 = self.portal.fol.doc2
00194         self.assertEqual(doc1.Title(), 'v1')
00195         self.assertEqual([doc1], doc2.getReferences())
00196         self.assertEqual([doc2], doc1.getReferences())
        

Definition at line 146 of file test_ATReferences.py.

00146 
00147     def test_referencesAreDeleted(self):
00148 
00149         repo = self.portal.portal_repository
00150         fol = self.portal.fol
00151         doc1 = self.portal.fol.doc1
00152         doc2 = self.portal.fol.doc2
00153 
00154         repo.applyVersionControl(doc1)
00155         repo.applyVersionControl(doc2)
00156 
00157         doc1.addReference(doc2)
00158         doc1.setTitle('v1')
00159         repo.save(doc1)
00160         fol.manage_delObjects('doc2')
00161         repo.revert(doc1, 1)
00162         self.assertEqual(doc1.getReferences(), [])
00163         self.failIf(doc1.getReferenceImpl())

Definition at line 49 of file test_ATReferences.py.

00049 
00050     def test_referencesAreSavedAndRestored(self):
00051         # this case checks restoring a version with a reference to
00052         # a working copy with no reference
00053 
00054         repo = self.portal.portal_repository
00055         fol = self.portal.fol
00056         doc1 = self.portal.fol.doc1
00057         doc2 = self.portal.fol.doc2
00058 
00059         repo.applyVersionControl(doc1)
00060         repo.applyVersionControl(doc2)
00061 
00062         doc1.addReference(doc2)
00063         doc1.setTitle('v1')
00064         repo.save(doc1)
00065         doc1.deleteReference(doc2)
00066         self.failIf(doc1.getReferences(targetObject=doc2))
00067         repo.revert(doc1, 1)
00068         self.assertEqual(doc1.getReferences(targetObject=doc2), [doc2])

Definition at line 93 of file test_ATReferences.py.

00093 
00094     def test_referencesAreSavedAndRestored2(self):
00095         # this case checks restoring a version with no refs, to a workin copy
00096         # with a ref, without using RetainATRefs
00097 
00098         repo = self.portal.portal_repository
00099         fol = self.portal.fol
00100         doc1 = self.portal.fol.doc1
00101         doc2 = self.portal.fol.doc2
00102 
00103         repo.applyVersionControl(doc1)
00104         repo.applyVersionControl(doc2)
00105 
00106         doc1.setTitle('v1')
00107         repo.save(doc1)
00108         doc1.addReference(doc2)
00109         self.assertEqual(doc1.getReferences(targetObject=doc2), [doc2])
00110         repo.revert(doc1, 1)
00111         self.failIf(doc1.getReferences(targetObject=doc2))
00112         # The above does not fail because ReferenceCatalog.getReferences calls
00113         # _resolveBrains after a catalog query to get the reference objects - so
00114         # the returned list is empty. But the reference_catalog still has the reference
00115         # indexed:
00116         rc = self.portal.reference_catalog
00117         self.failIf(rc(sourceUID=doc1.UID()))
00118         
00119         

Definition at line 22 of file test_ATReferences.py.

00022 
00023     def test_referencesDataGetSavedAndRestored(self):
00024         # this case checks restoring a version with a reference to
00025         # a working copy with no reference
00026         repo = self.portal.portal_repository
00027         fol = self.portal.fol
00028         doc1 = self.portal.fol.doc1
00029         doc2 = self.portal.fol.doc2
00030 
00031         repo.applyVersionControl(doc1)
00032         repo.applyVersionControl(doc2)
00033         relationship = 'dumb_relationship'
00034         doc1.addReference(doc2, relationship=relationship)
00035         doc1.setTitle('v1')
00036         repo.save(doc1)
00037         from Products.Archetypes.config import REFERENCE_ANNOTATION as \
00038              refs_container_name
00039         refs = getattr(doc1, refs_container_name).objectValues()
00040         doc1.deleteReference(doc2)
00041         should_be_empty_now = getattr(doc1, refs_container_name).objectValues()
00042         self.failIf(should_be_empty_now)
00043         repo.revert(doc1, 1)
00044         after_retrieve_refs = getattr(doc1, refs_container_name).objectValues()
00045         self.assertEqual(refs[0].targetUID, after_retrieve_refs[0].targetUID)
00046         self.assertEqual(refs[0].sourceUID, after_retrieve_refs[0].sourceUID)
00047         self.assertEqual(refs[0].relationship,
00048                          after_retrieve_refs[0].relationship)

Here is the call graph for this function:

Definition at line 69 of file test_ATReferences.py.

00069 
00070     def test_referencesDataGetSavedAndRestored2(self):
00071         # this case checks restoring a version with no refs, to a workin copy
00072         # with a ref, without using RetainATRefs
00073 
00074         repo = self.portal.portal_repository
00075         fol = self.portal.fol
00076         doc1 = self.portal.fol.doc1
00077         doc2 = self.portal.fol.doc2
00078 
00079         repo.applyVersionControl(doc1)
00080         repo.applyVersionControl(doc2)
00081         doc1.setTitle('v1')
00082         repo.save(doc1)
00083         relationship = 'dumb_relationship'
00084         doc1.addReference(doc2, relationship=relationship)
00085         doc1.setTitle('v2')
00086         from Products.Archetypes.config import REFERENCE_ANNOTATION as \
00087              refs_container_name
00088         refs = getattr(doc1, refs_container_name).objectValues()
00089 
00090         repo.revert(doc1, 1)
00091         should_be_empty_now = getattr(doc1, refs_container_name).objectValues()
00092         self.failIf(should_be_empty_now)

Here is the call graph for this function:

Definition at line 197 of file test_ATReferences.py.

00197 
00198     def test_refOnWorkingCopyArePreserved(self):
00199         repo = self.portal.portal_repository
00200         fol = self.portal.fol
00201         doc1 = self.portal.fol.doc1
00202         portal_modifier = self.portal.portal_modifier
00203         portal_modifier.edit("RetainATRefs",
00204                              enabled=True, 
00205                              condition="python: True")
00206         repo.applyVersionControl(doc1)
00207         doc1.addReference(fol)
00208         repo.save(doc1)
00209         repo.revert(doc1, 1)
00210         self.assertEqual([fol], doc1.getReferences())


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