Back to index

plone3  3.1.7
test_doctests.py
Go to the documentation of this file.
00001 from zope.testing import doctest
00002 from unittest import TestSuite
00003 
00004 from Testing.ZopeTestCase import FunctionalDocFileSuite
00005 from Products.PloneTestCase.PloneTestCase import FunctionalTestCase
00006 from Products.PloneTestCase.PloneTestCase import setupPloneSite
00007 
00008 setupPloneSite()
00009 
00010 OPTIONFLAGS = (doctest.ELLIPSIS |
00011                doctest.REPORT_ONLY_FIRST_FAILURE |
00012                doctest.NORMALIZE_WHITESPACE)
00013 
00014 class FolderTestCase(FunctionalTestCase):
00015     """base test case with convenience methods for all control panel tests"""
00016 
00017     def afterSetUp(self):
00018         super(FolderTestCase, self).afterSetUp()
00019         from Products.Five.testbrowser import Browser
00020         self.browser = Browser()
00021         
00022         self.uf = self.portal.acl_users
00023         self.uf.userFolderAddUser('root', 'secret', ['Manager'], [])
00024 
00025     def createDocuments(self, amount):
00026         self.setRoles(['Manager',])
00027         for i in xrange(1, amount + 1):
00028             self.portal.invokeFactory(id='testing-%d' % i, type_name='Document')
00029             document = getattr(self.portal, 'testing-%d' % i)
00030             document.setTitle('Testing %d' % i)
00031             document.setExcludeFromNav(True)
00032             document.reindexObject()
00033 
00034     def createFolder(self, id='new-folder'):
00035         self.setRoles(['Manager',])
00036         self.portal.invokeFactory(id=id, type_name='Folder')
00037         folder = getattr(self.portal, id)
00038         folder.setTitle('New Folder')
00039         folder.setExcludeFromNav(True)
00040         folder.reindexObject()
00041         
00042 
00043     def loginAsManager(self):
00044         """points the browser to the login screen and logs in as user root with Manager role."""
00045         self.browser.open('http://nohost/plone/')
00046         self.browser.getLink('Log in').click()
00047         self.browser.getControl('Login Name').value = 'root'
00048         self.browser.getControl('Password').value = 'secret'
00049         self.browser.getControl('Log in').click()
00050 
00051 def test_suite():
00052     tests = ['foldercontents.txt',]
00053     suite = TestSuite()
00054     for test in tests:
00055         suite.addTest(FunctionalDocFileSuite(test,
00056             optionflags=OPTIONFLAGS,
00057             package="plone.app.content.browser.tests",
00058             test_class=FolderTestCase))
00059     return suite