This commit is contained in:
tisto 2012-01-14 07:26:01 +01:00
parent a3883d7e7b
commit 0558a9b739
5 changed files with 45 additions and 40 deletions

View File

@ -58,8 +58,8 @@ COMMENT_DESCRIPTION_MARKDOWN = _(
COMMENT_DESCRIPTION_INTELLIGENT_TEXT = _(
u"comment_description_intelligent_text",
default=u"You can add a comment by filling out the form below. " +
"Plain text formatting. Web and email addresses are transformed " +
"into clickable links.")
"Plain text formatting. Web and email addresses are " +
"transformed into clickable links.")
COMMENT_DESCRIPTION_MODERATION_ENABLED = _(
u"comment_description_moderation_enabled",
@ -113,8 +113,8 @@ class CommentForm(extensible.ExtensibleForm, form.Form):
member_email = member.getProperty('email')
# Hide the user_notification checkbox if user notification is disabled
# or the user is not logged in. Also check if the user has a valid email
# address
# or the user is not logged in. Also check if the user has a valid
# email address
if member_email == '' or \
not settings.user_notification_enabled or \
mtool.isAnonymousUser():
@ -185,7 +185,8 @@ class CommentForm(extensible.ExtensibleForm, form.Form):
comment.author_name = author_name
comment.author_email = author_email
comment.user_notification = user_notification
comment.creation_date = comment.modification_date = datetime.utcnow()
comment.creation_date = datetime.utcnow()
comment.modification_date = datetime.utcnow()
elif not portal_membership.isAnonymousUser() and can_reply:
# Member
member = portal_membership.getAuthenticatedMember()
@ -204,7 +205,8 @@ class CommentForm(extensible.ExtensibleForm, form.Form):
comment.author_name = fullname
comment.author_email = email
comment.user_notification = user_notification
comment.creation_date = comment.modification_date = datetime.utcnow()
comment.creation_date = datetime.utcnow()
comment.modification_date = datetime.utcnow()
else: # pragma: no cover
raise Unauthorized("Anonymous user tries to post a comment, but "
"anonymous commenting is disabled. Or user does not have the "

View File

@ -167,7 +167,7 @@ class ConversationCatalogTest(unittest.TestCase):
brains = self.catalog.searchResults(dict(
path={'query':
'/'.join(self.portal.doc1.getPhysicalPath()) },
'/'.join(self.portal.doc1.getPhysicalPath())},
portal_type="Document"
))
doc1_brain = brains[0]
@ -178,7 +178,7 @@ class ConversationCatalogTest(unittest.TestCase):
del self.conversation[new_comment2_id]
brains = self.catalog.searchResults(dict(
path={'query':
'/'.join(self.portal.doc1.getPhysicalPath()) },
'/'.join(self.portal.doc1.getPhysicalPath())},
portal_type="Document"
))
doc1_brain = brains[0]
@ -188,7 +188,7 @@ class ConversationCatalogTest(unittest.TestCase):
del self.conversation[self.new_comment1_id]
brains = self.catalog.searchResults(dict(
path={'query':
'/'.join(self.portal.doc1.getPhysicalPath()) },
'/'.join(self.portal.doc1.getPhysicalPath())},
portal_type="Document"
))
doc1_brain = brains[0]
@ -197,7 +197,7 @@ class ConversationCatalogTest(unittest.TestCase):
def test_conversation_indexes_not_in_comments(self):
brains = self.catalog.searchResults(dict(
path={'query':
'/'.join(self.portal.doc1.getPhysicalPath()) },
'/'.join(self.portal.doc1.getPhysicalPath())},
portal_type="Discussion Item"
))
comment1_brain = brains[0]

View File

