Back to index

plone3  3.1.7
testPloneTestCase.py
Go to the documentation of this file.
00001 #
00002 # Example PloneTestCase
00003 #
00004 
00005 from Products.CMFPlone.tests import PloneTestCase
00006 
00007 from Acquisition import aq_base
00008 
00009 
00010 class TestPloneTestCase(PloneTestCase.PloneTestCase):
00011 
00012     def afterSetUp(self):
00013         self.catalog = self.portal.portal_catalog
00014         self.workflow = self.portal.portal_workflow
00015         self.setupAuthenticator()
00016 
00017     def testAddDocument(self):
00018         self.failIf(self.catalog(id='new'))
00019         self.folder.invokeFactory('Document', id='new')
00020         self.failUnless(hasattr(aq_base(self.folder), 'new'))
00021         self.failUnless(self.catalog(id='new'))
00022 
00023     def testPublishDocument(self):
00024         self.folder.invokeFactory('Document', id='new')
00025         self.setRoles(['Reviewer'])
00026         self.workflow.doActionFor(self.folder.new, 'publish')
00027         self.assertEqual(self.workflow.getInfoFor(self.folder.new, 'review_state'), 'published')
00028         self.failUnless(self.catalog(id='new', review_state='published'))
00029 
00030     def testRetractDocument(self):
00031         self.folder.invokeFactory('Document', id='new')
00032         self.setRoles(['Reviewer'])
00033         self.workflow.doActionFor(self.folder.new, 'publish')
00034         self.assertEqual(self.workflow.getInfoFor(self.folder.new, 'review_state'), 'published')
00035         self.setRoles(['Member'])
00036         self.workflow.doActionFor(self.folder.new, 'retract')
00037         self.assertEqual(self.workflow.getInfoFor(self.folder.new, 'review_state'), 'visible')
00038 
00039     def testEditDocument(self):
00040         self.folder.invokeFactory('Document', id='new')
00041         self.assertEqual(self.folder.new.EditableBody(), '')
00042         self.folder.new.edit('plain', 'data', file='', safety_belt='')
00043         self.assertEqual(self.folder.new.EditableBody(), 'data')
00044 
00045     def testGetterSkinScript(self):
00046         self.folder.invokeFactory('Document', id='new', title='Foo')
00047         self.assertEqual(self.folder.new.TitleOrId(), 'Foo')
00048 
00049     def testSetterSkinScript(self):
00050         self.folder.invokeFactory('Document', id='new')
00051         self.assertEqual(self.folder.new.EditableBody(), '')
00052         self.folder.new.document_edit('plain', 'data', title='Foo')
00053         self.assertEqual(self.folder.new.EditableBody(), 'data')
00054 
00055 
00056 def test_suite():
00057     from unittest import TestSuite, makeSuite
00058     suite = TestSuite()
00059     suite.addTest(makeSuite(TestPloneTestCase))
00060     return suite