Run ConversationTest for dexterity types only if dexterity is installed.

This commit is contained in:
Timo Stollenwerk 2012-07-12 18:56:10 +02:00
parent 103c7323e7
commit 528e1a1434

View File

@ -24,6 +24,12 @@ from plone.app.discussion.interfaces import IComment
from plone.app.discussion.interfaces import IReplies
from plone.app.discussion.interfaces import IDiscussionSettings
try:
import plone.dexterity
DEXTERITY = True
except:
DEXTERITY = False
class ConversationTest(unittest.TestCase):
@ -728,11 +734,11 @@ class ConversationEnabledForDexterityTypesTest(unittest.TestCase):
typetool = self.portal.portal_types
typetool.constructContent('Document', self.portal, 'doc1')
from plone.dexterity.interfaces import IDexterityContent
interface.alsoProvides(
self.portal.doc1,
IDexterityContent)
if DEXTERITY:
from plone.dexterity.interfaces import IDexterityContent
interface.alsoProvides(
self.portal.doc1,
IDexterityContent)
def _makeOne(self, *args, **kw):
return self.portal.doc1.restrictedTraverse('@@conversation_view')
@ -748,33 +754,38 @@ class ConversationEnabledForDexterityTypesTest(unittest.TestCase):
document_fti.manage_changeProperties(allow_discussion=allow_discussion)
def test_conversation_is_not_enabled_by_default(self):
conversation = self._makeOne(self.portal.doc1)
self.assertFalse(conversation.enabled())
if DEXTERITY:
conversation = self._makeOne(self.portal.doc1)
self.assertFalse(conversation.enabled())
def test_conversation_is_not_enabled_by_default_on_portal_type(self):
self._globally_enable_discussion(True)
conversation = self._makeOne(self.portal.doc1)
self.assertFalse(conversation.enabled())
if DEXTERITY:
self._globally_enable_discussion(True)
conversation = self._makeOne(self.portal.doc1)
self.assertFalse(conversation.enabled())
def test_conversation_needs_to_be_enabled_globally_and_for_type(self):
self._globally_enable_discussion(True)
self._enable_discussion_on_portal_type('Document', True)
conversation = self._makeOne(self.portal.doc1)
self.assertTrue(conversation.enabled())
if DEXTERITY:
self._globally_enable_discussion(True)
self._enable_discussion_on_portal_type('Document', True)
conversation = self._makeOne(self.portal.doc1)
self.assertTrue(conversation.enabled())
def test_disable_discussion(self):
self._globally_enable_discussion(True)
self._enable_discussion_on_portal_type('Document', True)
self.portal.doc1.allow_discussion = False
conversation = self._makeOne(self.portal.doc1)
self.assertFalse(conversation.enabled())
if DEXTERITY:
self._globally_enable_discussion(True)
self._enable_discussion_on_portal_type('Document', True)
self.portal.doc1.allow_discussion = False
conversation = self._makeOne(self.portal.doc1)
self.assertFalse(conversation.enabled())
def test_enable_discussion(self):
self._globally_enable_discussion(True)
self._enable_discussion_on_portal_type('Document', True)
self.portal.doc1.allow_discussion = True
conversation = self._makeOne(self.portal.doc1)
self.assertTrue(conversation.enabled())
if DEXTERITY:
self._globally_enable_discussion(True)
self._enable_discussion_on_portal_type('Document', True)
self.portal.doc1.allow_discussion = True
conversation = self._makeOne(self.portal.doc1)
self.assertTrue(conversation.enabled())
class RepliesTest(unittest.TestCase):