Back to index

plone3  3.1.7
testSyndicationTool.py
Go to the documentation of this file.
00001 #
00002 # SyndicationTool tests
00003 #
00004 
00005 from AccessControl import Unauthorized
00006 from Products.CMFPlone.tests import PloneTestCase
00007 
00008 
00009 class TestSyndicationTool(PloneTestCase.PloneTestCase):
00010 
00011     def afterSetUp(self):
00012         self.syndication = self.portal.portal_syndication
00013         self.folder.invokeFactory('Document','doc1')
00014         self.folder.invokeFactory('Document','doc2')
00015         self.doc1 = self.folder.doc1
00016         self.doc2 = self.folder.doc2
00017         #Enable syndication sitewide
00018         self.syndication.editProperties(isAllowed=True)
00019         #Enable syndication on folder
00020         self.syndication.enableSyndication(self.folder)
00021 
00022     def testIsSiteSyndicationAllowed(self):
00023         # Make sure isSiteSyndicationAllowed returns proper value so that tabs
00024         # appear
00025         self.failUnless(self.syndication.isSiteSyndicationAllowed())
00026         self.syndication.editProperties(isAllowed=False)
00027         self.failIf(self.syndication.isSiteSyndicationAllowed())
00028 
00029     def testIsSyndicationAllowed(self):
00030         # Make sure isSyndicationAllowed returns proper value so that the
00031         # action appears
00032         self.failUnless(self.syndication.isSyndicationAllowed(self.folder))
00033         self.syndication.disableSyndication(self.folder)
00034         self.failIf(self.syndication.isSyndicationAllowed(self.folder))
00035 
00036     def testGetSyndicatableContent(self):
00037         content = self.syndication.getSyndicatableContent(self.folder)
00038         self.assertEqual(len(content),2)
00039 
00040     def testOwnerCanEnableAndDisableSyndication(self):
00041         self.setRoles(['Owner'])
00042         self.syndication.disableSyndication(self.folder)
00043         self.failIf(self.syndication.isSyndicationAllowed(self.folder))
00044         self.syndication.enableSyndication(self.folder)
00045         self.failUnless(self.syndication.isSyndicationAllowed(self.folder))
00046         self.logout()
00047         self.assertRaises(Unauthorized, self.syndication.enableSyndication,
00048                           self.folder)
00049         self.assertRaises(Unauthorized, self.syndication.disableSyndication,
00050                           self.folder)
00051 
00052 
00053 def test_suite():
00054     from unittest import TestSuite, makeSuite
00055     suite = TestSuite()
00056     suite.addTest(makeSuite(TestSyndicationTool))
00057     return suite