[CMF-checkins] CVS: Products/CMFDefault/tests - test_DiscussionTool.py:1.5

Yvo Schubbe y.2004_ at wcm-solutions.de
Tue Jul 13 14:21:25 EDT 2004


Update of /cvs-repository/Products/CMFDefault/tests
In directory cvs.zope.org:/tmp/cvs-serv16803/CMFDefault/tests

Modified Files:
	test_DiscussionTool.py 
Log Message:
Merged yuppie-collector119and201-branch:
- Fixed acquisition bug in getDiscussionFor. (Collector #119)
- Fixed acquisition bug in overrideDiscussionFor. (Collector #201)
- Some related cleanup.


=== Products/CMFDefault/tests/test_DiscussionTool.py 1.4 => 1.5 ===
--- Products/CMFDefault/tests/test_DiscussionTool.py:1.4	Mon Apr 26 08:14:18 2004
+++ Products/CMFDefault/tests/test_DiscussionTool.py	Tue Jul 13 14:21:24 2004
@@ -5,9 +5,48 @@
 from Interface.Verify import verifyClass
 
 from Products.CMFDefault.DiscussionTool import DiscussionTool
+from Products.CMFCore.tests.base.dummy import DummyFolder
+from Products.CMFCore.tests.base.dummy import DummySite
+from Products.CMFCore.tests.base.dummy import DummyTool
 
 
 class DiscussionToolTests(TestCase):
+
+    def setUp(self):
+        self.site = DummySite('site')
+        self.site._setObject( 'portal_discussion', DiscussionTool() )
+        self.site._setObject( 'portal_membership', DummyTool() )
+
+    def test_overrideDiscussionFor(self):
+        dtool = self.site.portal_discussion
+        foo = self.site._setObject( 'foo', DummyFolder() )
+        baz = foo._setObject( 'baz', DummyFolder() )
+
+        dtool.overrideDiscussionFor(foo, 1)
+        self.failUnless( hasattr(foo.aq_base, 'allow_discussion') )
+        try:
+            dtool.overrideDiscussionFor(baz, None)
+        except KeyError:
+            self.fail('CMF Collector issue #201 (acquisition bug): '
+                      'KeyError raised')
+        dtool.overrideDiscussionFor(foo, None)
+        self.failIf( hasattr(foo.aq_base, 'allow_discussion') )
+
+    def test_getDiscussionFor(self):
+        dtool = self.site.portal_discussion
+        foo = self.site._setObject( 'foo', DummyFolder() )
+        foo.allow_discussion = 1
+        baz = foo._setObject( 'baz', DummyFolder() )
+        baz.allow_discussion = 1
+
+        self.failIf( hasattr(foo.aq_base, 'talkback') )
+        talkback = dtool.getDiscussionFor(foo)
+        self.failUnless( hasattr(foo.aq_base, 'talkback') )
+        self.failIf( hasattr(baz.aq_base, 'talkback') )
+        talkback = dtool.getDiscussionFor(baz)
+        self.failUnless( hasattr(baz.aq_base, 'talkback'),
+                         'CMF Collector issue #119 (acquisition bug): '
+                         'talkback not created' )
 
     def test_interface(self):
         from Products.CMFCore.interfaces.portal_discussion \



More information about the CMF-checkins mailing list