Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
plone.app.iterate.tests.test_iterate.TestIterations Class Reference

List of all members.

Public Member Functions

def afterSetUp
def beforeTearDown
def shim_test
def test_workflowState
def test_baselineVersionCreated
def test_wcNewForwardReferencesCopied
def test_wcNewBackwardReferencesCopied
def test_baselineReferencesMaintained
def test_baselineNoCopyReferences

Public Attributes

 repo
 wf

Detailed Description

Definition at line 39 of file test_iterate.py.


Member Function Documentation

Definition at line 41 of file test_iterate.py.

00041 
00042     def afterSetUp(self):
00043         self.setRoles(['Manager',])
00044         
00045         # Since we depend on ZCML being loaded, we can't do this
00046         # until the layer is set up
00047         
00048         self.portal.portal_quickinstaller.installProduct('plone.app.iterate')
00049 
00050         # add a folder with two documents in it
00051         self.portal.invokeFactory('Folder', 'docs')
00052         self.portal.docs.invokeFactory('Document', 'doc1')
00053         self.portal.docs.invokeFactory('Document', 'doc2')
00054 
00055         # add a working copy folder
00056         self.portal.invokeFactory('Folder', 'workarea')
00057 
00058         self.repo = self.portal.portal_repository
00059         self.wf   = self.portal.portal_workflow

Here is the call graph for this function:

Definition at line 60 of file test_iterate.py.

00060 
00061     def beforeTearDown(self):
00062         self.repo = None
00063         self.wf   = None

Definition at line 64 of file test_iterate.py.

00064 
00065     def shim_test( self, test_method):
00066 
00067         try:
00068             test_method()
00069         except:
00070             import sys, pdb, traceback
00071             ec, e, tb = sys.exc_info()
00072             traceback.print_exc()            
00073             pdb.post_mortem( tb )

Definition at line 157 of file test_iterate.py.

00157 
00158     def test_baselineNoCopyReferences( self ):
00159         # ensure that custom state is maintained with the no copy adapter
00160 
00161         # setup the named ref adapter
00162         from zope import component
00163         from Products.Archetypes.interfaces import IBaseObject
00164         from plone.app.iterate import relation, interfaces
00165         from plone.app.iterate.tests.utils import CustomReference
00166         
00167         component.provideAdapter( 
00168             adapts = (IBaseObject,),
00169             provides = interfaces.ICheckinCheckoutReference,
00170             factory = relation.NoCopyReferenceAdapter,
00171             name="zebra")
00172 
00173         doc = self.portal.docs.doc1
00174         ref = doc.addReference( self.portal.docs, "zebra", referenceClass=CustomReference )
00175         ref.custom_state = "hello world"
00176 
00177         wc = ICheckinCheckoutPolicy( doc ).checkout( self.portal.workarea )
00178 
00179         self.assertEqual( len(wc.getReferences("zebra")), 0)
00180 
00181         doc = ICheckinCheckoutPolicy( wc ).checkin( "updated" )
00182 
00183         self.assertEqual( len(doc.getReferences("zebra")), 1)
00184 
00185         ref = doc.getReferenceImpl("zebra")[0]
00186 
00187         self.assert_( hasattr( ref, "custom_state") )
00188         self.assertEqual( ref.custom_state, "hello world")
00189 

Definition at line 142 of file test_iterate.py.

00142 
00143     def test_baselineReferencesMaintained( self ):
00144         # ensure that baseline references are maintained when the object is checked in
00145         # copies forward, bkw are not copied, but are maintained.
00146 
00147         doc = self.portal.docs.doc1
00148         doc.addReference( self.portal.docs, "elephant" )
00149         self.portal.docs.doc2.addReference( doc )
00150 
00151         wc = ICheckinCheckoutPolicy( doc ).checkout( self.portal.workarea )
00152 
00153         doc = ICheckinCheckoutPolicy( wc ).checkin( "updated" )
00154 
00155         self.assertEqual( len(doc.getReferences()), 1 )
00156         self.assertEqual( len(doc.getBackReferences()), 1 )

