Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
Archetypes.tests.test_copying.PortalCopyTests Class Reference
Inheritance diagram for Archetypes.tests.test_copying.PortalCopyTests:
Inheritance graph
[legend]
Collaboration diagram for Archetypes.tests.test_copying.PortalCopyTests:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def afterSetUp
def test_created_doc
def test_clone_portal
def test_copy_paste_portal
def test_cut_paste_portal
def test_copy_paste_sets_ownership
def test_copy_paste_resets_workflow
def test_cut_paste_preserves_workflow
def test_copy_handles_talkback_Items
def test_delete_handles_talkback_Items

Public Attributes

 newportal

Private Member Functions

def _test_doc

Private Attributes

 _image

Detailed Description

Definition at line 73 of file test_copying.py.


Member Function Documentation

def Archetypes.tests.test_copying.PortalCopyTests._test_doc (   self,
  doc 
) [private]

Definition at line 89 of file test_copying.py.

00089 
00090     def _test_doc(self, doc):
00091         bodyfield = doc.getField('body')
00092         imagefield = doc.getField('image')
00093 
00094         self.failUnlessEqual(doc.getContentType(), 'text/x-rst')
00095 
00096         self.failUnlessEqual(doc.getRawBody(), 'testdata')
00097         self.failUnless(doc.getImage().data, self._image)
00098 
00099         self.failUnless(bodyfield.getContentType(doc), 'text/x-rst')

Here is the caller graph for this function:

Definition at line 75 of file test_copying.py.

00075 
00076     def afterSetUp(self):
00077         ATSiteTestCase.afterSetUp(self)
00078         self.setRoles(['Manager',])
00079 
00080         imgpath = os.path.join(PACKAGE_HOME, os.pardir, 'tool.gif')
00081         self._image = open(imgpath).read()
00082 
00083         portal = self.portal
00084 
00085         portal.invokeFactory('DDocument', id='document')
00086         doc = portal.document
00087         doc.setBody('testdata', mimetype='text/x-rst')
00088         doc.setImage(self._image, mimetype='image/gif')

Here is the call graph for this function:

Definition at line 106 of file test_copying.py.

00106 
00107     def test_clone_portal(self):
00108         app = self.app
00109         user = app.acl_users.getUserById(portal_owner).__of__(app.acl_users)
00110         newSecurityManager(None, user)
00111         app.manage_clone(self.portal, 'newportal')
00112         noSecurityManager()
00113         transaction.savepoint(optimistic=True)
00114 
00115         self.failUnless(hasattr(aq_base(app), 'newportal'))
00116         self.newportal = app.newportal
00117         # check if we really have new portal!
00118         self.failIf(aq_base(self.newportal) is aq_base(self.portal))
00119         self.failIfEqual(aq_base(self.newportal), aq_base(self.portal))
00120 
00121         self.failUnless(hasattr(aq_base(self.newportal), 'document'))
00122         doc = self.newportal.document
00123         self._test_doc(doc)

Here is the call graph for this function:

Definition at line 256 of file test_copying.py.

00256 
00257     def test_copy_handles_talkback_Items(self):
00258         # We need to ensure that the manage_after* methods are called on
00259         # subobjects of non-folderish objects
00260         doc = self.portal.document
00261         dtool = self.portal.portal_discussion
00262         cat = self.portal.portal_catalog
00263 
00264         doc.allowDiscussion('1')
00265         tb = dtool.getDiscussionFor(doc)
00266         tb.createReply(title='Stupendous', text='silly', Creator='admin')
00267 
00268         # Creating the reply should have cataloged it in manage_afterAdd
00269         results = cat(Title='Stupendous')
00270         self.assertEqual(len(results), 1)
00271 
00272         cp = self.portal.manage_copyObjects(ids=['document'])
00273         self.folder.manage_pasteObjects(cp)
00274         doc_copy = self.folder.document
00275 
00276         tb = dtool.getDiscussionFor(doc_copy)
00277         self.failUnless(tb.hasReplies(doc_copy), "Discussion not copied")
00278 
00279         # Copying doc should have cataloged the reply in manage_afterClone
00280         results = cat(Title='Stupendous')
00281         self.assertEqual(len(results), 2)

