Back to index

plone3  3.1.7
testS5.py
Go to the documentation of this file.
00001 
00002 from Products.CMFPlone.tests import PloneTestCase
00003 
00004 import transaction
00005 
00006 bad_ones = [
00007     "<p>Foo</p>",
00008     "<h5>Bar</h5><p>Foo</p>",    
00009     ]
00010 good_ones = [
00011     "<h2>Test</h2><p>Foo</p>",
00012     "<h1>Test</h1><p>Foo</p><h2>foo</h2><p>bar</p>",    
00013     ]
00014 
00015 
00016 class TestS5(PloneTestCase.PloneTestCase):
00017 
00018     def afterSetUp(self):
00019         self.folder.invokeFactory('Document', id='foo')
00020         self.ob = self.folder.restrictedTraverse('foo')
00021 
00022     def testNoHead(self):
00023         for bad in bad_ones:
00024             self.ob.setText(bad)
00025             view = self.ob.restrictedTraverse("@@presentation_view")
00026             assert view.enabled() == False
00027             del self.app.REQUEST.__annotations__
00028             self.ob.setPresentation(True)
00029             view = self.ob.restrictedTraverse("@@presentation_view")
00030             assert view.enabled() == False
00031             del self.app.REQUEST.__annotations__
00032             self.ob.setPresentation(False)
00033 
00034     def testHaveHead(self):
00035         for good in good_ones:
00036             self.ob.setText(good)
00037             view = self.ob.restrictedTraverse("@@presentation_view")
00038             assert view.enabled() == False
00039             del self.app.REQUEST.__annotations__
00040             self.ob.setPresentation(True)
00041             view = self.ob.restrictedTraverse("@@presentation_view")
00042             assert view.enabled() == True
00043             del self.app.REQUEST.__annotations__
00044             self.ob.setPresentation(False)
00045 
00046 def test_suite():
00047     from unittest import TestSuite, makeSuite
00048     suite = TestSuite()
00049     suite.addTest(makeSuite(TestS5))
00050     return suite