Definition at line 99 of file test_iterate.py.

00099 
00100     def test_baselineVersionCreated( self ):
00101         # if a baseline has no version ensure that one is created on checkout
00102 
00103         doc = self.portal.docs.doc1
00104         self.assertTrue( self.repo.isVersionable( doc ) )
00105 
00106         history = self.repo.getHistory( doc )
00107         self.assertEqual( len(history), 0 )
00108 
00109         ICheckinCheckoutPolicy( doc ).checkout( self.portal.workarea )
00110 
00111         history = self.repo.getHistory( doc )
00112         self.assertEqual( len(history), 1 )
00113 
00114         doc2 = self.portal.docs.doc2
00115         self.repo.save( doc2 )
00116 
00117         ICheckinCheckoutPolicy( doc2 ).checkout( self.portal.workarea )
00118 
00119         history = self.repo.getHistory( doc2 )
00120         self.assertEqual( len(history), 1 )
    

Definition at line 131 of file test_iterate.py.

00131 
00132     def test_wcNewBackwardReferencesCopied( self ):
00133         # ensure that new wc back references are copied back to the baseline on checkin
00134 
00135         doc = self.portal.docs.doc1
00136         self.assertEqual( len(doc.getBackReferences("zebra")), 0)
00137         wc = ICheckinCheckoutPolicy( doc ).checkout( self.portal.workarea )
00138         self.portal.docs.doc2.addReference( wc, "zebra")
00139         self.assertEqual( len( wc.getBackReferences("zebra")), 1 )        
00140         doc = ICheckinCheckoutPolicy( wc ).checkin( "updated")
00141         self.assertEqual( len( doc.getBackReferences("zebra")), 1 )

Definition at line 121 of file test_iterate.py.

00121 
00122     def test_wcNewForwardReferencesCopied( self ):
00123         # ensure that new wc references are copied back to the baseline on checkin
00124         doc = self.portal.docs.doc1
00125         doc.addReference( self.portal.docs )
00126         self.assertEqual( len(doc.getReferences("zebra")), 0)
00127         wc = ICheckinCheckoutPolicy( doc ).checkout( self.portal.workarea )
00128         wc.addReference( self.portal.docs.doc2, "zebra")        
00129         doc = ICheckinCheckoutPolicy( wc ).checkin( "updated" )
00130         self.assertEqual( len(doc.getReferences("zebra")), 1 )
        

Definition at line 74 of file test_iterate.py.

00074 
00075     def test_workflowState( self ):
00076         # ensure baseline workflow state is retained on checkin, including security
00077 
00078         doc = self.portal.docs.doc1
00079         
00080         # sanity check that owner can edit visible docs
00081         self.setRoles(['Owner',])
00082         self.assertTrue( getSecurityManager().checkPermission( "Modify portal content",
00083                                                                self.portal.docs.doc1 ) )
00084 
00085         self.setRoles(['Manager',])        
00086         self.wf.doActionFor( doc, 'publish')
00087         state = self.wf.getInfoFor( doc, 'review_state')
00088         
00089         self.repo.save( doc )
00090         wc = ICheckinCheckoutPolicy( doc ).checkout( self.portal.workarea )
00091         wc_state = self.wf.getInfoFor( wc, 'review_state')
00092         
00093         self.assertNotEqual( state, wc_state )
00094 
00095         ICheckinCheckoutPolicy( wc ).checkin( "modified" )
00096         bstate = self.wf.getInfoFor( wc, 'review_state')
00097         self.assertEqual( state, bstate )
00098         self.setRoles(['Owner',])       

Here is the call graph for this function:


Member Data Documentation

Definition at line 57 of file test_iterate.py.

Definition at line 58 of file test_iterate.py.


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