Definition at line 124 of file test_copying.py.

00124 
00125     def test_copy_paste_portal(self):
00126         app = self.app
00127         user = app.acl_users.getUserById('portal_owner').__of__(app.acl_users)
00128         newSecurityManager(None, user)
00129         cp = app.manage_copyObjects(ids=[portal_name])
00130         app.manage_pasteObjects(cb_copy_data=cp)
00131 
00132         noSecurityManager()
00133         transaction.savepoint(optimistic=True)
00134 
00135         self.failUnless(hasattr(aq_base(self.app), 'copy_of_%s' % portal_name))
00136         self.newportal = getattr(self.app, 'copy_of_%s' % portal_name)
00137         # check if we really have new portal!
00138         self.failIf(aq_base(self.newportal) is aq_base(self.portal))
00139         self.failIfEqual(aq_base(self.newportal), aq_base(self.portal))
00140 
00141         self.failUnless(hasattr(aq_base(self.newportal), 'document'))
00142         doc = self.newportal.document
00143         self._test_doc(doc)

Here is the call graph for this function:

Definition at line 194 of file test_copying.py.

00194 
00195     def test_copy_paste_resets_workflow(self):
00196         # Copy/pasting a File should reset workflow to the default state
00197 
00198         # This test depends on the default wf, assume CMFDefault if plone
00199         # isn't present
00200         wf_tool = self.portal.portal_workflow
00201         if 'plone_workflow' in wf_tool.objectIds():
00202             wf_id = 'plone_workflow'
00203             def_state = 'visible'
00204         else:
00205             wf_id = 'default_workflow'
00206             def_state = 'private'
00207 
00208         wf_tool.setChainForPortalTypes(('DDocument',), (wf_id,))
00209         self.folder.invokeFactory('DDocument', id='test_file')
00210 
00211         file = self.folder.test_file
00212 
00213         self.assertEqual(wf_tool.getInfoFor(file, 'review_state'), def_state)
00214         wf_tool.doActionFor(file, 'publish')
00215         self.assertEqual(wf_tool.getInfoFor(file, 'review_state'),
00216                                                                  'published')
00217 
00218         cb = self.folder.manage_copyObjects(['test_file'])
00219         self.folder.manage_pasteObjects(cb)
00220 
00221         file_copy = self.folder.copy_of_test_file
00222         self.assertEqual(wf_tool.getInfoFor(file_copy, 'review_state'),
00223                                                                    def_state)

Definition at line 161 of file test_copying.py.

00161 
00162     def test_copy_paste_sets_ownership(self):
00163         # Copy/pasting a File should set new ownership including local roles
00164         # borrowed from CMFCore tests
00165 
00166         # First, add two users to the user folder, a member and a manager
00167         # and create a member area for the member
00168         uf = self.portal.acl_users
00169         uf._doAddUser('member', 'secret', ['Member'], [])
00170         uf._doAddUser('manager1', 'secret', ['Manager'], [])
00171         member = uf.getUser('member').__of__(uf)
00172         manager1 = uf.getUser('manager1').__of__(uf)
00173         self.portal.portal_membership.setMemberareaCreationFlag()
00174         self.portal.portal_membership.createMemberArea('member')
00175         member_area = self.portal.Members.member
00176 
00177         # Switch to the manager user context and plant a content item into
00178         # the member user's member area
00179         self.login('manager1')
00180         member_area.invokeFactory('DDocument', id='test_file')
00181 
00182         # Switch to "member" context now and try to copy and paste the
00183         # content item created by "manager1"
00184         self.login('member')
00185         cb = member_area.manage_copyObjects(['test_file'])
00186         member_area.manage_pasteObjects(cb)
00187 
00188         # Now test executable ownership and "owner" local role
00189         # "member" should have both.
00190         file_ob = member_area.copy_of_test_file
00191         self.assertEqual(aq_base(file_ob.getOwner().getId()), aq_base(member).getId())
00192         self.failUnless('Owner' in
00193                             file_ob.get_local_roles_for_userid('member'))

