Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes
PloneTestCase.testPloneTestCase.TestPloneTestCase Class Reference
Inheritance diagram for PloneTestCase.testPloneTestCase.TestPloneTestCase:
Inheritance graph
[legend]
Collaboration diagram for PloneTestCase.testPloneTestCase.TestPloneTestCase:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def afterSetUp
def testDefaultMemberarea
def testCreateMemberarea
def testSetRoles
def testSetRolesUser2
def testSetRolesAuthUser
def testSetGroups
def testSetGroupsUser2
def testSetGroupsAuthUser
def testSetGroups
def testSetGroupsUser2
def testSetGroupsAuthUser
def testAddDocument
def testEditDocument
def testPublishDocument
def testSkinScript
def testGetSite
def getPortal
def createMemberarea
def setRoles
def setGroups
def loginAsPortalOwner
def addProfile
def addProduct

Public Attributes

 membership
 catalog
 workflow
 groups

Static Public Attributes

 layer = layer.PloneSite

Detailed Description

Definition at line 27 of file testPloneTestCase.py.


Member Function Documentation

def PloneTestCase.PloneTestCase.PloneTestCase.addProduct (   self,
  name 
) [inherited]
Quickinstalls a product into the site.

Definition at line 156 of file PloneTestCase.py.

00156 
00157     def addProduct(self, name):
00158         '''Quickinstalls a product into the site.'''
00159         sm = getSecurityManager()
00160         self.loginAsPortalOwner()
00161         try:
00162             qi = self.portal.portal_quickinstaller
00163             if not qi.isProductInstalled(name):
00164                 qi.installProduct(name)
00165                 self._refreshSkinData()
00166         finally:
00167             setSecurityManager(sm)
00168 

Here is the call graph for this function:

Here is the caller graph for this function:

def PloneTestCase.PloneTestCase.PloneTestCase.addProfile (   self,
  name 
) [inherited]
Imports an extension profile into the site.

Definition at line 134 of file PloneTestCase.py.

00134 
00135     def addProfile(self, name):
00136         '''Imports an extension profile into the site.'''
00137         sm = getSecurityManager()
00138         self.loginAsPortalOwner()
00139         try:
00140             installed = getattr(self.portal, '_installed_profiles', {})
00141             if not installed.has_key(name):
00142                 setup = self.portal.portal_setup
00143                 profile_id = 'profile-%s' % (name,)
00144                 if PLONE30:
00145                     setup.runAllImportStepsFromProfile(profile_id)
00146                 else:
00147                     saved = setup.getImportContextID()
00148                     try:
00149                         setup.setImportContext(profile_id)
00150                         setup.runAllImportSteps()
00151                     finally:
00152                         setup.setImportContext(saved)
00153                 self._refreshSkinData()
00154         finally:
00155             setSecurityManager(sm)

Here is the call graph for this function:

Definition at line 29 of file testPloneTestCase.py.

00029 
00030     def afterSetUp(self):
00031         self.membership = self.portal.portal_membership
00032         self.catalog = self.portal.portal_catalog
00033         self.workflow = self.portal.portal_workflow
00034         self.groups = self.portal.portal_groups
00035         self.groups.groupWorkspacesCreationFlag = 0

def PloneTestCase.PloneTestCase.PloneTestCase.createMemberarea (   self,
  name 
) [inherited]
Creates a minimal memberarea.

Definition at line 96 of file PloneTestCase.py.

00096 
00097     def createMemberarea(self, name):
00098         '''Creates a minimal memberarea.'''
00099         _createHomeFolder(self.portal, name)

Here is the call graph for this function:

Here is the caller graph for this function:

Returns the portal object.

   Do not call this method! Use the self.portal
   attribute to access the portal object from tests.

Definition at line 88 of file PloneTestCase.py.

00088 
00089     def getPortal(self):
00090         '''Returns the portal object.
00091 
00092            Do not call this method! Use the self.portal
00093            attribute to access the portal object from tests.
00094         '''
00095         return getattr(self.app, portal_name)

Here is the caller graph for this function:

Use if - AND ONLY IF - you need to manipulate
   the portal object itself.

Definition at line 122 of file PloneTestCase.py.

00122 
00123     def loginAsPortalOwner(self):
00124         '''Use if - AND ONLY IF - you need to manipulate
00125            the portal object itself.
00126         '''
00127         uf = self.app.acl_users
00128         user = uf.getUserById(portal_owner)
00129         if not hasattr(user, 'aq_base'):
00130             user = user.__of__(uf)
00131         newSecurityManager(None, user)

