Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
CMFPlone.tests.testPloneTool.TestOwnershipStuff Class Reference
Inheritance diagram for CMFPlone.tests.testPloneTool.TestOwnershipStuff:
Inheritance graph
[legend]
Collaboration diagram for CMFPlone.tests.testPloneTool.TestOwnershipStuff:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def afterSetUp
def assertList
def testChangeOwnershipOf
def testChangeOwnershipOfWithTopAclUsers
def testChangeOwnershipOfKeepsOtherRoles
def testChangeOwnershipOfRecursive
def testGetOwnerName
def testGetInheritedLocalRoles
def testGetInheritedLocalRolesMultiLevel
def setRequestMethod
def getAuthenticator
def setupAuthenticator

Public Attributes

 utils
 membership
 folder1
 folder2
 folder3

Detailed Description

Definition at line 169 of file testPloneTool.py.


Member Function Documentation

Definition at line 171 of file testPloneTool.py.

00171 
00172     def afterSetUp(self):
00173         self.utils = self.portal.plone_utils
00174         self.membership = self.portal.portal_membership
00175         self.membership.addMember('new_owner', 'secret', ['Member'], [])
00176         self.folder.invokeFactory('Folder', 'folder1')
00177         self.folder1 = self.folder.folder1
00178         self.folder1.invokeFactory('Folder', 'folder2')
00179         self.folder2 = self.folder1.folder2
00180         self.folder2.invokeFactory('Folder', 'folder3')
00181         self.folder3 = self.folder2.folder3

def CMFPlone.tests.testPloneTool.TestOwnershipStuff.assertList (   self,
  result,
  expect 
)

Definition at line 182 of file testPloneTool.py.

00182 
00183     def assertList(self, result, expect):
00184         # Verifies lists have the same contents
00185         lhs = [r for r in result]
00186         lhs.sort()
00187         rhs = list(expect)
00188         rhs.sort()
00189         self.assertEqual(lhs, rhs)

Here is the caller graph for this function:

Definition at line 30 of file PloneTestCase.py.

00030 
00031     def getAuthenticator(self):
00032         tag = AuthenticatorView('context', 'request').authenticator()
00033         pattern = '<input .*name="(\w+)".*value="(\w+)"'
00034         return match(pattern, tag).groups()

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFPlone.tests.PloneTestCase.PloneTestCase.setRequestMethod (   self,
  method 
) [inherited]
This is a stub now, but in case you want to try
   something fancy on Your Branch (tm), put it here.

Definition at line 26 of file PloneTestCase.py.

00026 
00027     def setRequestMethod(self, method):
00028         self.app.REQUEST.set('REQUEST_METHOD', method)
00029         self.app.REQUEST.method = method

Here is the caller graph for this function:

Definition at line 35 of file PloneTestCase.py.

00035 
00036     def setupAuthenticator(self):
00037         name, token = self.getAuthenticator()
00038         self.app.REQUEST.form[name] = token
00039 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 190 of file testPloneTool.py.

00190 
00191     def testChangeOwnershipOf(self):
00192         # Should take ownership
00193         self.assertEqual(self.folder1.getOwnerTuple()[1], default_user)
00194         self.assertList(self.folder1.get_local_roles_for_userid(default_user),
00195                         ['Owner'])
00196 
00197         self.utils.changeOwnershipOf(self.folder1, 'new_owner')
00198         self.assertEqual(self.folder1.getOwnerTuple()[1], 'new_owner')
00199         self.assertList(self.folder1.get_local_roles_for_userid('new_owner'),
00200                         ['Owner'])
00201 
00202         # Initial creator no longer has Owner role.
00203         self.assertList(self.folder1.get_local_roles_for_userid(default_user), [])

Here is the call graph for this function:

Definition at line 215 of file testPloneTool.py.

00215 
00216     def testChangeOwnershipOfKeepsOtherRoles(self):
00217         # Should preserve roles other than Owner
00218         self.folder1.manage_addLocalRoles('new_owner', ('Reviewer',))
00219         self.assertList(self.folder1.get_local_roles_for_userid('new_owner'),
00220                         ['Reviewer'])
00221         self.utils.changeOwnershipOf(self.folder1, 'new_owner')
00222         self.assertEqual(self.folder1.getOwnerTuple()[1], 'new_owner')
00223         self.assertList(self.folder1.get_local_roles_for_userid('new_owner'),
00224                         ['Owner', 'Reviewer'])
00225         self.assertList(self.folder1.get_local_roles_for_userid(default_user), [])

