products/CPSRSS

changeset 236:245fa28df4da

Factorized container creation
author Georges Racinet on purity.racinet.fr <georges@racinet.fr>
date Sun, 05 Dec 2010 04:20:58 +0100
parents 46f0fc29b4e8
children c3313b2c9e08
files RSSChannelContainer.py tests/test_rss.py
diffstat 2 files changed, 14 insertions(+), 10 deletions(-) [+]
line diff
     1.1 --- a/RSSChannelContainer.py
     1.2 +++ b/RSSChannelContainer.py
     1.3 @@ -122,3 +122,11 @@
     1.4  InitializeClass(RSSChannelContainer)
     1.5  
     1.6  
     1.7 +def addRSSChannelContainer(folder, cid='.cps_rss'):
     1.8 +    """Add a channel container in folder and return it.
     1.9 +
    1.10 +    This does not redirect to a ZMI URL like addRSSChannel does in case a
    1.11 +    request would be provided, because ZMI would not the only UI.
    1.12 +    """
    1.13 +    folder._setObject(cid, RSSChannelContainer(cid))
    1.14 +    return folder[cid]
     2.1 --- a/tests/test_rss.py
     2.2 +++ b/tests/test_rss.py
     2.3 @@ -3,10 +3,11 @@
     2.4  import unittest, os.path
     2.5  
     2.6  from OFS.Folder import Folder
     2.7 -from CPSRSSTestCase import CPSRSSTestCase
     2.8 -from CPSRSSTestCase import ZopeRSSTestCase
     2.9 +from basetests import CPSRSSTestCase
    2.10 +from basetests import ZopeRSSTestCase
    2.11  
    2.12  from Products.CPSRSS.RSSChannelContainer import RSSChannelContainer
    2.13 +from Products.CPSRSS.RSSChannelContainer import addRSSChannelContainer
    2.14  
    2.15  def get_feed_url(feed_file):
    2.16      return os.path.abspath(os.path.join(os.path.dirname(__file__), feed_file))
    2.17 @@ -15,14 +16,9 @@
    2.18  class TestRSS(object):
    2.19  
    2.20      def localContainer(self):
    2.21 -        """Depends on subclass."""
    2.22 +        """Provided by subclasses."""
    2.23          raise NotImplementedError
    2.24  
    2.25 -    def _localContainer(self, folder):
    2.26 -        """Common code called by subclass."""
    2.27 -        folder._setObject('.cps_rss', RSSChannelContainer('.cps_rss'))
    2.28 -        return folder['.cps_rss']
    2.29 -
    2.30      def testEmptyTool(self):
    2.31          rss_tool = self.tool
    2.32          self.assertEquals(rss_tool.meta_type, 'RSS Tool')
    2.33 @@ -86,7 +82,7 @@
    2.34      """Run the tests in a full CPS portal context."""
    2.35  
    2.36      def localContainer(self):
    2.37 -        return self._localContainer(self.portal.workspaces)
    2.38 +        return addRSSChannelContainer(self.portal.workspaces)
    2.39  
    2.40  
    2.41  class ZopeTestRSS(TestRSS, ZopeRSSTestCase):
    2.42 @@ -94,7 +90,7 @@
    2.43  
    2.44      def localContainer(self):
    2.45          self.folder._setObject('subfold', Folder('subfold'))
    2.46 -        return self._localContainer(self.folder.subfold)
    2.47 +        return addRSSChannelContainer(self.folder.subfold)
    2.48  
    2.49  
    2.50  def test_suite():