def PloneTestCase.PloneTestCase.PloneTestCase.setGroups (   self,
  groups,
  name = default_user 
) [inherited]
Changes the user's groups.

Definition at line 112 of file PloneTestCase.py.

00112 
00113     def setGroups(self, groups, name=default_user):
00114         '''Changes the user's groups.'''
00115         uf = self.portal.acl_users
00116         if PLONE25:
00117             uf.userSetGroups(name, utils.makelist(groups))
00118         else:
00119             uf._updateUser(name, groups=utils.makelist(groups))
00120         if name == getSecurityManager().getUser().getId():
00121             self.login(name)

Here is the call graph for this function:

Here is the caller graph for this function:

def PloneTestCase.PloneTestCase.PloneTestCase.setRoles (   self,
  roles,
  name = default_user 
) [inherited]
Changes the user's roles.

Definition at line 102 of file PloneTestCase.py.

00102 
00103     def setRoles(self, roles, name=default_user):
00104         '''Changes the user's roles.'''
00105         uf = self.portal.acl_users
00106         if PLONE25:
00107             uf.userFolderEditUser(name, None, utils.makelist(roles), [])
00108         else:
00109             uf._updateUser(name, roles=utils.makelist(roles))
00110         if name == getSecurityManager().getUser().getId():
00111             self.login(name)

Here is the call graph for this function:

Definition at line 117 of file testPloneTestCase.py.

00117 
00118     def testAddDocument(self):
00119         self.folder.invokeFactory('Document', id='doc')
00120         self.failUnless('doc' in self.folder.objectIds())

Definition at line 41 of file testPloneTestCase.py.

00041 
00042     def testCreateMemberarea(self):
00043         self.membership.addMember('user2', 'secret', [], [])
00044         self.createMemberarea('user2')
00045         home = self.membership.getHomeFolder('user2')
00046         self.assertEqual(home.getOwner().getId(), 'user2')
00047         self.assertEqual(home.get_local_roles_for_userid('user2'), ('Owner',))
00048         self.assertEqual(home.get_local_roles_for_userid(default_user), ())
00049         self.failIf('index_html' in home.objectIds())

Here is the call graph for this function:

Definition at line 36 of file testPloneTestCase.py.

00036 
00037     def testDefaultMemberarea(self):
00038         self.assertEqual(self.folder.getOwner().getId(), default_user)
00039         self.assertEqual(self.folder.get_local_roles_for_userid(default_user), ('Owner',))
00040         self.failIf('index_html' in self.folder.objectIds())

Definition at line 121 of file testPloneTestCase.py.

00121 
00122     def testEditDocument(self):
00123         self.folder.invokeFactory('Document', id='doc')
00124         self.folder.doc.edit(text_format='plain', text='data')
00125         self.assertEqual(self.folder.doc.EditableBody(), 'data')

Definition at line 140 of file testPloneTestCase.py.

00140 
00141         def testGetSite(self):
00142             from zope.app.component.hooks import getSite
00143             self.failUnless(aq_base(getSite()) is aq_base(self.portal))
00144 

Here is the call graph for this function:

Definition at line 126 of file testPloneTestCase.py.

00126 
00127     def testPublishDocument(self):
00128         self.folder.invokeFactory('Document', id='doc')
00129         self.setRoles(['Reviewer'])
00130         self.workflow.doActionFor(self.folder.doc, 'publish')
00131         review_state = self.workflow.getInfoFor(self.folder.doc, 'review_state')
00132         self.assertEqual(review_state, 'published')
00133         self.assertEqual(len(self.catalog(getId='doc', review_state='published')), 1)

Here is the call graph for this function:

Definition at line 68 of file testPloneTestCase.py.

00068 
00069         def testSetGroups(self):
00070             self.groups.addGroup('Editors', [], [])
00071             self.setGroups(['Editors'])
00072             acl_user = self.portal.acl_users.getUserById(default_user)
00073                                                               # Auto group
00074             self.assertEqual(sortTuple(acl_user.getGroups()), ('AuthenticatedUsers', 'Editors'))
00075             self.assertEqual(sortTuple(acl_user.getRoles()), ('Authenticated', 'Member'))

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 95 of file testPloneTestCase.py.