Here is the call graph for this function:

Definition at line 226 of file testPloneTool.py.

00226 
00227     def testChangeOwnershipOfRecursive(self):
00228         # Should take ownership of subobjects as well
00229         self.utils.changeOwnershipOf(self.folder1, 'new_owner', recursive=1)
00230         self.assertEqual(self.folder1.getOwnerTuple()[1], 'new_owner')
00231         self.assertList(self.folder1.get_local_roles_for_userid('new_owner'),
00232                         ['Owner'])
00233         self.assertList(self.folder1.get_local_roles_for_userid(default_user), [])
00234         self.assertEqual(self.folder2.getOwnerTuple()[1], 'new_owner')
00235         self.assertList(self.folder2.get_local_roles_for_userid('new_owner'),
00236                         ['Owner'])
00237         self.assertList(self.folder2.get_local_roles_for_userid(default_user), [])
00238         self.assertEqual(self.folder3.getOwnerTuple()[1], 'new_owner')
00239         self.assertList(self.folder3.get_local_roles_for_userid('new_owner'),
00240                         ['Owner'])
00241         self.assertList(self.folder3.get_local_roles_for_userid(default_user), [])

Here is the call graph for this function:

Definition at line 204 of file testPloneTool.py.

00204 
00205     def testChangeOwnershipOfWithTopAclUsers(self):
00206         # Should be able to give ownership to a user in the top level
00207         # acl_users folder (even if this is not offered TTW).
00208         self.utils.changeOwnershipOf(self.folder1, 'portal_owner')
00209         self.assertEqual(self.folder1.getOwnerTuple()[1], 'portal_owner')
00210         self.assertList(self.folder1.get_local_roles_for_userid('portal_owner'),
00211                         ['Owner'])
00212 
00213         # Initial creator no longer has Owner role.
00214         self.assertList(self.folder1.get_local_roles_for_userid(default_user), [])

Here is the call graph for this function:

Definition at line 248 of file testPloneTool.py.

00248 
00249     def testGetInheritedLocalRoles(self):
00250         # Test basic local roles acquisition is dealt with by
00251         # getInheritedLocalRoles
00252         gILR = self.utils.getInheritedLocalRoles
00253         self.folder1.manage_addLocalRoles('new_owner', ('Reviewer',))
00254         # Test Normal role acquisition is returned
00255         filtered_roles = [r for r in gILR(self.folder2) if r[0] == 'new_owner'][0]
00256         self.assertList(filtered_roles[1], ['Reviewer'])
00257         filtered_roles = [r for r in gILR(self.folder3) if r[0] == 'new_owner'][0]
00258         self.assertList(filtered_roles[1], ['Reviewer'])

Here is the call graph for this function:

Definition at line 259 of file testPloneTool.py.

00259 
00260     def testGetInheritedLocalRolesMultiLevel(self):
00261         # Test for http://dev.plone.org/plone/ticket/3901
00262         # make sure local roles are picked up from all folders in tree.
00263         gILR = self.utils.getInheritedLocalRoles
00264         self.folder1.manage_addLocalRoles('new_owner', ('Reviewer',))
00265         self.folder2.manage_addLocalRoles('new_owner', ('Owner',))
00266 
00267         # folder2 should have only the inherited role
00268         filtered_roles = [r for r in gILR(self.folder2) if r[0] == 'new_owner'][0]
00269         self.assertList(filtered_roles[1], ['Reviewer'])
00270 
00271         # folder3 should have roles inherited from parent and grand-parent
00272         filtered_roles = [r for r in gILR(self.folder3) if r[0] == 'new_owner'][0]
00273         self.assertList(filtered_roles[1], ['Owner','Reviewer'])
00274 

Here is the call graph for this function:

Definition at line 242 of file testPloneTool.py.

00242 
00243     def testGetOwnerName(self):
00244         # Test that getOwnerName gets the Owner name
00245         self.assertEqual(self.utils.getOwnerName(self.folder1), default_user)
00246         self.utils.changeOwnershipOf(self.folder1, 'new_owner')
00247         self.assertEqual(self.utils.getOwnerName(self.folder1), 'new_owner')


Member Data Documentation

Definition at line 176 of file testPloneTool.py.

Definition at line 178 of file testPloneTool.py.

Definition at line 180 of file testPloneTool.py.

Definition at line 173 of file testPloneTool.py.

Definition at line 172 of file testPloneTool.py.


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