Back to index

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

List of all members.

Public Member Functions

def afterSetUp
def testAddGroup
def testGetGroupById
def testGetBadGroupById
def testGroupByIdIsWrapped
def testEditGroup
def testEditBadGroup
def testRemoveGroups
def testListGroupIds
def testGetGroupsByUserId
def testGroupsByUserIdAreWrapped
def testListGroups
def testListedGroupsAreWrapped
def testSetGroupOwnership
def testWrapGroup
def testGetGroupInfo
def testGetGroupInfoAsAnonymous
def testGetBadGroupInfo
def beforeTearDown
def setRequestMethod
def getAuthenticator
def setupAuthenticator

Public Attributes

 membership
 acl_users
 groups

Detailed Description

Definition at line 18 of file testGroupsTool.py.


Member Function Documentation

Definition at line 20 of file testGroupsTool.py.

00020 
00021     def afterSetUp(self):
00022         self.membership = self.portal.portal_membership
00023         self.acl_users = self.portal.acl_users
00024         self.groups = self.portal.portal_groups
00025         self.groups.groupWorkspacesCreationFlag = 0
00026         self._trap_warning_output()
00027 
00028         if 'auto_group' in self.acl_users.objectIds():
00029             self.acl_users.manage_delObjects(['auto_group'])
00030 
00031         # Nuke Administators and Reviewers groups added in 2.1a2 migrations
00032         # (and any other migrated-in groups) to avoid test confusion
00033         self.groups.removeGroups(self.groups.listGroupIds())

Definition at line 153 of file testGroupsTool.py.

00153 
00154     def beforeTearDown(self):
00155         self._free_warning_output()
00156 

Here is the call 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 34 of file testGroupsTool.py.

00034 
00035     def testAddGroup(self):
00036         self.groups.addGroup('foo', [], [])
00037         self.assertEqual(self.groups.listGroupIds(), ['foo'])
00038         # No group workspace should have been created
00039         self.failIf(hasattr(aq_base(self.portal), self.groups.getGroupWorkspacesFolderId()))

Here is the call graph for this function:

Definition at line 64 of file testGroupsTool.py.

00064 
00065     def testEditBadGroup(self):
00066         # Error type depends on the user folder...
00067         try:
00068             self.groups.editGroup('foo', [], [])
00069         except KeyError:
00070             pass        # Ok, this is the wanted behaviour
00071         except ValueError:
00072             pass        # Ok, this is the wanted behaviour
00073         else:
00074             self.fail("Should have raised KeyError or ValueError")

Here is the call graph for this function:

Definition at line 56 of file testGroupsTool.py.

00056 
00057     def testEditGroup(self):
00058         self.groups.addGroup('foo', )
00059         self.groups.editGroup('foo', roles = ['Reviewer']) #, ['foo.com']) => no domains on groups
00060         g = self.groups.getGroupById('foo')
00061         self.assertEqual(sortTuple(g.getRoles()), ('Authenticated', 'Reviewer'))
00062         ##self.assertEqual(g.getDomains(), ('foo.com',))                  # No domains on groups
00063         ##self.assertEqual(g.getGroup()._getPassword(), 'secret')         # No password for groups

Here is the call graph for this function:

Definition at line 45 of file testGroupsTool.py.

00045 
00046     def testGetBadGroupById(self):
00047         g = self.groups.getGroupById('foo')
00048         self.assertEqual(g, None)

Definition at line 149 of file testGroupsTool.py.

00149 
00150     def testGetBadGroupInfo(self):
00151         info = self.groups.getGroupInfo('foo')
00152         self.assertEqual(info, None)

Definition at line 40 of file testGroupsTool.py.

00040 
00041     def testGetGroupById(self):
00042         self.groups.addGroup('foo', [], [])
00043         g = self.groups.getGroupById('foo')
00044         self.failIfEqual(g, None)

Definition at line 135 of file testGroupsTool.py.

00135 
00136     def testGetGroupInfo(self):
00137         self.groups.addGroup('foo', title='Foo', description='Bar', email='foo@foo.com')
00138         info = self.groups.getGroupInfo('foo')
00139         self.assertEqual(info.get('title'), 'Foo')
00140         self.assertEqual(info.get('description'), 'Bar')
00141         self.assertEqual(info.get('email'), None) # No email!

Definition at line 142 of file testGroupsTool.py.

00142 
00143     def testGetGroupInfoAsAnonymous(self):
00144         self.groups.addGroup('foo', title='Foo', description='Bar')
00145         self.logout()
00146         info = self.groups.restrictedTraverse('getGroupInfo')('foo')
00147         self.assertEqual(info.get('title'), 'Foo')
00148         self.assertEqual(info.get('description'), 'Bar')

