From e671d7880674ddcdfc21a1306508d89c280ca939 Mon Sep 17 00:00:00 2001 From: Timo Stollenwerk Date: Thu, 4 Jun 2009 15:38:12 +0000 Subject: [PATCH] test for globally_enabled discussion added. svn path=/plone.app.discussion/trunk/; revision=27302 --- plone/app/discussion/browser/controlpanel.py | 2 +- .../app/discussion/tests/test_conversation.py | 31 +++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/plone/app/discussion/browser/controlpanel.py b/plone/app/discussion/browser/controlpanel.py index 8e74305..935cf84 100644 --- a/plone/app/discussion/browser/controlpanel.py +++ b/plone/app/discussion/browser/controlpanel.py @@ -32,7 +32,7 @@ class DiscussionSettingsControlPanel(controlpanel.ControlPanelFormWrapper): form = DiscussionSettingsEditForm class Utility(BrowserView): - """Utility view to determine if the site is currently styled with xdv + """Utility view to determine ... """ def globally_enabled(self): diff --git a/plone/app/discussion/tests/test_conversation.py b/plone/app/discussion/tests/test_conversation.py index 9d4e2d6..78decaa 100644 --- a/plone/app/discussion/tests/test_conversation.py +++ b/plone/app/discussion/tests/test_conversation.py @@ -1,16 +1,19 @@ import unittest from datetime import datetime, timedelta +from plone.registry import Registry + from zope.component import createObject -from Acquisition import aq_base, aq_parent +from Acquisition import aq_base, aq_parent, aq_inner from plone.app.vocabularies.types import BAD_TYPES +from Products.CMFCore.utils import getToolByName from Products.PloneTestCase.ptc import PloneTestCase from plone.app.discussion.tests.layer import DiscussionLayer -from plone.app.discussion.interfaces import IConversation, IComment, IReplies +from plone.app.discussion.interfaces import IConversation, IComment, IReplies, IDiscussionSettings class ConversationTest(PloneTestCase): @@ -21,6 +24,7 @@ class ConversationTest(PloneTestCase): self.loginAsPortalOwner() typetool = self.portal.portal_types typetool.constructContent('Document', self.portal, 'doc1') + self.portal_discussion = getToolByName(self.portal, 'portal_discussion', None) def test_add_comment(self): # Create a conversation. In this case we doesn't assign it to an @@ -458,6 +462,29 @@ class ConversationTest(PloneTestCase): def test_discussion_item_not_in_bad_types(self): self.failIf('Discussion Item' in BAD_TYPES) + def test_allow_discussion_globally(self): + + registry = Registry() + registry.register_interface(IDiscussionSettings) + globally_enabled_record = registry.records['plone.app.discussion.interfaces.IDiscussionSettings.globally_enabled'] + + # Check if a record for globally_enabled is in the registry + # with the correct default value (True). + self.failUnless('globally_enabled' in IDiscussionSettings) + self.assertEquals(registry['plone.app.discussion.interfaces.IDiscussionSettings.globally_enabled'], True) + + # Todo: Add a comment. Then set globally_enabled to false and check if + # comments are disabled. + + + def test_allow_discussion_for_content_type(self): + pass + + def test_allow_discussion_for_folder(self): + # Create a folder and two content types and check if they are + # commentable. + pass + class RepliesTest(PloneTestCase): # test the IReplies adapter on a conversation