Here is the call graph for this function:

Definition at line 100 of file test_copying.py.

00100 
00101     def test_created_doc(self):
00102         portal = self.portal
00103         self.failUnless(portal, 'document')
00104         doc = portal.document
00105         self._test_doc(doc)

Here is the call graph for this function:

Definition at line 144 of file test_copying.py.

00144 
00145     def test_cut_paste_portal(self):
00146         app = self.app
00147         user = app.acl_users.getUserById(portal_owner).__of__(app.acl_users)
00148         newSecurityManager(None, user)
00149         cp = app.manage_cutObjects(ids=[portal_name])
00150         app.manage_pasteObjects(cb_copy_data=cp)
00151 
00152         noSecurityManager()
00153         transaction.savepoint(optimistic=True)
00154 
00155         self.failUnless(hasattr(aq_base(self.app), portal_name))
00156         self.newportal = getattr(self.app, portal_name)
00157 
00158         self.failUnless(hasattr(aq_base(self.newportal), 'document'))
00159         doc = self.newportal.document
00160         self._test_doc(doc)

Here is the call graph for this function:

Definition at line 224 of file test_copying.py.

00224 
00225     def test_cut_paste_preserves_workflow(self):
00226         # Cut/pasting a File should preserve workflow state
00227 
00228         # This test depends on the default wf, assume CMFDefault if plone
00229         # isn't present
00230         wf_tool = self.portal.portal_workflow
00231         if 'plone_workflow' in wf_tool.objectIds():
00232             wf_id = 'plone_workflow'
00233             def_state = 'visible'
00234         else:
00235             wf_id = 'default_workflow'
00236             def_state = 'private'
00237 
00238         wf_tool.setChainForPortalTypes(('DDocument',), (wf_id,))
00239         self.folder.invokeFactory('DDocument', id='test_file')
00240         self.folder.invokeFactory('Folder', id='sub')
00241 
00242         file = self.folder.test_file
00243 
00244         self.assertEqual(wf_tool.getInfoFor(file, 'review_state'), def_state)
00245         wf_tool.doActionFor(file, 'publish')
00246         self.assertEqual(wf_tool.getInfoFor(file, 'review_state'),
00247                                                                  'published')
00248 
00249         transaction.savepoint(optimistic=True)
00250         cb = self.folder.manage_cutObjects(['test_file'])
00251         self.folder.sub.manage_pasteObjects(cb)
00252 
00253         file_copy = self.folder.sub.test_file
00254         self.assertEqual(wf_tool.getInfoFor(file_copy, 'review_state'),
00255                                                                  'published')

Definition at line 283 of file test_copying.py.

00283 
00284     def test_delete_handles_talkback_Items(self):
00285         doc = self.portal.document
00286         dtool = self.portal.portal_discussion
00287         cat = self.portal.portal_catalog
00288 
00289         doc.allowDiscussion('1')
00290         tb = dtool.getDiscussionFor(doc)
00291         tb.createReply(title='Stupendous', text='silly', Creator='admin')
00292 
00293         # Creating the reply should have cataloged it in manage_afterAdd
00294         results = cat(Title='Stupendous')
00295         self.assertEqual(len(results), 1)
00296 
00297         self.portal.manage_delObjects(ids=['document'])
00298 
00299         # Deleting the doc should have removed the discussions from the
00300         # catalog
00301         results = cat(Title='Stupendous')
00302         self.assertEqual(len(results), 0)
00303 


Member Data Documentation

Definition at line 80 of file test_copying.py.

Definition at line 115 of file test_copying.py.


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