Back to index

plone3  3.1.7
test_rssviewlet.py
Go to the documentation of this file.
00001 import unittest
00002 from plone.app.layout.viewlets.tests.base import ViewletsTestCase
00003 from plone.app.layout.links.viewlets import RSSViewlet
00004 
00005 from Products.CMFCore.utils import getToolByName
00006 
00007 class TestRSSViewletView(ViewletsTestCase):
00008     """
00009     Test the document by line viewlet
00010     """
00011     def afterSetUp(self):
00012         pass
00013 
00014     def test_RSSViewlet(self):
00015         syntool = getToolByName(self.portal, 'portal_syndication')
00016         if syntool.isSyndicationAllowed(self.portal):
00017             # make sure syndication is disabled
00018             self.loginAsPortalOwner()
00019             syntool.disableSyndication(self.portal)
00020             self.logout()
00021         request = self.app.REQUEST
00022         viewlet = RSSViewlet(self.portal, request, None, None)
00023         viewlet.update()
00024         result = viewlet.render()
00025         self.assertEquals(result.strip(), '')
00026         self.loginAsPortalOwner()
00027         syntool.enableSyndication(self.portal)
00028         self.logout()
00029         request = self.app.REQUEST
00030         viewlet = RSSViewlet(self.portal, request, None, None)
00031         viewlet.update()
00032         result = viewlet.render()
00033         self.failIf("<link" not in result)
00034         self.failIf("http://nohost/plone/RSS" not in result)
00035 
00036 
00037 def test_suite():
00038     suite = unittest.TestSuite()
00039     suite.addTest(unittest.makeSuite(TestRSSViewletView))
00040     return suite