Here is the call graph for this function:

Definition at line 87 of file testGroupsTool.py.

00087 
00088     def testGetGroupsByUserId(self):
00089         self.groups.addGroup('foo', [], [])
00090         self.acl_users.userSetGroups(default_user, groupnames=['foo'])
00091         gs = self.groups.getGroupsByUserId(default_user)
00092         self.assertEqual(gs[0].getId(), 'foo')

Definition at line 49 of file testGroupsTool.py.

00049 
00050     def testGroupByIdIsWrapped(self):
00051         self.groups.addGroup('foo', [], [])
00052         g = self.groups.getGroupById('foo')
00053         self.assertEqual(g.__class__.__name__, 'GroupData')
00054         self.assertEqual(g.aq_parent.__class__.__name__, 'PloneGroup')
00055         self.assertEqual(g.aq_parent.aq_parent.__class__.__name__, 'GroupManager')

Definition at line 93 of file testGroupsTool.py.

00093 
00094     def testGroupsByUserIdAreWrapped(self):
00095         self.groups.addGroup('foo', [], [])
00096         self.acl_users.userSetGroups(default_user, groupnames=['foo'])
00097         gs = self.groups.getGroupsByUserId(default_user)
00098         self.assertEqual(gs[0].__class__.__name__, 'GroupData')
00099         self.assertEqual(gs[0].aq_parent.__class__.__name__, 'PloneGroup')
00100         self.assertEqual(gs[0].aq_parent.aq_parent.__class__.__name__, 'GroupManager')

Definition at line 108 of file testGroupsTool.py.

00108 
00109     def testListedGroupsAreWrapped(self):
00110         self.groups.addGroup('foo', [], [])
00111         gs = self.groups.listGroups()
00112         self.assertEqual(gs[0].__class__.__name__, 'GroupData')
00113         self.assertEqual(gs[0].aq_parent.__class__.__name__, 'PloneGroup')
00114         self.assertEqual(gs[0].aq_parent.aq_parent.__class__.__name__, 'GroupManager')

Definition at line 80 of file testGroupsTool.py.

00080 
00081     def testListGroupIds(self):
00082         self.groups.addGroup('foo', [], [])
00083         self.groups.addGroup('bar', [], [])
00084         grps = self.groups.listGroupIds()
00085         grps.sort()
00086         self.assertEqual(grps, ['bar', 'foo'])

Definition at line 101 of file testGroupsTool.py.

00101 
00102     def testListGroups(self):
00103         self.groups.addGroup('foo', [], [])
00104         self.groups.addGroup('bar', [], [])
00105         gs = self.groups.listGroups()
00106         self.assertEqual(gs[0].getId(), 'bar')
00107         self.assertEqual(gs[1].getId(), 'foo')

Definition at line 75 of file testGroupsTool.py.

00075 
00076     def testRemoveGroups(self):
00077         self.groups.addGroup('foo', [], [])
00078         self.groups.removeGroups(['foo'])
00079         self.assertEqual(len(self.groups.listGroupIds()), 0)

Definition at line 115 of file testGroupsTool.py.

00115 
00116     def testSetGroupOwnership(self):
00117         self.groups.addGroup('foo', [], [])
00118         self.folder.invokeFactory('Document', 'doc')
00119         doc = self.folder.doc
00120         g = self.groups.getGroupById('foo')
00121         self.groups.setGroupOwnership(g, doc)
00122         self.assertEqual(doc.getOwnerTuple()[1], 'foo')
00123         self.assertEqual(doc.get_local_roles_for_userid('foo'), ('Owner',))
00124         # TODO: Initial creator still has Owner role. Is this a bug?
00125         self.assertEqual(doc.get_local_roles_for_userid(default_user), ('Owner',))

Definition at line 126 of file testGroupsTool.py.

00126 
00127     def testWrapGroup(self):
00128         self.groups.addGroup('foo', [], [])
00129         g = self.acl_users.getGroup('foo')
00130         self.assertEqual(g.__class__.__name__, 'PloneGroup')
00131         g = self.groups.wrapGroup(g)
00132         self.assertEqual(g.__class__.__name__, 'GroupData')
00133         self.assertEqual(g.aq_parent.__class__.__name__, 'PloneGroup')
00134         self.assertEqual(g.aq_parent.aq_parent.__class__.__name__, 'GroupManager')


Member Data Documentation

Definition at line 22 of file testGroupsTool.py.

Definition at line 23 of file testGroupsTool.py.

Definition at line 21 of file testGroupsTool.py.


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