Back to index

plone3  3.1.7
cptc.py
Go to the documentation of this file.
00001 """Base class for control panel test cases.
00002 
00003 This is in a separate module because it's potentially useful to other
00004 packages which register controlpanels. They should be able to import it
00005 without the PloneTestCase.setupPloneSite() side effects.
00006 """
00007 
00008 from Products.PloneTestCase.PloneTestCase import FunctionalTestCase
00009 from Products.Five.testbrowser import Browser
00010 from Products.CMFCore.utils import getToolByName
00011 
00012 class ControlPanelTestCase(FunctionalTestCase):
00013     """base test case with convenience methods for all control panel tests"""
00014 
00015     def afterSetUp(self):
00016         super(ControlPanelTestCase, self).afterSetUp()
00017                 
00018         self.browser = Browser()
00019         
00020         self.uf = self.portal.acl_users
00021         self.uf.userFolderAddUser('root', 'secret', ['Manager'], [])
00022         
00023         self.ptool = getToolByName(self.portal, 'portal_properties')
00024         self.site_props = self.ptool.site_properties
00025 
00026     def loginAsManager(self, user='root', pwd='secret'):
00027         """points the browser to the login screen and logs in as user root with Manager role."""
00028         self.browser.open('http://nohost/plone/')
00029         self.browser.getLink('Log in').click()
00030         self.browser.getControl('Login Name').value = user
00031         self.browser.getControl('Password').value = pwd
00032         self.browser.getControl('Log in').click()