test for globally_enabled discussion added.

svn path=/plone.app.discussion/trunk/; revision=27302
This commit is contained in:
Timo Stollenwerk 2009-06-04 15:38:12 +00:00
parent ad8a7b4636
commit e671d78806
2 changed files with 30 additions and 3 deletions

View File

@ -32,7 +32,7 @@ class DiscussionSettingsControlPanel(controlpanel.ControlPanelFormWrapper):
form = DiscussionSettingsEditForm form = DiscussionSettingsEditForm
class Utility(BrowserView): class Utility(BrowserView):
"""Utility view to determine if the site is currently styled with xdv """Utility view to determine ...
""" """
def globally_enabled(self): def globally_enabled(self):

View File

@ -1,16 +1,19 @@
import unittest import unittest
from datetime import datetime, timedelta from datetime import datetime, timedelta
from plone.registry import Registry
from zope.component import createObject 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 plone.app.vocabularies.types import BAD_TYPES
from Products.CMFCore.utils import getToolByName
from Products.PloneTestCase.ptc import PloneTestCase from Products.PloneTestCase.ptc import PloneTestCase
from plone.app.discussion.tests.layer import DiscussionLayer 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): class ConversationTest(PloneTestCase):
@ -21,6 +24,7 @@ class ConversationTest(PloneTestCase):
self.loginAsPortalOwner() self.loginAsPortalOwner()
typetool = self.portal.portal_types typetool = self.portal.portal_types
typetool.constructContent('Document', self.portal, 'doc1') typetool.constructContent('Document', self.portal, 'doc1')
self.portal_discussion = getToolByName(self.portal, 'portal_discussion', None)
def test_add_comment(self): def test_add_comment(self):
# Create a conversation. In this case we doesn't assign it to an # 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): def test_discussion_item_not_in_bad_types(self):
self.failIf('Discussion Item' in BAD_TYPES) 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): class RepliesTest(PloneTestCase):
# test the IReplies adapter on a conversation # test the IReplies adapter on a conversation