Back to index

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

List of all members.

Public Member Functions

def getPortal
def createMemberarea
def loginAsPortalOwner
def addProfile
def addProduct

Static Public Attributes

 layer = layer.CMFSite

Private Member Functions

def _portal
def _setup
def _clear

Static Private Attributes

tuple __implements__

Detailed Description

Base test case for CMF testing

Definition at line 50 of file CMFTestCase.py.


Member Function Documentation

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

Definition at line 77 of file CMFTestCase.py.

00077 
00078     def _clear(self, call_close_hook=0):
00079         '''Clears the fixture.'''
00080         PortalTestCase._clear(self, call_close_hook)
00081         if CMF21:
00082             _placefulTearDown()

Here is the call graph for this function:

Here is the caller graph for this function:

Returns the portal object for a test.

Reimplemented in CMFTestCase.testInterfaces.TestFunctionalTestCase, and CMFTestCase.testInterfaces.TestCMFTestCase.

Definition at line 64 of file CMFTestCase.py.

00064 
00065     def _portal(self):
00066         '''Returns the portal object for a test.'''
00067         portal = self.getPortal()
00068         if CMF21:
00069             _placefulSetUp(portal)
00070         return portal

Here is the call graph for this function:

Configures the portal.

Definition at line 71 of file CMFTestCase.py.

00071 
00072     def _setup(self):
00073         '''Configures the portal.'''
00074         PortalTestCase._setup(self)
00075         if CMF21 and self.portal is not None:
00076             self._refreshSkinData()

Here is the call graph for this function:

Installs a product into the site.

Definition at line 145 of file CMFTestCase.py.

00145 
00146     def addProduct(self, name):
00147         '''Installs a product into the site.'''
00148         sm = getSecurityManager()
00149         self.loginAsPortalOwner()
00150         try:
00151             installed = getattr(self.portal, '_installed_products', {})
00152             if not installed.has_key(name):
00153                 exec 'from Products.%s.Extensions.Install import install' % (name,)
00154                 install(self.portal)
00155                 self._refreshSkinData()
00156         finally:
00157             setSecurityManager(sm)
00158 

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 123 of file CMFTestCase.py.

00123 
00124     def addProfile(self, name):
00125         '''Imports an extension profile into the site.'''
00126         sm = getSecurityManager()
00127         self.loginAsPortalOwner()
00128         try:
00129             installed = getattr(self.portal, '_installed_profiles', {})
00130             if not installed.has_key(name):
00131                 setup = self.portal.portal_setup
00132                 profile_id = 'profile-%s' % (name,)
00133                 if CMF21:
00134                     setup.runAllImportStepsFromProfile(profile_id)
00135                 else:
00136                     saved = setup.getImportContextID()
00137                     try:
00138                         setup.setImportContext(profile_id)
00139                         setup.runAllImportSteps()
00140                     finally:
00141                         setup.setImportContext(saved)
00142                 self._refreshSkinData()
00143         finally:
00144             setSecurityManager(sm)

Here is the call graph for this function:

Creates a minimal memberarea.

Definition at line 93 of file CMFTestCase.py.

00093 
00094     def createMemberarea(self, name):
00095         '''Creates a minimal memberarea.'''
00096         uf = self.portal.acl_users
00097         user = uf.getUserById(name)
00098         if user is None:
00099             raise ValueError, 'Member %s does not exist' % name
00100         if not hasattr(user, 'aq_base'):
00101             user = user.__of__(uf)
00102         pm = self.portal.portal_membership
00103         members = pm.getMembersFolder()
00104         members.manage_addPortalFolder(name)
00105         folder = pm.getHomeFolder(name)
00106         folder.changeOwnership(user)
00107         folder.__ac_local_roles__ = None
00108         folder.manage_setLocalRoles(name, ['Owner'])

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 85 of file CMFTestCase.py.

00085 
00086     def getPortal(self):
00087         '''Returns the portal object.
00088 
00089            Do not call this method! Use the self.portal
00090            attribute to access the portal object from tests.
00091         '''
00092         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 111 of file CMFTestCase.py.

00111 
00112     def loginAsPortalOwner(self):
00113         '''Use if - AND ONLY IF - you need to manipulate the
00114            portal object itself.
00115         '''
00116         uf = self.app.acl_users
00117         user = uf.getUserById(portal_owner)
00118         if not hasattr(user, 'aq_base'):
00119             user = user.__of__(uf)
00120         newSecurityManager(None, user)


Member Data Documentation

Initial value:
(ICMFTestCase, ICMFSecurity,
                          PortalTestCase.__implements__)

Reimplemented in CMFTestCase.CMFTestCase.FunctionalTestCase.

Definition at line 57 of file CMFTestCase.py.

Definition at line 62 of file CMFTestCase.py.


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