@ -60,7 +60,7 @@ class TestCommentForm(unittest.TestCase):
'portal_discussion',
None)
self.discussionTool.overrideDiscussionFor(self.portal.doc1, False)
self.membershipTool = getToolByName(self.folder, 'portal_membership', None)
self.membershipTool = getToolByName(self.folder, 'portal_membership')
self.memberdata = self.portal.portal_memberdata
self.context = getattr(self.portal, 'doc1')
@ -261,7 +261,8 @@ class TestCommentsViewlet(unittest.TestCase):
# Anonymous has no 'can review' permission
self.assertFalse(self.viewlet.can_review())
# The reviewer role has the 'Review comments' permission
self.portal.acl_users._doAddUser('reviewer', 'secret', ['Reviewer'], [])
self.portal.acl_users._doAddUser(
'reviewer', 'secret', ['Reviewer'], [])
login(self.portal, 'reviewer')
self.assertTrue(self.viewlet.can_review())
@ -276,7 +277,8 @@ class TestCommentsViewlet(unittest.TestCase):
# Anonymous has no 'can review' permission
self.assertFalse(self.viewlet.can_manage())
# The reviewer role has the 'Review comments' permission
self.portal.acl_users._doAddUser('reviewer', 'secret', ['Reviewer'], [])
self.portal.acl_users._doAddUser(
'reviewer', 'secret', ['Reviewer'], [])
login(self.portal, 'reviewer')
self.assertTrue(self.viewlet.can_manage())
@ -295,8 +297,8 @@ class TestCommentsViewlet(unittest.TestCase):
self.assertTrue(self.viewlet.comment_transform_message())
self.assertEqual(
self.viewlet.comment_transform_message(),
"You can add a comment by filling out the form below. Plain text " +
"formatting.")
"You can add a comment by filling out the form below. Plain " +
"text formatting.")
# Set text transform to intelligent text
registry = queryUtility(IRegistry)
@ -358,7 +360,7 @@ class TestCommentsViewlet(unittest.TestCase):
('comment_review_workflow,'))
# Check if workflow actions are available
reply = self.viewlet.get_replies(workflow_actions=True).next()
self.assertTrue(reply.has_key('actions'))
self.assertTrue('actions' in reply)
self.assertEqual(reply['actions'][0]['id'],
'publish')
self.assertEqual(reply['actions'][0]['url'],

View File

@ -12,7 +12,8 @@ from Products.CMFCore.utils import getToolByName
from plone.app.testing import TEST_USER_ID, setRoles
from plone.app.discussion.interfaces import IDiscussionSettings
from plone.app.discussion.testing import PLONE_APP_DISCUSSION_INTEGRATION_TESTING
from plone.app.discussion.testing import \
PLONE_APP_DISCUSSION_INTEGRATION_TESTING
class RegistryTest(unittest.TestCase):
@ -166,5 +167,6 @@ class ConfigurationChangedSubscriberTest(unittest.TestCase):
# setting itself remains unchanged.
self.settings.moderation_enabled = True
def test_suite():
return unittest.defaultTestLoader.loadTestsFromName(__name__)

View File

@ -15,7 +15,8 @@ from Products.CMFCore.utils import getToolByName
from plone.app.testing import TEST_USER_ID, setRoles
from plone.app.discussion.testing import PLONE_APP_DISCUSSION_INTEGRATION_TESTING
from plone.app.discussion.testing import \
PLONE_APP_DISCUSSION_INTEGRATION_TESTING
from plone.app.discussion import interfaces
from plone.app.discussion.interfaces import IConversation
@ -179,7 +180,6 @@ class ConversationTest(unittest.TestCase):
# 1) allow_discussion attribute: Every content object in Plone
# has a allow_discussion attribute. By default it is set to None.
# Create a conversation.
IConversation(self.portal.doc1)
@ -206,7 +206,7 @@ class ConversationTest(unittest.TestCase):
# the content type. So we allow discussion on the Document content
# type and check if the Document object allows discussion now.
document_fti = getattr(portal_types, 'Document')
document_fti.manage_changeProperties(allow_discussion = True)
document_fti.manage_changeProperties(allow_discussion=True)
self.assertEqual(portal_discussion.isDiscussionAllowedFor(
self.portal.doc1), True)
self.assertEqual(self.portal.doc1.getTypeInfo().allowDiscussion(),
@ -223,7 +223,7 @@ class ConversationTest(unittest.TestCase):
False)
# Disallow discussion on the Document content type again
document_fti.manage_changeProperties(allow_discussion = False)
document_fti.manage_changeProperties(allow_discussion=False)
self.assertEqual(portal_discussion.isDiscussionAllowedFor(
self.portal.doc1), False)
self.assertEqual(self.portal.doc1.getTypeInfo().allowDiscussion(),
@ -258,7 +258,7 @@ class ConversationTest(unittest.TestCase):
# otherwise allow_discussion will always return False
portal_types = getToolByName(self.portal, 'portal_types')
document_fti = getattr(portal_types, 'Document')
document_fti.manage_changeProperties(allow_discussion = True)
document_fti.manage_changeProperties(allow_discussion=True)
self.assertEqual(conversation.enabled(), True)
@ -272,7 +272,7 @@ class ConversationTest(unittest.TestCase):
# otherwise allow_discussion will always return False
portal_types = getToolByName(self.portal, 'portal_types')
document_fti = getattr(portal_types, 'Document')
document_fti.manage_changeProperties(allow_discussion = True)
document_fti.manage_changeProperties(allow_discussion=True)
# Check if conversation is enabled now
self.assertEqual(conversation.enabled(), True)
@ -289,7 +289,6 @@ class ConversationTest(unittest.TestCase):
settings.globally_enabled = True
self.assertEqual(conversation.enabled(), True)
def test_allow_discussion_for_news_items(self):
self.typetool.constructContent('News Item', self.portal, 'newsitem')
@ -300,7 +299,7 @@ class ConversationTest(unittest.TestCase):
# otherwise allow_discussion will always return False
portal_types = getToolByName(self.portal, 'portal_types')
document_fti = getattr(portal_types, 'News Item')
document_fti.manage_changeProperties(allow_discussion = True)
document_fti.manage_changeProperties(allow_discussion=True)
# Check if conversation is enabled now
self.assertEqual(conversation.enabled(), True)
@ -329,7 +328,7 @@ class ConversationTest(unittest.TestCase):
# Allow discussion on Document content type
portal_types = getToolByName(self.portal, 'portal_types')
document_fti = getattr(portal_types, 'Document')
document_fti.manage_changeProperties(allow_discussion = True)
document_fti.manage_changeProperties(allow_discussion=True)
# Check if conversation is enabled now
self.assertEqual(conversation.enabled(), True)
@ -337,7 +336,7 @@ class ConversationTest(unittest.TestCase):
# Disallow discussion on Document content type
portal_types = getToolByName(self.portal, 'portal_types')
document_fti = getattr(portal_types, 'Document')
document_fti.manage_changeProperties(allow_discussion = False)
document_fti.manage_changeProperties(allow_discussion=False)
# Check if conversation is enabled now
self.assertEqual(conversation.enabled(), False)
@ -358,7 +357,7 @@ class ConversationTest(unittest.TestCase):
# Allow discussion on Folder content type
portal_types = getToolByName(self.portal, 'portal_types')
document_fti = getattr(portal_types, 'Folder')
document_fti.manage_changeProperties(allow_discussion = True)
document_fti.manage_changeProperties(allow_discussion=True)
# Always return False
self.assertFalse(conversation.enabled())
@ -710,8 +709,7 @@ class ConversationTest(unittest.TestCase):
self.assertFalse('Discussion Item' in BAD_TYPES)
def test_no_comment(self):
conversation = IConversation(self.portal.doc1)
IConversation(self.portal.doc1)
# Make sure no conversation has been created
self.assertTrue('plone.app.discussion:conversation' not in
IAnnotations(self.portal.doc1))
@ -850,5 +848,6 @@ class RepliesTest(unittest.TestCase):
self.assertEqual(len(replies_to_comment1_1), 1)
self.assertEqual(len(replies_to_comment2), 1)
def test_suite():
return unittest.defaultTestLoader.loadTestsFromName(__name__)