00095 
00096         def testSetGroups(self):
00097             self.groups.addGroup('Editors', [], [])
00098             self.setGroups(['Editors'])
00099             acl_user = self.portal.acl_users.getUserById(default_user)
00100             self.assertEqual(sortTuple(acl_user.getGroups()), (PREFIX+'Editors',))
00101             self.assertEqual(sortTuple(acl_user.getRoles()), ('Authenticated', 'Member'))

Here is the call graph for this function:

Definition at line 85 of file testPloneTestCase.py.

00085 
00086         def testSetGroupsAuthUser(self):
00087             self.groups.addGroup('Editors', [], [])
00088             self.setGroups(['Editors'])
00089             auth_user = getSecurityManager().getUser()
00090                                                                # Auto group
00091             self.assertEqual(sortTuple(auth_user.getGroups()), ('AuthenticatedUsers', 'Editors'))
00092             self.assertEqual(sortTuple(auth_user.getRoles()), ('Authenticated', 'Member'))

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 110 of file testPloneTestCase.py.

00110 
00111         def testSetGroupsAuthUser(self):
00112             self.groups.addGroup('Editors', [], [])
00113             self.setGroups(['Editors'])
00114             auth_user = getSecurityManager().getUser()
00115             self.assertEqual(sortTuple(auth_user.getGroups()), (PREFIX+'Editors',))
00116             self.assertEqual(sortTuple(auth_user.getRoles()), ('Authenticated', 'Member'))

Here is the call graph for this function:

Definition at line 76 of file testPloneTestCase.py.

00076 
00077         def testSetGroupsUser2(self):
00078             self.membership.addMember('user2', 'secret', ['Member'], [])
00079             self.groups.addGroup('Editors', [], [])
00080             self.setGroups(['Editors'], 'user2')
00081             acl_user = self.portal.acl_users.getUserById('user2')
00082                                                               # Auto group
00083             self.assertEqual(sortTuple(acl_user.getGroups()), ('AuthenticatedUsers', 'Editors'))
00084             self.assertEqual(sortTuple(acl_user.getRoles()), ('Authenticated', 'Member'))

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 102 of file testPloneTestCase.py.

00102 
00103         def testSetGroupsUser2(self):
00104             self.membership.addMember('user2', 'secret', ['Member'], [])
00105             self.groups.addGroup('Editors', [], [])
00106             self.setGroups(['Editors'], 'user2')
00107             acl_user = self.portal.acl_users.getUserById('user2')
00108             self.assertEqual(sortTuple(acl_user.getGroups()), (PREFIX+'Editors',))
00109             self.assertEqual(sortTuple(acl_user.getRoles()), ('Authenticated', 'Member'))

Here is the call graph for this function:

Definition at line 50 of file testPloneTestCase.py.

00050 
00051     def testSetRoles(self):
00052         self.setRoles(['Manager'])
00053         acl_user = self.portal.acl_users.getUserById(default_user)
00054         self.assertEqual(sortTuple(acl_user.getRoles()), ('Authenticated', 'Manager'))

Here is the call graph for this function:

Definition at line 61 of file testPloneTestCase.py.

00061 
00062     def testSetRolesAuthUser(self):
00063         self.setRoles(['Manager'])
00064         auth_user = getSecurityManager().getUser()
00065         self.assertEqual(sortTuple(auth_user.getRoles()), ('Authenticated', 'Manager'))

Here is the call graph for this function:

Definition at line 55 of file testPloneTestCase.py.

00055 
00056     def testSetRolesUser2(self):
00057         self.membership.addMember('user2', 'secret', ['Member'], [])
00058         self.setRoles(['Manager'], 'user2')
00059         acl_user = self.portal.acl_users.getUserById('user2')
00060         self.assertEqual(sortTuple(acl_user.getRoles()), ('Authenticated', 'Manager'))

Here is the call graph for this function:

Definition at line 134 of file testPloneTestCase.py.

00134 
00135     def testSkinScript(self):
00136         self.folder.invokeFactory('Document', id='doc', title='Foo')
00137         self.assertEqual(self.folder.doc.TitleOrId(), 'Foo')


Member Data Documentation

Definition at line 31 of file testPloneTestCase.py.

Definition at line 33 of file testPloneTestCase.py.

Definition at line 65 of file PloneTestCase.py.

Definition at line 30 of file testPloneTestCase.py.

Definition at line 32 of file testPloneTestCase.py.


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