Back to index

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

List of all members.

Public Member Functions

def getPortal
def createMemberarea
def setRoles
def setGroups
def loginAsPortalOwner
def addProfile
def addProduct

Static Public Attributes

 layer = layer.PloneSite

Private Member Functions

def _portal
def _setup
def _clear

Static Private Attributes

tuple __implements__

Detailed Description

Base test case for Plone testing

Definition at line 53 of file PloneTestCase.py.


Member Function Documentation

def PloneTestCase.PloneTestCase.PloneTestCase._clear (   self,
  call_close_hook = 0 
) [private]
Clears the fixture.

Definition at line 80 of file PloneTestCase.py.

00080 
00081     def _clear(self, call_close_hook=0):
00082         '''Clears the fixture.'''
00083         PortalTestCase._clear(self, call_close_hook)
00084         if PLONE30:
00085             _placefulTearDown()

Here is the call graph for this function:

Returns the portal object for a test.

Reimplemented in PloneTestCase.testInterfaces.TestFunctionalTestCase, and PloneTestCase.testInterfaces.TestPloneTestCase.

Definition at line 67 of file PloneTestCase.py.

00067 
00068     def _portal(self):
00069         '''Returns the portal object for a test.'''
00070         portal = self.getPortal()
00071         if PLONE30:
00072             _placefulSetUp(portal)
00073         return portal

Here is the call graph for this function:

Configures the portal.

Definition at line 74 of file PloneTestCase.py.

00074 
00075     def _setup(self):
00076         '''Configures the portal.'''
00077         PortalTestCase._setup(self)
00078         if PLONE30 and self.portal is not None:
00079             self._refreshSkinData()

Here is the call graph for this function:

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:

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:

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 
)
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 
)
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:


Member Data Documentation

Initial value:
(IPloneTestCase, IPloneSecurity,
                          PortalTestCase.__implements__)

Reimplemented in PloneTestCase.PloneTestCase.FunctionalTestCase.

Definition at line 60 of file PloneTestCase.py.

Definition at line 65 of file PloneTestCase.py.


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