Nuke trailing white space
svn path=/plone.app.discussion/trunk/; revision=46366
This commit is contained in:
@@ -19,13 +19,13 @@ class CatalogSetupTest(PloneTestCase):
|
||||
layer = DiscussionLayer
|
||||
|
||||
def test_catalog_installed(self):
|
||||
self.failUnless('total_comments' in
|
||||
self.failUnless('total_comments' in
|
||||
self.portal.portal_catalog.indexes())
|
||||
self.failUnless('commentators' in
|
||||
self.failUnless('commentators' in
|
||||
self.portal.portal_catalog.indexes())
|
||||
self.failUnless('total_comments' in
|
||||
self.failUnless('total_comments' in
|
||||
self.portal.portal_catalog.schema())
|
||||
self.failUnless('in_response_to' in
|
||||
self.failUnless('in_response_to' in
|
||||
self.portal.portal_catalog.schema())
|
||||
|
||||
def test_collection_criteria_installed(self):
|
||||
@@ -44,8 +44,8 @@ class ConversationCatalogTest(PloneTestCase):
|
||||
def afterSetUp(self):
|
||||
# First we need to create some content.
|
||||
self.loginAsPortalOwner()
|
||||
self.portal.invokeFactory(id='doc1',
|
||||
Title='Document 1',
|
||||
self.portal.invokeFactory(id='doc1',
|
||||
Title='Document 1',
|
||||
type_name='Document')
|
||||
|
||||
self.catalog = getToolByName(self.portal, 'portal_catalog')
|
||||
@@ -64,7 +64,7 @@ class ConversationCatalogTest(PloneTestCase):
|
||||
self.comment_id = new_comment1_id
|
||||
|
||||
brains = self.catalog.searchResults(
|
||||
path = {'query' :
|
||||
path = {'query' :
|
||||
'/'.join(self.portal.doc1.getPhysicalPath()) },
|
||||
portal_type = "Document"
|
||||
)
|
||||
@@ -88,7 +88,7 @@ class ConversationCatalogTest(PloneTestCase):
|
||||
'++conversation++default/%s' % new_comment2_id)
|
||||
comment2.reindexObject()
|
||||
brains = self.catalog.searchResults(
|
||||
path = {'query' :
|
||||
path = {'query' :
|
||||
'/'.join(self.portal.doc1.getPhysicalPath()) },
|
||||
portal_type = "Document"
|
||||
)
|
||||
@@ -97,7 +97,7 @@ class ConversationCatalogTest(PloneTestCase):
|
||||
|
||||
def test_last_comment_date(self):
|
||||
self.failUnless(self.doc1_brain.has_key('last_comment_date'))
|
||||
self.assertEquals(self.doc1_brain.last_comment_date,
|
||||
self.assertEquals(self.doc1_brain.last_comment_date,
|
||||
datetime(2006, 9, 17, 14, 18, 12))
|
||||
|
||||
# Add another comment and check if last comment date is updated.
|
||||
@@ -113,31 +113,31 @@ class ConversationCatalogTest(PloneTestCase):
|
||||
'++conversation++default/%s' % new_comment2_id)
|
||||
comment2.reindexObject()
|
||||
brains = self.catalog.searchResults(
|
||||
path = {'query' :
|
||||
path = {'query' :
|
||||
'/'.join(self.portal.doc1.getPhysicalPath()) },
|
||||
portal_type = "Document"
|
||||
)
|
||||
doc1_brain = brains[0]
|
||||
self.assertEquals(doc1_brain.last_comment_date,
|
||||
self.assertEquals(doc1_brain.last_comment_date,
|
||||
datetime(2009, 9, 17, 14, 18, 12))
|
||||
|
||||
# Remove the comment again
|
||||
del self.conversation[new_comment2_id]
|
||||
|
||||
brains = self.catalog.searchResults(
|
||||
path = {'query' :
|
||||
path = {'query' :
|
||||
'/'.join(self.portal.doc1.getPhysicalPath()) },
|
||||
portal_type = "Document"
|
||||
)
|
||||
doc1_brain = brains[0]
|
||||
|
||||
self.assertEquals(doc1_brain.last_comment_date,
|
||||
self.assertEquals(doc1_brain.last_comment_date,
|
||||
datetime(2006, 9, 17, 14, 18, 12))
|
||||
|
||||
# remove all comments
|
||||
del self.conversation[self.new_comment1_id]
|
||||
brains = self.catalog.searchResults(
|
||||
path = {'query' :
|
||||
path = {'query' :
|
||||
'/'.join(self.portal.doc1.getPhysicalPath()) },
|
||||
portal_type = "Document"
|
||||
)
|
||||
@@ -161,7 +161,7 @@ class ConversationCatalogTest(PloneTestCase):
|
||||
comment2.reindexObject()
|
||||
|
||||
brains = self.catalog.searchResults(
|
||||
path = {'query' :
|
||||
path = {'query' :
|
||||
'/'.join(self.portal.doc1.getPhysicalPath()) },
|
||||
portal_type = "Document"
|
||||
)
|
||||
@@ -172,7 +172,7 @@ class ConversationCatalogTest(PloneTestCase):
|
||||
# remove one comments
|
||||
del self.conversation[new_comment2_id]
|
||||
brains = self.catalog.searchResults(
|
||||
path = {'query' :
|
||||
path = {'query' :
|
||||
'/'.join(self.portal.doc1.getPhysicalPath()) },
|
||||
portal_type = "Document"
|
||||
)
|
||||
@@ -182,7 +182,7 @@ class ConversationCatalogTest(PloneTestCase):
|
||||
# remove all comments
|
||||
del self.conversation[self.new_comment1_id]
|
||||
brains = self.catalog.searchResults(
|
||||
path = {'query' :
|
||||
path = {'query' :
|
||||
'/'.join(self.portal.doc1.getPhysicalPath()) },
|
||||
portal_type = "Document"
|
||||
)
|
||||
@@ -191,7 +191,7 @@ class ConversationCatalogTest(PloneTestCase):
|
||||
|
||||
def test_conversation_indexes_not_in_comments(self):
|
||||
brains = self.catalog.searchResults(
|
||||
path = {'query' :
|
||||
path = {'query' :
|
||||
'/'.join(self.portal.doc1.getPhysicalPath()) },
|
||||
portal_type = "Discussion Item"
|
||||
)
|
||||
@@ -208,8 +208,8 @@ class CommentCatalogTest(PloneTestCase):
|
||||
"""Create a document with a comment.
|
||||
"""
|
||||
self.loginAsPortalOwner()
|
||||
self.portal.invokeFactory(id='doc1',
|
||||
title='Document 1',
|
||||
self.portal.invokeFactory(id='doc1',
|
||||
title='Document 1',
|
||||
type_name='Document')
|
||||
self.catalog = getToolByName(self.portal, 'portal_catalog')
|
||||
|
||||
@@ -226,13 +226,13 @@ class CommentCatalogTest(PloneTestCase):
|
||||
self.comment = self.portal.doc1.restrictedTraverse(
|
||||
'++conversation++default/%s' % new_comment1_id)
|
||||
brains = self.catalog.searchResults(
|
||||
path = {'query' :
|
||||
path = {'query' :
|
||||
'/'.join(self.comment.getPhysicalPath()) })
|
||||
self.comment_brain = brains[0]
|
||||
|
||||
def test_title(self):
|
||||
self.assertEquals(self.comment_brain.Title, 'Jim on Document 1')
|
||||
|
||||
|
||||
def test_no_name_title(self):
|
||||
comment = createObject('plone.Comment')
|
||||
comment.text = 'Comment text'
|
||||
@@ -242,7 +242,7 @@ class CommentCatalogTest(PloneTestCase):
|
||||
comment = self.portal.doc1.restrictedTraverse(
|
||||
'++conversation++default/%s' % cid)
|
||||
brains = self.catalog.searchResults(
|
||||
path = {'query' :
|
||||
path = {'query' :
|
||||
'/'.join(comment.getPhysicalPath()) })
|
||||
comment_brain = brains[0]
|
||||
self.assertEquals(comment_brain.Title, "Anonymous on Document 1")
|
||||
@@ -266,13 +266,13 @@ class CommentCatalogTest(PloneTestCase):
|
||||
|
||||
def test_add_comment(self):
|
||||
self.failUnless(self.comment_brain)
|
||||
|
||||
|
||||
def test_delete_comment(self):
|
||||
# Make sure a comment is removed from the catalog as well when it is
|
||||
# deleted.
|
||||
del self.conversation[self.comment_id]
|
||||
brains = self.catalog.searchResults(
|
||||
path = {'query' :
|
||||
path = {'query' :
|
||||
'/'.join(self.comment.getPhysicalPath()) })
|
||||
self.assertEquals(len(brains), 0)
|
||||
|
||||
@@ -285,7 +285,7 @@ class CommentCatalogTest(PloneTestCase):
|
||||
self.portal.manage_delObjects(["doc1"])
|
||||
brains = self.catalog.searchResults(portal_type = 'Discussion Item')
|
||||
self.assertEquals(len(brains), 0)
|
||||
|
||||
|
||||
def test_clear_and_rebuild_catalog(self):
|
||||
# Clear and rebuild catalog
|
||||
self.catalog.clearFindAndRebuild()
|
||||
@@ -353,7 +353,7 @@ class CommentCatalogTest(PloneTestCase):
|
||||
self.assertEquals(len(brains), 6)
|
||||
|
||||
def test_collection(self):
|
||||
self.portal.invokeFactory(id='topic', type_name='Topic')
|
||||
self.portal.invokeFactory(id='topic', type_name='Topic')
|
||||
topic = self.portal.topic
|
||||
crit = topic.addCriterion('Type', 'ATSimpleStringCriterion')
|
||||
crit.setValue('Comment')
|
||||
|
||||
@@ -37,7 +37,7 @@ class CommentTest(PloneTestCase):
|
||||
self.catalog = getToolByName(self.portal, 'portal_catalog')
|
||||
self.document_brain = self.catalog.searchResults(
|
||||
portal_type = 'Document')[0]
|
||||
|
||||
|
||||
def test_factory(self):
|
||||
comment1 = createObject('plone.Comment')
|
||||
self.assert_(IComment.providedBy(comment1))
|
||||
@@ -71,7 +71,7 @@ class CommentTest(PloneTestCase):
|
||||
conversation.addComment(comment1)
|
||||
comment_brain = self.catalog.searchResults(
|
||||
portal_type = 'Discussion Item')[0]
|
||||
|
||||
|
||||
# comment should only have a UID if plone.uuid is present
|
||||
try:
|
||||
from plone.uuid.interfaces import IUUID
|
||||
@@ -80,7 +80,7 @@ class CommentTest(PloneTestCase):
|
||||
self.failIf(comment_brain.UID)
|
||||
else:
|
||||
self.failUnless(comment_brain.UID)
|
||||
|
||||
|
||||
def test_uid_is_unique(self):
|
||||
conversation = IConversation(self.portal.doc1)
|
||||
comment1 = createObject('plone.Comment')
|
||||
@@ -89,12 +89,12 @@ class CommentTest(PloneTestCase):
|
||||
conversation.addComment(comment2)
|
||||
brains = self.catalog.searchResults(
|
||||
portal_type = 'Discussion Item')
|
||||
|
||||
|
||||
# make sure uids are either both None (i.e. without plone.uuid),
|
||||
# or not equal
|
||||
if brains[0].UID != None or brains[1].UID != None:
|
||||
self.assertNotEquals(brains[0].UID, brains[1].UID)
|
||||
|
||||
|
||||
def test_comment_uid_differs_from_content_uid(self):
|
||||
conversation = IConversation(self.portal.doc1)
|
||||
comment1 = createObject('plone.Comment')
|
||||
|
||||
@@ -4,7 +4,7 @@ import time
|
||||
from datetime import datetime
|
||||
|
||||
from AccessControl import Unauthorized
|
||||
|
||||
|
||||
from zope.component import createObject, queryUtility
|
||||
|
||||
from OFS.Image import Image
|
||||
@@ -31,7 +31,7 @@ from Products.PloneTestCase.ptc import PloneTestCase
|
||||
|
||||
from plone.app.discussion.browser.comments import CommentsViewlet
|
||||
from plone.app.discussion.browser.comments import CommentForm
|
||||
from plone.app.discussion.interfaces import IConversation
|
||||
from plone.app.discussion.interfaces import IConversation
|
||||
from plone.app.discussion.tests.layer import DiscussionLayer
|
||||
from plone.app.discussion.interfaces import IDiscussionSettings
|
||||
|
||||
@@ -44,8 +44,8 @@ class TestCommentForm(PloneTestCase):
|
||||
self.loginAsPortalOwner()
|
||||
typetool = self.portal.portal_types
|
||||
typetool.constructContent('Document', self.portal, 'doc1')
|
||||
self.dtool = getToolByName(self.portal,
|
||||
'portal_discussion',
|
||||
self.dtool = getToolByName(self.portal,
|
||||
'portal_discussion',
|
||||
None)
|
||||
self.dtool.overrideDiscussionFor(self.portal.doc1, False)
|
||||
self.mtool = getToolByName(self.folder, 'portal_membership', None)
|
||||
@@ -57,11 +57,11 @@ class TestCommentForm(PloneTestCase):
|
||||
registry = queryUtility(IRegistry)
|
||||
settings = registry.forInterface(IDiscussionSettings)
|
||||
settings.globally_enabled = True
|
||||
|
||||
|
||||
def test_add_comment(self):
|
||||
"""Post a comment as logged-in user.
|
||||
"""
|
||||
|
||||
|
||||
# Allow discussion
|
||||
self.dtool.overrideDiscussionFor(self.portal.doc1, True)
|
||||
self.viewlet = CommentsViewlet(self.context, self.request, None, None)
|
||||
@@ -72,99 +72,99 @@ class TestCommentForm(PloneTestCase):
|
||||
alsoProvides(request, IFormLayer)
|
||||
alsoProvides(request, IAttributeAnnotatable)
|
||||
return request
|
||||
|
||||
|
||||
provideAdapter(adapts=(Interface, IBrowserRequest),
|
||||
provides=Interface,
|
||||
factory=CommentForm,
|
||||
name=u"comment-form")
|
||||
|
||||
|
||||
# The form should return an error if the comment text field is empty
|
||||
request = make_request(form={})
|
||||
|
||||
commentForm = getMultiAdapter((self.context, request),
|
||||
commentForm = getMultiAdapter((self.context, request),
|
||||
name=u"comment-form")
|
||||
commentForm.update()
|
||||
data, errors = commentForm.extractData() # pylint: disable-msg=W0612
|
||||
|
||||
data, errors = commentForm.extractData() # pylint: disable-msg=W0612
|
||||
|
||||
self.assertEquals(len(errors), 1)
|
||||
self.failIf(commentForm.handleComment(commentForm, "foo"))
|
||||
|
||||
# The form is submitted successfully, if the required text field is
|
||||
|
||||
# The form is submitted successfully, if the required text field is
|
||||
# filled out
|
||||
request = make_request(form={'form.widgets.text': u'bar'})
|
||||
|
||||
commentForm = getMultiAdapter((self.context, request),
|
||||
commentForm = getMultiAdapter((self.context, request),
|
||||
name=u"comment-form")
|
||||
commentForm.update()
|
||||
data, errors = commentForm.extractData() # pylint: disable-msg=W0612
|
||||
data, errors = commentForm.extractData() # pylint: disable-msg=W0612
|
||||
|
||||
self.assertEquals(len(errors), 0)
|
||||
self.failIf(commentForm.handleComment(commentForm, "foo"))
|
||||
|
||||
|
||||
def test_add_anonymous_comment(self):
|
||||
"""Add a comment as anonymous.
|
||||
"""
|
||||
|
||||
|
||||
# Allow discussion
|
||||
self.dtool.overrideDiscussionFor(self.portal.doc1, True)
|
||||
self.viewlet = CommentsViewlet(self.context, self.request, None, None)
|
||||
|
||||
|
||||
registry = queryUtility(IRegistry)
|
||||
settings = registry.forInterface(IDiscussionSettings, check=False)
|
||||
settings.anonymous_comments = True
|
||||
|
||||
# Logout
|
||||
self.logout()
|
||||
|
||||
|
||||
def make_request(form={}):
|
||||
request = TestRequest()
|
||||
request.form.update(form)
|
||||
alsoProvides(request, IFormLayer)
|
||||
alsoProvides(request, IAttributeAnnotatable)
|
||||
return request
|
||||
|
||||
|
||||
provideAdapter(adapts=(Interface, IBrowserRequest),
|
||||
provides=Interface,
|
||||
factory=CommentForm,
|
||||
name=u"comment-form")
|
||||
|
||||
|
||||
# Post an anonymous comment and provide a name
|
||||
request = make_request(form={'form.widgets.name': u'john doe',
|
||||
'form.widgets.text': u'bar'})
|
||||
|
||||
commentForm = getMultiAdapter((self.context, request),
|
||||
commentForm = getMultiAdapter((self.context, request),
|
||||
name=u"comment-form")
|
||||
commentForm.update()
|
||||
data, errors = commentForm.extractData() # pylint: disable-msg=W0612
|
||||
data, errors = commentForm.extractData() # pylint: disable-msg=W0612
|
||||
|
||||
self.assertEquals(len(errors), 0)
|
||||
self.failIf(commentForm.handleComment(commentForm, "action"))
|
||||
|
||||
|
||||
def test_can_not_add_comments_if_discussion_is_not_allowed(self):
|
||||
"""Make sure that comments can't be posted if discussion is disabled.
|
||||
"""
|
||||
|
||||
|
||||
# Discussion is disabled by default
|
||||
|
||||
|
||||
def make_request(form={}):
|
||||
request = TestRequest()
|
||||
request.form.update(form)
|
||||
alsoProvides(request, IFormLayer)
|
||||
alsoProvides(request, IAttributeAnnotatable)
|
||||
return request
|
||||
|
||||
|
||||
provideAdapter(adapts=(Interface, IBrowserRequest),
|
||||
provides=Interface,
|
||||
factory=CommentForm,
|
||||
name=u"comment-form")
|
||||
|
||||
|
||||
request = make_request(form={'form.widgets.text': u'bar'})
|
||||
|
||||
commentForm = getMultiAdapter((self.context, request),
|
||||
commentForm = getMultiAdapter((self.context, request),
|
||||
name=u"comment-form")
|
||||
commentForm.update()
|
||||
data, errors = commentForm.extractData() # pylint: disable-msg=W0612
|
||||
|
||||
data, errors = commentForm.extractData() # pylint: disable-msg=W0612
|
||||
|
||||
# No form errors, but raise unauthorized because discussion is not
|
||||
# allowed
|
||||
self.assertEquals(len(errors), 0)
|
||||
@@ -172,52 +172,52 @@ class TestCommentForm(PloneTestCase):
|
||||
commentForm.handleComment,
|
||||
commentForm,
|
||||
"foo")
|
||||
|
||||
|
||||
def test_anonymous_can_not_add_comments_if_discussion_is_not_allowed(self):
|
||||
"""Make sure that anonymous users can't post comments if anonymous
|
||||
comments are disabled.
|
||||
"""
|
||||
|
||||
|
||||
# Anonymous comments are disabled by default
|
||||
|
||||
|
||||
self.logout()
|
||||
|
||||
|
||||
def make_request(form={}):
|
||||
request = TestRequest()
|
||||
request.form.update(form)
|
||||
alsoProvides(request, IFormLayer)
|
||||
alsoProvides(request, IAttributeAnnotatable)
|
||||
return request
|
||||
|
||||
|
||||
provideAdapter(adapts=(Interface, IBrowserRequest),
|
||||
provides=Interface,
|
||||
factory=CommentForm,
|
||||
name=u"comment-form")
|
||||
|
||||
|
||||
request = make_request(form={'form.widgets.text': u'bar'})
|
||||
|
||||
commentForm = getMultiAdapter((self.context, request),
|
||||
commentForm = getMultiAdapter((self.context, request),
|
||||
name=u"comment-form")
|
||||
commentForm.update()
|
||||
data, errors = commentForm.extractData() # pylint: disable-msg=W0612
|
||||
|
||||
data, errors = commentForm.extractData() # pylint: disable-msg=W0612
|
||||
|
||||
self.assertEquals(len(errors), 0)
|
||||
self.assertRaises(Unauthorized,
|
||||
commentForm.handleComment,
|
||||
commentForm,
|
||||
"foo")
|
||||
|
||||
|
||||
|
||||
class TestCommentsViewlet(PloneTestCase):
|
||||
|
||||
layer = DiscussionLayer
|
||||
|
||||
|
||||
def afterSetUp(self):
|
||||
self.loginAsPortalOwner()
|
||||
typetool = self.portal.portal_types
|
||||
typetool.constructContent('Document', self.portal, 'doc1')
|
||||
self.portal_discussion = getToolByName(self.portal,
|
||||
'portal_discussion',
|
||||
self.portal_discussion = getToolByName(self.portal,
|
||||
'portal_discussion',
|
||||
None)
|
||||
self.mtool = getToolByName(self.folder, 'portal_membership')
|
||||
self.memberdata = self.portal.portal_memberdata
|
||||
@@ -229,29 +229,29 @@ class TestCommentsViewlet(PloneTestCase):
|
||||
registry = queryUtility(IRegistry)
|
||||
settings = registry.forInterface(IDiscussionSettings)
|
||||
settings.globally_enabled = True
|
||||
|
||||
|
||||
def test_cook(self):
|
||||
text = """First paragraph
|
||||
|
||||
|
||||
Second paragraph"""
|
||||
self.assertEquals(self.viewlet.cook(text),
|
||||
"<p>First paragraph<br /> <br /> Second paragraph</p>")
|
||||
"<p>First paragraph<br /><br /> Second paragraph</p>")
|
||||
|
||||
def test_cook_no_html(self):
|
||||
text = """<b>Got HTML?</b>"""
|
||||
self.assertEquals(self.viewlet.cook(text),
|
||||
"<p><b>Got HTML?</b></p>")
|
||||
|
||||
|
||||
def test_cook_with_no_ascii_characters(self):
|
||||
text = """Umlaute sind ä, ö und ü."""
|
||||
self.assertEquals(self.viewlet.cook(text),
|
||||
self.assertEquals(self.viewlet.cook(text),
|
||||
"<p>Umlaute sind \xc3\xa4, \xc3\xb6 und \xc3\xbc.</p>")
|
||||
|
||||
|
||||
def test_cook_links(self):
|
||||
text = "Go to http://www.plone.org"
|
||||
self.assertEquals(self.viewlet.cook(text),
|
||||
self.assertEquals(self.viewlet.cook(text),
|
||||
"<p>Go to http://www.plone.org</p>")
|
||||
|
||||
|
||||
def test_can_reply(self):
|
||||
# Portal owner can reply
|
||||
self.failUnless(self.viewlet.can_reply())
|
||||
@@ -268,7 +268,7 @@ class TestCommentsViewlet(PloneTestCase):
|
||||
# The reviewer role has the 'Review comments' permission
|
||||
self.portal.acl_users._doAddUser('reviewer', 'secret', ['Reviewer'], [])
|
||||
self.login('reviewer')
|
||||
self.failUnless(self.viewlet.can_review())
|
||||
self.failUnless(self.viewlet.can_review())
|
||||
|
||||
def test_can_manage(self):
|
||||
"""We keep this method for backward compatibility. This method has been
|
||||
@@ -283,8 +283,8 @@ class TestCommentsViewlet(PloneTestCase):
|
||||
# The reviewer role has the 'Review comments' permission
|
||||
self.portal.acl_users._doAddUser('reviewer', 'secret', ['Reviewer'], [])
|
||||
self.login('reviewer')
|
||||
self.failUnless(self.viewlet.can_manage())
|
||||
|
||||
self.failUnless(self.viewlet.can_manage())
|
||||
|
||||
def test_is_discussion_allowed(self):
|
||||
# By default, discussion is disabled
|
||||
self.failIf(self.viewlet.is_discussion_allowed())
|
||||
@@ -309,12 +309,11 @@ class TestCommentsViewlet(PloneTestCase):
|
||||
|
||||
# Make sure the comment description is changes accordingly
|
||||
self.assertEquals(
|
||||
self.viewlet.comment_transform_message(),
|
||||
self.viewlet.comment_transform_message(),
|
||||
"You can add a comment by filling out the form below. " +
|
||||
"Plain text formatting. Web and email addresses are transformed " +
|
||||
"into clickable links.")
|
||||
|
||||
|
||||
|
||||
def test_has_replies(self):
|
||||
self.assertEquals(self.viewlet.has_replies(), False)
|
||||
comment = createObject('plone.Comment')
|
||||
@@ -331,7 +330,7 @@ class TestCommentsViewlet(PloneTestCase):
|
||||
conversation.addComment(comment)
|
||||
conversation.addComment(comment)
|
||||
replies = self.viewlet.get_replies()
|
||||
self.assertEquals(len(tuple(replies)), 2)
|
||||
self.assertEquals(len(tuple(replies)), 2)
|
||||
replies = self.viewlet.get_replies()
|
||||
replies.next()
|
||||
replies.next()
|
||||
@@ -344,7 +343,7 @@ class TestCommentsViewlet(PloneTestCase):
|
||||
conversation = IConversation(self.portal.doc1)
|
||||
c1 = conversation.addComment(comment)
|
||||
self.assertEquals(
|
||||
len(tuple(self.viewlet.get_replies(workflow_actions=True))), 1)
|
||||
len(tuple(self.viewlet.get_replies(workflow_actions=True))), 1)
|
||||
# Enable moderation workflow
|
||||
self.portal.portal_workflow.setChainForPortalTypes(
|
||||
('Discussion Item',),
|
||||
@@ -356,8 +355,8 @@ class TestCommentsViewlet(PloneTestCase):
|
||||
'publish')
|
||||
self.assertEquals(reply['actions'][0]['url'],
|
||||
'http://nohost/plone/doc1/++conversation++default/%s' % int(c1) +
|
||||
'/content_status_modify?workflow_action=publish')
|
||||
|
||||
'/content_status_modify?workflow_action=publish')
|
||||
|
||||
def test_get_commenter_home_url(self):
|
||||
comment = createObject('plone.Comment')
|
||||
comment.text = 'Comment text'
|
||||
@@ -369,17 +368,17 @@ class TestCommentsViewlet(PloneTestCase):
|
||||
|
||||
def test_get_commenter_home_url_is_none(self):
|
||||
self.failIf(self.viewlet.get_commenter_home_url())
|
||||
|
||||
|
||||
def test_get_commenter_portrait(self):
|
||||
|
||||
# Add a user with a member image
|
||||
self.mtool.addMember('jim', 'Jim', ['Member'], [])
|
||||
self.memberdata._setPortrait(Image(id='jim',
|
||||
self.memberdata._setPortrait(Image(id='jim',
|
||||
file=dummy.File(),
|
||||
title=''), 'jim')
|
||||
self.assertEqual(self.memberdata._getPortrait('jim').getId(),
|
||||
self.assertEqual(self.memberdata._getPortrait('jim').getId(),
|
||||
'jim')
|
||||
self.assertEqual(self.memberdata._getPortrait('jim').meta_type,
|
||||
self.assertEqual(self.memberdata._getPortrait('jim').meta_type,
|
||||
'Image')
|
||||
|
||||
# Add a conversation with a comment
|
||||
@@ -395,13 +394,13 @@ class TestCommentsViewlet(PloneTestCase):
|
||||
portrait_url = self.viewlet.get_commenter_portrait('jim')
|
||||
|
||||
# Check if the correct member image URL is returned
|
||||
self.assertEquals(portrait_url,
|
||||
self.assertEquals(portrait_url,
|
||||
'http://nohost/plone/portal_memberdata/portraits/jim')
|
||||
|
||||
def test_get_commenter_portrait_is_none(self):
|
||||
self.assertEquals(self.viewlet.get_commenter_portrait(),
|
||||
self.assertEquals(self.viewlet.get_commenter_portrait(),
|
||||
'defaultUser.gif')
|
||||
|
||||
|
||||
def test_get_commenter_portrait_without_userimage(self):
|
||||
|
||||
# Create a user without a user image
|
||||
@@ -431,14 +430,14 @@ class TestCommentsViewlet(PloneTestCase):
|
||||
'anonymous_comments'] = True
|
||||
# Test if anonymous discussion is allowed for the viewlet
|
||||
self.failUnless(self.viewlet.anonymous_discussion_allowed())
|
||||
|
||||
|
||||
def test_show_commenter_image(self):
|
||||
self.failUnless(self.viewlet.show_commenter_image())
|
||||
registry = queryUtility(IRegistry)
|
||||
registry['plone.app.discussion.interfaces.IDiscussionSettings.' +
|
||||
'show_commenter_image'] = False
|
||||
'show_commenter_image'] = False
|
||||
self.failIf(self.viewlet.show_commenter_image())
|
||||
|
||||
|
||||
def test_is_anonymous(self):
|
||||
self.failIf(self.viewlet.is_anonymous())
|
||||
self.logout()
|
||||
@@ -447,8 +446,8 @@ class TestCommentsViewlet(PloneTestCase):
|
||||
def test_login_action(self):
|
||||
self.viewlet.update()
|
||||
self.assertEquals(self.viewlet.login_action(),
|
||||
'http://nohost/plone/login_form?came_from=http%3A//nohost')
|
||||
|
||||
'http://nohost/plone/login_form?came_from=http%3A//nohost')
|
||||
|
||||
def test_format_time(self):
|
||||
python_time = datetime(2009, 02, 01, 23, 32, 03, 57)
|
||||
# Python Time must be utc time. There seems to be no too simple way
|
||||
@@ -464,5 +463,6 @@ class TestCommentsViewlet(PloneTestCase):
|
||||
localized_time = self.viewlet.format_time(python_time)
|
||||
self.assertEquals(localized_time, "Feb 01, 2009 11:32 PM")
|
||||
|
||||
|
||||
def test_suite():
|
||||
return unittest.defaultTestLoader.loadTestsFromName(__name__)
|
||||
|
||||
@@ -27,9 +27,9 @@ class RegistryTest(PloneTestCase):
|
||||
def test_registry_registered(self):
|
||||
registry = queryUtility(IRegistry)
|
||||
self.failUnless(registry.forInterface(IDiscussionSettings))
|
||||
|
||||
|
||||
def test_discussion_controlpanel_view(self):
|
||||
view = getMultiAdapter((self.portal, self.portal.REQUEST),
|
||||
view = getMultiAdapter((self.portal, self.portal.REQUEST),
|
||||
name="discussion-settings")
|
||||
view = view.__of__(self.portal)
|
||||
self.failUnless(view())
|
||||
@@ -45,7 +45,7 @@ class RegistryTest(PloneTestCase):
|
||||
self.failUnless('globally_enabled' in IDiscussionSettings)
|
||||
self.assertEquals(
|
||||
self.registry['plone.app.discussion.interfaces.' +
|
||||
'IDiscussionSettings.globally_enabled'],
|
||||
'IDiscussionSettings.globally_enabled'],
|
||||
False)
|
||||
|
||||
def test_anonymous_comments(self):
|
||||
@@ -59,16 +59,16 @@ class RegistryTest(PloneTestCase):
|
||||
self.failUnless('moderation_enabled' in IDiscussionSettings)
|
||||
self.assertEquals(
|
||||
self.registry['plone.app.discussion.interfaces.' +
|
||||
'IDiscussionSettings.moderation_enabled'],
|
||||
'IDiscussionSettings.moderation_enabled'],
|
||||
False)
|
||||
|
||||
|
||||
def test_text_transform(self):
|
||||
self.failUnless('text_transform' in IDiscussionSettings)
|
||||
self.assertEquals(
|
||||
self.registry['plone.app.discussion.interfaces.' +
|
||||
'IDiscussionSettings.text_transform'],
|
||||
'text/plain')
|
||||
|
||||
|
||||
def test_captcha(self):
|
||||
# Check globally_enabled record
|
||||
self.failUnless('captcha' in IDiscussionSettings)
|
||||
@@ -79,12 +79,12 @@ class RegistryTest(PloneTestCase):
|
||||
def test_show_commenter_image(self):
|
||||
# Check show_commenter_image record
|
||||
self.failUnless('show_commenter_image' in IDiscussionSettings)
|
||||
self.assertEquals(self.registry['plone.app.discussion.interfaces.' +
|
||||
self.assertEquals(self.registry['plone.app.discussion.interfaces.' +
|
||||
'IDiscussionSettings.show_commenter_image'], True)
|
||||
|
||||
def test_moderator_notification_enabled(self):
|
||||
# Check show_commenter_image record
|
||||
self.failUnless('moderator_notification_enabled' in
|
||||
self.failUnless('moderator_notification_enabled' in
|
||||
IDiscussionSettings)
|
||||
self.assertEquals(self.registry['plone.app.discussion.interfaces.' +
|
||||
'IDiscussionSettings.moderator_notification_enabled'], False)
|
||||
@@ -108,39 +108,39 @@ class ConfigurationChangedSubscriberTest(PloneTestCase):
|
||||
# Set up the registry
|
||||
registry = queryUtility(IRegistry)
|
||||
self.settings = registry.forInterface(IDiscussionSettings, check=False)
|
||||
|
||||
|
||||
def test_moderation_enabled_in_discussion_control_panel_changed(self):
|
||||
"""Make sure the 'Discussion Item' workflow is changed properly, when
|
||||
the 'comment_moderation' setting in the discussion control panel
|
||||
"""Make sure the 'Discussion Item' workflow is changed properly, when
|
||||
the 'comment_moderation' setting in the discussion control panel
|
||||
changes.
|
||||
"""
|
||||
# By default the one_state_workflow without moderation is enabled
|
||||
self.assertEquals(('one_state_workflow',),
|
||||
self.portal.portal_workflow.getChainForPortalType(
|
||||
'Discussion Item'))
|
||||
|
||||
'Discussion Item'))
|
||||
|
||||
# Enable moderation in the discussion control panel
|
||||
self.settings.moderation_enabled = True
|
||||
|
||||
self.settings.moderation_enabled = True
|
||||
|
||||
# Make sure the comment_review_workflow with moderation enabled is
|
||||
# enabled
|
||||
self.assertEquals(('comment_review_workflow',),
|
||||
self.portal.portal_workflow.getChainForPortalType(
|
||||
'Discussion Item'))
|
||||
'Discussion Item'))
|
||||
# And back
|
||||
self.settings.moderation_enabled = False
|
||||
self.assertEquals(('one_state_workflow',),
|
||||
self.portal.portal_workflow.getChainForPortalType(
|
||||
'Discussion Item'))
|
||||
|
||||
'Discussion Item'))
|
||||
|
||||
def test_change_workflow_in_types_control_panel(self):
|
||||
"""Make sure the setting in the discussion control panel is changed
|
||||
accordingly, when the workflow for the 'Discussion Item' changed in
|
||||
the types control panel.
|
||||
accordingly, when the workflow for the 'Discussion Item' changed in
|
||||
the types control panel.
|
||||
"""
|
||||
# By default, moderation is disabled
|
||||
self.settings.moderation_enabled = False
|
||||
|
||||
|
||||
# Enable the 'comment_review_workflow' with moderation enabled
|
||||
self.portal.portal_workflow.setChainForPortalTypes(
|
||||
('Discussion Item',),
|
||||
@@ -159,11 +159,11 @@ class ConfigurationChangedSubscriberTest(PloneTestCase):
|
||||
self.portal.portal_workflow.setChainForPortalTypes(
|
||||
('Discussion Item',),
|
||||
('intranet_workflow',))
|
||||
|
||||
# Setting has not changed. A Custom workflow disables the
|
||||
|
||||
# Setting has not changed. A Custom workflow disables the
|
||||
# enable_moderation checkbox in the discussion control panel. The
|
||||
# setting itself remains unchanged.
|
||||
self.settings.moderation_enabled = True
|
||||
|
||||
|
||||
def test_suite():
|
||||
return unittest.defaultTestLoader.loadTestsFromName(__name__)
|
||||
|
||||
@@ -29,20 +29,20 @@ class ConversationTest(PloneTestCase):
|
||||
typetool = self.portal.portal_types
|
||||
typetool.constructContent('Document', self.portal, 'doc1')
|
||||
self.typetool = typetool
|
||||
self.portal_discussion = getToolByName(self.portal,
|
||||
'portal_discussion',
|
||||
self.portal_discussion = getToolByName(self.portal,
|
||||
'portal_discussion',
|
||||
None)
|
||||
# Allow discussion
|
||||
registry = queryUtility(IRegistry)
|
||||
settings = registry.forInterface(IDiscussionSettings)
|
||||
settings.globally_enabled = True
|
||||
|
||||
|
||||
def test_add_comment(self):
|
||||
# Create a conversation. In this case we doesn't assign it to an
|
||||
# object, as we just want to check the Conversation object API.
|
||||
conversation = IConversation(self.portal.doc1)
|
||||
|
||||
# Add a comment. Note: in real life, we always create comments via the
|
||||
# Add a comment. Note: in real life, we always create comments via the
|
||||
# factory to allow different factories to be swapped in
|
||||
|
||||
comment = createObject('plone.Comment')
|
||||
@@ -59,7 +59,7 @@ class ConversationTest(PloneTestCase):
|
||||
self.assertEquals(len(list(conversation.getComments())), 1)
|
||||
self.assertEquals(len(tuple(conversation.getThreads())), 1)
|
||||
self.assertEquals(conversation.total_comments, 1)
|
||||
self.assert_(conversation.last_comment_date - datetime.utcnow() <
|
||||
self.assert_(conversation.last_comment_date - datetime.utcnow() <
|
||||
timedelta(seconds=1))
|
||||
|
||||
def test_delete_comment(self):
|
||||
@@ -67,7 +67,7 @@ class ConversationTest(PloneTestCase):
|
||||
# object, as we just want to check the Conversation object API.
|
||||
conversation = IConversation(self.portal.doc1)
|
||||
|
||||
# Add a comment. Note: in real life, we always create comments via the
|
||||
# Add a comment. Note: in real life, we always create comments via the
|
||||
# factory to allow different factories to be swapped in
|
||||
|
||||
comment = createObject('plone.Comment')
|
||||
@@ -148,7 +148,7 @@ class ConversationTest(PloneTestCase):
|
||||
], list(conversation.getThreads()))
|
||||
|
||||
def test_delete_comment_when_content_object_is_deleted(self):
|
||||
# Make sure all comments of a content object are deleted when the
|
||||
# Make sure all comments of a content object are deleted when the
|
||||
# object itself is deleted.
|
||||
conversation = IConversation(self.portal.doc1)
|
||||
comment = createObject('plone.Comment')
|
||||
@@ -157,11 +157,11 @@ class ConversationTest(PloneTestCase):
|
||||
|
||||
# Delete the content object
|
||||
self.portal.manage_delObjects(['doc1'])
|
||||
|
||||
|
||||
# Make sure the comment has been deleted as well
|
||||
self.assertEquals(len(list(conversation.getComments())), 0)
|
||||
self.assertEquals(len(tuple(conversation.getThreads())), 0)
|
||||
self.assertEquals(conversation.total_comments, 0)
|
||||
self.assertEquals(conversation.total_comments, 0)
|
||||
|
||||
def test_allow_discussion(self):
|
||||
# This is not a real test! It's only there to understand the
|
||||
@@ -188,20 +188,20 @@ class ConversationTest(PloneTestCase):
|
||||
portal_discussion = getToolByName(self.portal, 'portal_discussion')
|
||||
self.assertEquals(portal_discussion.isDiscussionAllowedFor(
|
||||
self.portal.doc1), False)
|
||||
self.assertEquals(self.portal.doc1.getTypeInfo().allowDiscussion(),
|
||||
self.assertEquals(self.portal.doc1.getTypeInfo().allowDiscussion(),
|
||||
False)
|
||||
|
||||
# The allow discussion flag is None by default
|
||||
self.failIf(getattr(self.portal.doc1, 'allow_discussion', None))
|
||||
|
||||
# But isDiscussionAllowedFor, also checks if discussion is allowed on
|
||||
# the content type. So we allow discussion on the Document content
|
||||
# But isDiscussionAllowedFor, also checks if discussion is allowed on
|
||||
# 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)
|
||||
self.assertEquals(portal_discussion.isDiscussionAllowedFor(
|
||||
self.portal.doc1), True)
|
||||
self.assertEquals(self.portal.doc1.getTypeInfo().allowDiscussion(),
|
||||
self.assertEquals(self.portal.doc1.getTypeInfo().allowDiscussion(),
|
||||
True)
|
||||
|
||||
# We can also override the allow_discussion locally
|
||||
@@ -209,16 +209,16 @@ class ConversationTest(PloneTestCase):
|
||||
# Check if the Document discussion is disabled
|
||||
self.assertEquals(portal_discussion.isDiscussionAllowedFor(
|
||||
self.portal.doc1), False)
|
||||
# Check that the local allow_discussion flag is now explicitly set to
|
||||
# Check that the local allow_discussion flag is now explicitly set to
|
||||
# False
|
||||
self.assertEquals(getattr(self.portal.doc1, 'allow_discussion', None),
|
||||
self.assertEquals(getattr(self.portal.doc1, 'allow_discussion', None),
|
||||
False)
|
||||
|
||||
# Disallow discussion on the Document content type again
|
||||
document_fti.manage_changeProperties(allow_discussion = False)
|
||||
self.assertEquals(portal_discussion.isDiscussionAllowedFor(
|
||||
self.portal.doc1), False)
|
||||
self.assertEquals(self.portal.doc1.getTypeInfo().allowDiscussion(),
|
||||
self.assertEquals(self.portal.doc1.getTypeInfo().allowDiscussion(),
|
||||
False)
|
||||
|
||||
# Now we override allow_discussion again (True) for the Document
|
||||
@@ -226,14 +226,14 @@ class ConversationTest(PloneTestCase):
|
||||
self.portal_discussion.overrideDiscussionFor(self.portal.doc1, True)
|
||||
self.assertEquals(portal_discussion.isDiscussionAllowedFor(
|
||||
self.portal.doc1), True)
|
||||
self.assertEquals(getattr(self.portal.doc1, 'allow_discussion', None),
|
||||
self.assertEquals(getattr(self.portal.doc1, 'allow_discussion', None),
|
||||
True)
|
||||
|
||||
def test_comments_enabled_on_doc_in_subfolder(self):
|
||||
typetool = self.portal.portal_types
|
||||
typetool.constructContent('Folder', self.portal, 'folder1')
|
||||
typetool.constructContent('Document', self.portal.folder1, 'doc2')
|
||||
|
||||
|
||||
folder = self.portal.folder1
|
||||
folder.allowDiscussion(False)
|
||||
self.assertFalse(hasattr(aq_base(folder), 'allow_discussion'))
|
||||
@@ -241,11 +241,11 @@ class ConversationTest(PloneTestCase):
|
||||
self.assertTrue(aq_base(folder).allow_discussion)
|
||||
folder.allowDiscussion(False)
|
||||
self.assertFalse(aq_base(folder).allow_discussion)
|
||||
|
||||
|
||||
doc = self.portal.folder1.doc2
|
||||
conversation = IConversation(doc)
|
||||
self.assertEquals(conversation.enabled(), False)
|
||||
|
||||
|
||||
# We have to allow discussion on Document content type, since
|
||||
# otherwise allow_discussion will always return False
|
||||
portal_types = getToolByName(self.portal, 'portal_types')
|
||||
@@ -409,7 +409,7 @@ class ConversationTest(PloneTestCase):
|
||||
# object, as we just want to check the Conversation object API.
|
||||
conversation = IConversation(self.portal.doc1)
|
||||
|
||||
# Add a comment. Note: in real life, we always create comments via the
|
||||
# Add a comment. Note: in real life, we always create comments via the
|
||||
# factory to allow different factories to be swapped in
|
||||
|
||||
comment1 = createObject('plone.Comment')
|
||||
@@ -571,9 +571,9 @@ class ConversationTest(PloneTestCase):
|
||||
new_comment3_id = conversation.addComment(comment3)
|
||||
|
||||
# check if the latest comment is exactly one day old
|
||||
self.assert_(conversation.last_comment_date < datetime.utcnow() -
|
||||
self.assert_(conversation.last_comment_date < datetime.utcnow() -
|
||||
timedelta(hours=23, minutes=59, seconds=59))
|
||||
self.assert_(conversation.last_comment_date >
|
||||
self.assert_(conversation.last_comment_date >
|
||||
datetime.utcnow() - timedelta(days=1, seconds=1))
|
||||
|
||||
# remove the latest comment
|
||||
@@ -581,9 +581,9 @@ class ConversationTest(PloneTestCase):
|
||||
|
||||
# check if the latest comment has been updated
|
||||
# the latest comment should be exactly two days old
|
||||
self.assert_(conversation.last_comment_date < datetime.utcnow() -
|
||||
self.assert_(conversation.last_comment_date < datetime.utcnow() -
|
||||
timedelta(days=1, hours=23, minutes=59, seconds=59))
|
||||
self.assert_(conversation.last_comment_date > datetime.utcnow() -
|
||||
self.assert_(conversation.last_comment_date > datetime.utcnow() -
|
||||
timedelta(days=2, seconds=1))
|
||||
|
||||
# remove the latest comment again
|
||||
@@ -591,9 +591,9 @@ class ConversationTest(PloneTestCase):
|
||||
|
||||
# check if the latest comment has been updated
|
||||
# the latest comment should be exactly four days old
|
||||
self.assert_(conversation.last_comment_date < datetime.utcnow() -
|
||||
self.assert_(conversation.last_comment_date < datetime.utcnow() -
|
||||
timedelta(days=3, hours=23, minutes=59, seconds=59))
|
||||
self.assert_(conversation.last_comment_date > datetime.utcnow() -
|
||||
self.assert_(conversation.last_comment_date > datetime.utcnow() -
|
||||
timedelta(days=4, seconds=2))
|
||||
|
||||
def test_get_comments_full(self):
|
||||
@@ -678,15 +678,15 @@ class ConversationTest(PloneTestCase):
|
||||
'++conversation++default')
|
||||
self.assert_(IConversation.providedBy(conversation))
|
||||
|
||||
self.assertEquals(('', 'plone', 'doc1', '++conversation++default'),
|
||||
self.assertEquals(('', 'plone', 'doc1', '++conversation++default'),
|
||||
conversation.getPhysicalPath())
|
||||
# XXX: conversation.absolute_url() returns different values dependent
|
||||
# on the Plone version used.
|
||||
# Plone 3.3:
|
||||
#self.assertEquals('plone/doc1/%2B%2Bconversation%2B%2Bdefault',
|
||||
#self.assertEquals('plone/doc1/%2B%2Bconversation%2B%2Bdefault',
|
||||
#conversation.absolute_url())
|
||||
# Plone 4:
|
||||
#self.assertEquals('http://nohost/plone/doc1/++conversation++default',
|
||||
#self.assertEquals('http://nohost/plone/doc1/++conversation++default',
|
||||
#conversation.absolute_url())
|
||||
|
||||
def test_parent(self):
|
||||
|
||||
@@ -9,9 +9,9 @@ try:
|
||||
import unittest2 as unittest
|
||||
import pprint
|
||||
import interlude
|
||||
|
||||
|
||||
from plone.testing import layered
|
||||
|
||||
|
||||
from plone.app.discussion.testing import \
|
||||
PLONE_APP_DISCUSSION_FUNCTIONAL_TESTING
|
||||
PLONE4 = True
|
||||
@@ -26,7 +26,7 @@ normal_testfiles = [
|
||||
]
|
||||
|
||||
if PLONE4:
|
||||
|
||||
|
||||
def test_suite():
|
||||
suite = unittest.TestSuite()
|
||||
suite.addTests([
|
||||
@@ -41,9 +41,9 @@ if PLONE4:
|
||||
return suite
|
||||
|
||||
else:
|
||||
|
||||
|
||||
def test_suite():
|
||||
return unittest.TestSuite([])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(defaultTest='test_suite')
|
||||
|
||||
@@ -17,14 +17,14 @@ from plone.indexer.delegate import DelegatingIndexerFactory
|
||||
|
||||
from plone.app.discussion import catalog
|
||||
|
||||
LONG_TEXT = """Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed
|
||||
diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,
|
||||
sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.
|
||||
Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit
|
||||
LONG_TEXT = """Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed
|
||||
diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,
|
||||
sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.
|
||||
Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit
|
||||
amet."""
|
||||
|
||||
LONG_TEXT_CUT = """Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed
|
||||
diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,
|
||||
LONG_TEXT_CUT = """Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed
|
||||
diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,
|
||||
sed diam voluptua. At [...]"""
|
||||
|
||||
|
||||
@@ -37,8 +37,8 @@ class ConversationIndexersTest(PloneTestCase):
|
||||
def afterSetUp(self):
|
||||
# First we need to create some content.
|
||||
self.loginAsPortalOwner()
|
||||
self.portal.invokeFactory(id='doc1',
|
||||
title='Document 1',
|
||||
self.portal.invokeFactory(id='doc1',
|
||||
title='Document 1',
|
||||
type_name='Document')
|
||||
|
||||
# Create a conversation.
|
||||
@@ -71,7 +71,7 @@ class ConversationIndexersTest(PloneTestCase):
|
||||
self.conversation = conversation
|
||||
|
||||
def test_conversation_total_comments(self):
|
||||
self.assert_(isinstance(catalog.total_comments,
|
||||
self.assert_(isinstance(catalog.total_comments,
|
||||
DelegatingIndexerFactory))
|
||||
self.assertEquals(catalog.total_comments(self.portal.doc1)(), 3)
|
||||
del self.conversation[self.new_id1]
|
||||
@@ -81,12 +81,12 @@ class ConversationIndexersTest(PloneTestCase):
|
||||
self.assertEquals(catalog.total_comments(self.portal.doc1)(), 0)
|
||||
|
||||
def test_conversation_last_comment_date(self):
|
||||
self.assert_(isinstance(catalog.last_comment_date,
|
||||
self.assert_(isinstance(catalog.last_comment_date,
|
||||
DelegatingIndexerFactory))
|
||||
self.assertEquals(catalog.last_comment_date(self.portal.doc1)(),
|
||||
self.assertEquals(catalog.last_comment_date(self.portal.doc1)(),
|
||||
datetime(2009, 4, 12, 11, 12, 12))
|
||||
del self.conversation[self.new_id3]
|
||||
self.assertEquals(catalog.last_comment_date(self.portal.doc1)(),
|
||||
self.assertEquals(catalog.last_comment_date(self.portal.doc1)(),
|
||||
datetime(2007, 12, 13, 4, 18, 12))
|
||||
del self.conversation[self.new_id2]
|
||||
del self.conversation[self.new_id1]
|
||||
@@ -94,11 +94,12 @@ class ConversationIndexersTest(PloneTestCase):
|
||||
|
||||
def test_conversation_commentators(self):
|
||||
pass
|
||||
#self.assertEquals(catalog.commentators(self.portal.doc1)(),
|
||||
#self.assertEquals(catalog.commentators(self.portal.doc1)(),
|
||||
# ('Jim', 'Emma', 'Lukas'))
|
||||
#self.assert_(isinstance(catalog.commentators,
|
||||
#self.assert_(isinstance(catalog.commentators,
|
||||
# DelegatingIndexerFactory))
|
||||
|
||||
|
||||
class CommentIndexersTest(PloneTestCase):
|
||||
|
||||
layer = DiscussionLayer
|
||||
@@ -106,15 +107,15 @@ class CommentIndexersTest(PloneTestCase):
|
||||
def afterSetUp(self):
|
||||
# First we need to create some content.
|
||||
self.loginAsPortalOwner()
|
||||
self.portal.invokeFactory(id='doc1',
|
||||
title='Document 1',
|
||||
type_name='Document')
|
||||
self.portal.invokeFactory(id='doc1',
|
||||
title='Document 1',
|
||||
type_name='Document')
|
||||
|
||||
# Create a conversation. In this case we doesn't assign it to an
|
||||
# object, as we just want to check the Conversation object API.
|
||||
conversation = IConversation(self.portal.doc1)
|
||||
|
||||
# Add a comment. Note: in real life, we always create comments via the
|
||||
# Add a comment. Note: in real life, we always create comments via the
|
||||
# factory to allow different factories to be swapped in
|
||||
|
||||
comment = createObject('plone.Comment')
|
||||
@@ -132,7 +133,7 @@ class CommentIndexersTest(PloneTestCase):
|
||||
self.assert_(isinstance(catalog.title, DelegatingIndexerFactory))
|
||||
|
||||
def test_description(self):
|
||||
self.assertEquals(catalog.description(self.comment)(),
|
||||
self.assertEquals(catalog.description(self.comment)(),
|
||||
'Lorem ipsum dolor sit amet.')
|
||||
self.assert_(isinstance(catalog.description, DelegatingIndexerFactory))
|
||||
|
||||
@@ -144,23 +145,23 @@ class CommentIndexersTest(PloneTestCase):
|
||||
comment_long.text = LONG_TEXT
|
||||
|
||||
self.conversation.addComment(comment_long)
|
||||
self.assertEquals(catalog.description(comment_long)(),
|
||||
LONG_TEXT_CUT.replace("\n", ""))
|
||||
self.assertEquals(catalog.description(comment_long)(),
|
||||
LONG_TEXT_CUT.replace("\n", " "))
|
||||
|
||||
def test_dates(self):
|
||||
# Test if created, modified, effective etc. are set correctly
|
||||
self.assertEquals(catalog.created(self.comment)(),
|
||||
self.assertEquals(catalog.created(self.comment)(),
|
||||
DateTime(2006, 9, 17, 14, 18, 12))
|
||||
self.assertEquals(catalog.effective(self.comment)(),
|
||||
self.assertEquals(catalog.effective(self.comment)(),
|
||||
DateTime(2006, 9, 17, 14, 18, 12))
|
||||
self.assertEquals(catalog.modified(self.comment)(),
|
||||
self.assertEquals(catalog.modified(self.comment)(),
|
||||
DateTime(2008, 3, 12, 7, 32, 52))
|
||||
|
||||
def test_searchable_text(self):
|
||||
# Test if searchable text is a concatenation of title and comment text
|
||||
self.assertEquals(catalog.searchable_text(self.comment)(),
|
||||
self.assertEquals(catalog.searchable_text(self.comment)(),
|
||||
('Lorem ipsum dolor sit amet.'))
|
||||
self.assert_(isinstance(catalog.searchable_text,
|
||||
self.assert_(isinstance(catalog.searchable_text,
|
||||
DelegatingIndexerFactory))
|
||||
|
||||
def test_creator(self):
|
||||
@@ -171,5 +172,6 @@ class CommentIndexersTest(PloneTestCase):
|
||||
# object the comment was added to
|
||||
self.assertEquals(catalog.in_response_to(self.comment)(), 'Document 1')
|
||||
|
||||
|
||||
def test_suite():
|
||||
return unittest.defaultTestLoader.loadTestsFromName(__name__)
|
||||
|
||||
@@ -18,11 +18,11 @@ from plone.app.discussion.interfaces import IConversation, IComment
|
||||
class MigrationTest(PloneTestCase):
|
||||
|
||||
layer = DiscussionLayer
|
||||
|
||||
|
||||
def afterSetUp(self):
|
||||
self.loginAsPortalOwner()
|
||||
self.portal.invokeFactory(id='doc',
|
||||
title='Document 1',
|
||||
title='Document 1',
|
||||
type_name='Document')
|
||||
# Create a document
|
||||
self.discussion = getToolByName(self.portal, 'portal_discussion', None)
|
||||
@@ -35,7 +35,7 @@ class MigrationTest(PloneTestCase):
|
||||
request.set("test", True)
|
||||
context = getattr(self.portal, 'doc')
|
||||
self.view = View(context, request)
|
||||
self.workflow.setChainForPortalTypes(('Discussion Item',),
|
||||
self.workflow.setChainForPortalTypes(('Discussion Item',),
|
||||
'comment_review_workflow')
|
||||
|
||||
self.doc = self.portal.doc
|
||||
@@ -59,7 +59,7 @@ class MigrationTest(PloneTestCase):
|
||||
self.view()
|
||||
|
||||
# Make sure a conversation has been created
|
||||
self.failUnless('plone.app.discussion:conversation' in
|
||||
self.failUnless('plone.app.discussion:conversation' in
|
||||
IAnnotations(self.doc))
|
||||
conversation = IConversation(self.doc)
|
||||
|
||||
@@ -71,9 +71,9 @@ class MigrationTest(PloneTestCase):
|
||||
self.assertEquals(comment1.Title(), 'Jim on Document 1')
|
||||
self.assertEquals(comment1.text, 'My Text')
|
||||
self.assertEquals(comment1.Creator(), 'Jim')
|
||||
self.assertEquals(comment1.creation_date,
|
||||
self.assertEquals(comment1.creation_date,
|
||||
datetime(2003, 3, 11, 9, 28, 6))
|
||||
self.assertEquals(comment1.modification_date,
|
||||
self.assertEquals(comment1.modification_date,
|
||||
datetime(2009, 7, 12, 19, 38, 7))
|
||||
self.assertEquals(
|
||||
[{'comment': comment1, 'depth': 0, 'id': long(comment1.id)},]
|
||||
|
||||
@@ -22,7 +22,7 @@ class ModerationViewTest(PloneTestCase):
|
||||
self.loginAsPortalOwner()
|
||||
typetool = self.portal.portal_types
|
||||
typetool.constructContent('Document', self.portal, 'doc1')
|
||||
|
||||
|
||||
self.portal_discussion = getToolByName(self.portal,
|
||||
'portal_discussion',
|
||||
None)
|
||||
@@ -66,7 +66,7 @@ class ModerationViewTest(PloneTestCase):
|
||||
'++conversation++default/%s' % new_id_3)
|
||||
|
||||
def test_moderation_enabled(self):
|
||||
"""Make sure that moderation_enabled returns true if the comment
|
||||
"""Make sure that moderation_enabled returns true if the comment
|
||||
workflow implements a 'pending' state.
|
||||
"""
|
||||
# The one_state_workflow does not have a 'pending' state
|
||||
@@ -81,10 +81,10 @@ class ModerationViewTest(PloneTestCase):
|
||||
def test_old_comments_not_shown_in_moderation_view(self):
|
||||
# Create an old comment and make sure it is not shown
|
||||
# in the moderation view.
|
||||
|
||||
|
||||
# Create old comment
|
||||
discussion = getToolByName(self.portal, 'portal_discussion', None)
|
||||
discussion.overrideDiscussionFor(self.portal.doc1, 1)
|
||||
discussion.overrideDiscussionFor(self.portal.doc1, 1)
|
||||
talkback = discussion.getDiscussionFor(self.portal.doc1)
|
||||
self.portal.doc1.talkback.createReply('My Title', 'My Text', Creator='Jim')
|
||||
reply = talkback.getReplies()[0]
|
||||
@@ -96,7 +96,7 @@ class ModerationViewTest(PloneTestCase):
|
||||
self.failUnless('Jim' in reply.listCreators())
|
||||
self.assertEquals(talkback.replyCount(self.portal.doc1), 1)
|
||||
self.assertEquals(reply.inReplyTo(), self.portal.doc1)
|
||||
|
||||
|
||||
# Make sure only the two new comments are shown
|
||||
self.view()
|
||||
self.assertEquals(len(self.view.comments), 3)
|
||||
@@ -110,10 +110,10 @@ class ModerationBulkActionsViewTest(PloneTestCase):
|
||||
self.loginAsPortalOwner()
|
||||
typetool = self.portal.portal_types
|
||||
typetool.constructContent('Document', self.portal, 'doc1')
|
||||
self.wf = getToolByName(self.portal,
|
||||
self.wf = getToolByName(self.portal,
|
||||
'portal_workflow',
|
||||
None)
|
||||
|
||||
|
||||
self.request = self.app.REQUEST
|
||||
self.context = self.portal
|
||||
self.portal.portal_workflow.setChainForPortalTypes(
|
||||
@@ -149,7 +149,7 @@ class ModerationBulkActionsViewTest(PloneTestCase):
|
||||
'++conversation++default/%s' % new_id_3)
|
||||
|
||||
self.conversation = conversation
|
||||
|
||||
|
||||
def test_default_bulkaction(self):
|
||||
# Make sure no error is raised when no bulk actions has been supplied
|
||||
self.request = self.app.REQUEST
|
||||
@@ -158,14 +158,14 @@ class ModerationBulkActionsViewTest(PloneTestCase):
|
||||
self.request.set('paths', ['/'.join(self.comment1.getPhysicalPath())])
|
||||
view = BulkActionsView(self.context, self.request)
|
||||
self.failIf(view())
|
||||
|
||||
|
||||
def test_retract(self):
|
||||
self.request = self.app.REQUEST
|
||||
self.context = self.portal
|
||||
self.request.set('form.select.BulkAction', 'retract')
|
||||
self.request.set('paths', ['/'.join(self.comment1.getPhysicalPath())])
|
||||
view = BulkActionsView(self.context, self.request)
|
||||
|
||||
|
||||
self.assertRaises(NotImplementedError,
|
||||
view)
|
||||
|
||||
@@ -173,10 +173,10 @@ class ModerationBulkActionsViewTest(PloneTestCase):
|
||||
self.request = self.app.REQUEST
|
||||
self.context = self.portal
|
||||
self.request.set('form.select.BulkAction', 'publish')
|
||||
self.request.set('paths', ['/'.join(self.comment1.getPhysicalPath())])
|
||||
self.request.set('paths', ['/'.join(self.comment1.getPhysicalPath())])
|
||||
view = BulkActionsView(self.context, self.request)
|
||||
view()
|
||||
|
||||
|
||||
# Count published comments
|
||||
published_comments = 0
|
||||
for r in self.conversation.getThreads():
|
||||
@@ -184,17 +184,17 @@ class ModerationBulkActionsViewTest(PloneTestCase):
|
||||
workflow_status = self.wf.getInfoFor(comment_obj, 'review_state')
|
||||
if workflow_status == 'published':
|
||||
published_comments += 1
|
||||
|
||||
|
||||
# Make sure the comment has been published
|
||||
self.assertEquals(published_comments, 1)
|
||||
|
||||
|
||||
def test_mark_as_spam(self):
|
||||
self.request = self.app.REQUEST
|
||||
self.context = self.portal
|
||||
self.request.set('form.select.BulkAction', 'mark_as_spam')
|
||||
self.request.set('paths', ['/'.join(self.comment1.getPhysicalPath())])
|
||||
view = BulkActionsView(self.context, self.request)
|
||||
|
||||
|
||||
self.assertRaises(NotImplementedError,
|
||||
view)
|
||||
|
||||
@@ -204,14 +204,14 @@ class ModerationBulkActionsViewTest(PloneTestCase):
|
||||
|
||||
# Initially we have three comments
|
||||
self.assertEquals(self.conversation.total_comments, 3)
|
||||
|
||||
|
||||
# Delete two comments with bulk actions
|
||||
self.request.set('form.select.BulkAction', 'delete')
|
||||
self.request.set('paths', ['/'.join(self.comment1.getPhysicalPath()),
|
||||
'/'.join(self.comment3.getPhysicalPath())])
|
||||
'/'.join(self.comment3.getPhysicalPath())])
|
||||
view = BulkActionsView(self.context, self.request)
|
||||
view()
|
||||
|
||||
|
||||
# Make sure that the two comments have been deleted
|
||||
self.assertEquals(self.conversation.total_comments, 1)
|
||||
comment = self.conversation.getComments().next()
|
||||
|
||||
@@ -50,9 +50,9 @@ class TestUserNotificationUnit(PloneTestCase):
|
||||
self.portal.MailHost = self.portal._original_MailHost
|
||||
sm = getSiteManager(context=self.portal)
|
||||
sm.unregisterUtility(provided=IMailHost)
|
||||
sm.registerUtility(aq_base(self.portal._original_MailHost),
|
||||
sm.registerUtility(aq_base(self.portal._original_MailHost),
|
||||
provided=IMailHost)
|
||||
|
||||
|
||||
def test_notify_user(self):
|
||||
# Add a comment with user notification enabled. Add another comment
|
||||
# and make sure an email is send to the user of the first comment.
|
||||
@@ -74,7 +74,7 @@ class TestUserNotificationUnit(PloneTestCase):
|
||||
# We expect the headers to be properly header encoded (7-bit):
|
||||
#>>> 'Subject: =?utf-8?q?Some_t=C3=A4st_subject=2E?=' in msg
|
||||
#True
|
||||
# # The output should be encoded in a reasonable manner
|
||||
# # The output should be encoded in a reasonable manner
|
||||
# (in this case quoted-printable):
|
||||
#>>> msg
|
||||
#'...Another t=C3=A4st message...You are receiving this mail \
|
||||
@@ -97,9 +97,9 @@ class TestUserNotificationUnit(PloneTestCase):
|
||||
comment = createObject('plone.Comment')
|
||||
comment.text = 'Comment text'
|
||||
self.conversation.addComment(comment)
|
||||
|
||||
|
||||
self.assertEquals(len(self.mailhost.messages), 0)
|
||||
|
||||
|
||||
def test_do_not_notify_user_when_email_address_is_given(self):
|
||||
comment = createObject('plone.Comment')
|
||||
comment.text = 'Comment text'
|
||||
@@ -109,7 +109,7 @@ class TestUserNotificationUnit(PloneTestCase):
|
||||
comment = createObject('plone.Comment')
|
||||
comment.text = 'Comment text'
|
||||
self.conversation.addComment(comment)
|
||||
|
||||
|
||||
self.assertEquals(len(self.mailhost.messages), 0)
|
||||
|
||||
def test_do_not_notify_user_when_no_sender_is_available(self):
|
||||
@@ -126,7 +126,7 @@ class TestUserNotificationUnit(PloneTestCase):
|
||||
comment = createObject('plone.Comment')
|
||||
comment.text = 'Comment text'
|
||||
self.conversation.addComment(comment)
|
||||
|
||||
|
||||
self.assertEquals(len(self.mailhost.messages), 0)
|
||||
|
||||
def test_notify_only_once(self):
|
||||
@@ -179,13 +179,13 @@ class TestModeratorNotificationUnit(PloneTestCase):
|
||||
# We need to fake a valid mail setup
|
||||
self.portal.email_from_address = "portal@plone.test"
|
||||
self.mailhost = self.portal.MailHost
|
||||
|
||||
|
||||
# Enable comment moderation
|
||||
self.portal.portal_types['Document'].allow_discussion = True
|
||||
self.portal.portal_workflow.setChainForPortalTypes(
|
||||
('Discussion Item',),
|
||||
('comment_review_workflow',))
|
||||
|
||||
|
||||
# Enable moderator notification setting
|
||||
registry = queryUtility(IRegistry)
|
||||
registry['plone.app.discussion.interfaces.IDiscussionSettings.' +
|
||||
@@ -201,9 +201,9 @@ class TestModeratorNotificationUnit(PloneTestCase):
|
||||
self.portal.MailHost = self.portal._original_MailHost
|
||||
sm = getSiteManager(context=self.portal)
|
||||
sm.unregisterUtility(provided=IMailHost)
|
||||
sm.registerUtility(aq_base(self.portal._original_MailHost),
|
||||
sm.registerUtility(aq_base(self.portal._original_MailHost),
|
||||
provided=IMailHost)
|
||||
|
||||
|
||||
def test_notify_moderator(self):
|
||||
# Add a comment and make sure an email is send to the moderator.
|
||||
comment = createObject('plone.Comment')
|
||||
@@ -213,7 +213,7 @@ class TestModeratorNotificationUnit(PloneTestCase):
|
||||
self.assertEquals(len(self.mailhost.messages), 1)
|
||||
self.failUnless(self.mailhost.messages[0])
|
||||
msg = self.mailhost.messages[0]
|
||||
|
||||
|
||||
if not isinstance(msg, str):
|
||||
# Plone 3
|
||||
self.failUnless('portal@plone.test' in msg.mfrom)
|
||||
@@ -221,17 +221,17 @@ class TestModeratorNotificationUnit(PloneTestCase):
|
||||
else:
|
||||
#Plone 4
|
||||
self.failUnless('To: portal@plone.test' in msg)
|
||||
self.failUnless('From: portal@plone.test' in msg)
|
||||
self.failUnless('From: portal@plone.test' in msg)
|
||||
|
||||
#We expect the headers to be properly header encoded (7-bit):
|
||||
#>>> 'Subject: =?utf-8?q?Some_t=C3=A4st_subject=2E?=' in msg
|
||||
#True
|
||||
|
||||
#The output should be encoded in a reasonable manner (in this case
|
||||
#The output should be encoded in a reasonable manner (in this case
|
||||
# quoted-printable):
|
||||
#>>> msg
|
||||
#'...Another t=C3=A4st message...You are receiving this mail because
|
||||
# T=C3=A4st user\ntest@plone.test...is sending feedback about the site
|
||||
#'...Another t=C3=A4st message...You are receiving this mail because
|
||||
# T=C3=A4st user\ntest@plone.test...is sending feedback about the site
|
||||
# you administer at...
|
||||
|
||||
def test_do_not_notify_moderator_when_no_sender_is_available(self):
|
||||
@@ -243,9 +243,9 @@ class TestModeratorNotificationUnit(PloneTestCase):
|
||||
comment.text = 'Comment text'
|
||||
self.conversation.addComment(comment)
|
||||
self.assertEquals(len(self.mailhost.messages), 0)
|
||||
|
||||
|
||||
def test_do_not_notify_moderator_when_notification_is_disabled(self):
|
||||
# Disable moderator notification setting and make sure no email is send
|
||||
# Disable moderator notification setting and make sure no email is send
|
||||
# to the moderator.
|
||||
registry = queryUtility(IRegistry)
|
||||
registry['plone.app.discussion.interfaces.IDiscussionSettings.' +
|
||||
@@ -263,7 +263,7 @@ class TestModeratorNotificationUnit(PloneTestCase):
|
||||
self.portal.portal_workflow.setChainForPortalTypes(
|
||||
('Discussion Item',),
|
||||
('one_state_workflow',))
|
||||
|
||||
|
||||
comment = createObject('plone.Comment')
|
||||
comment.text = 'Comment text'
|
||||
self.conversation.addComment(comment)
|
||||
|
||||
@@ -14,8 +14,8 @@ class ToolTest(PloneTestCase):
|
||||
def afterSetUp(self):
|
||||
# First we need to create some content.
|
||||
self.loginAsPortalOwner()
|
||||
self.portal.invokeFactory(id='doc1',
|
||||
title='Document 1',
|
||||
self.portal.invokeFactory(id='doc1',
|
||||
title='Document 1',
|
||||
type_name='Document')
|
||||
|
||||
def test_tool_indexing(self):
|
||||
|
||||
@@ -23,7 +23,7 @@ class WorkflowSetupTest(PloneTestCase):
|
||||
"""
|
||||
|
||||
layer = DiscussionLayer
|
||||
|
||||
|
||||
def afterSetUp(self):
|
||||
"""Create a document and allow discussion.
|
||||
"""
|
||||
@@ -31,13 +31,13 @@ class WorkflowSetupTest(PloneTestCase):
|
||||
self.portal_discussion = self.portal.portal_discussion
|
||||
self.folder.invokeFactory('Document', 'doc1')
|
||||
self.doc = self.folder.doc1
|
||||
|
||||
|
||||
def test_workflows_installed(self):
|
||||
"""Make sure both comment workflows have been installed properly.
|
||||
"""
|
||||
self.failUnless('one_state_workflow' in
|
||||
self.failUnless('one_state_workflow' in
|
||||
self.portal.portal_workflow.objectIds())
|
||||
self.failUnless('comment_review_workflow' in
|
||||
self.failUnless('comment_review_workflow' in
|
||||
self.portal.portal_workflow.objectIds())
|
||||
|
||||
def test_default_workflow(self):
|
||||
@@ -46,7 +46,7 @@ class WorkflowSetupTest(PloneTestCase):
|
||||
self.assertEquals(('one_state_workflow',),
|
||||
self.portal.portal_workflow.getChainForPortalType(
|
||||
'Discussion Item'))
|
||||
|
||||
|
||||
def test_review_comments_permission(self):
|
||||
#'Review comments' in self.portal.permissionsOfRole('Admin')
|
||||
|
||||
@@ -65,12 +65,12 @@ class PermissionsSetupTest(PloneTestCase):
|
||||
"""
|
||||
|
||||
layer = DiscussionLayer
|
||||
|
||||
|
||||
def afterSetUp(self):
|
||||
portal = self.portal
|
||||
mtool = self.portal.portal_membership
|
||||
self.checkPermission = mtool.checkPermission
|
||||
|
||||
|
||||
def test_reply_to_item_permission_assigned(self):
|
||||
"""Make sure the 'Reply to item' permission is properly assigned.
|
||||
By default this permission is assigned to 'Member' and 'Manager'.
|
||||
@@ -96,7 +96,7 @@ class CommentOneStateWorkflowTest(PloneTestCase):
|
||||
"""
|
||||
|
||||
layer = DiscussionLayer
|
||||
|
||||
|
||||
def afterSetUp(self):
|
||||
"""Create a document with comments and enable the one.
|
||||
"""
|
||||
@@ -106,31 +106,31 @@ class CommentOneStateWorkflowTest(PloneTestCase):
|
||||
'one_state_workflow')
|
||||
self.folder.invokeFactory('Document', 'doc1')
|
||||
self.doc = self.folder.doc1
|
||||
|
||||
|
||||
# Add a comment
|
||||
conversation = IConversation(self.folder.doc1)
|
||||
comment = createObject('plone.Comment')
|
||||
comment.text = 'Comment text'
|
||||
cid = conversation.addComment(comment)
|
||||
|
||||
|
||||
self.comment = self.folder.doc1.restrictedTraverse(\
|
||||
'++conversation++default/%s' % cid)
|
||||
|
||||
|
||||
self.portal.acl_users._doAddUser('member', 'secret', ['Member'], [])
|
||||
self.portal.acl_users._doAddUser('reviewer', 'secret', ['Reviewer'], [])
|
||||
self.portal.acl_users._doAddUser('manager', 'secret', ['Manager'], [])
|
||||
self.portal.acl_users._doAddUser('editor' , ' secret', ['Editor'],[])
|
||||
self.portal.acl_users._doAddUser('reader', 'secret', ['Reader'], [])
|
||||
|
||||
|
||||
def test_initial_workflow_state(self):
|
||||
"""Make sure the initial workflow state of a comment is 'published'.
|
||||
"""
|
||||
self.assertEqual(self.workflow.getInfoFor(self.doc, 'review_state'),
|
||||
self.assertEqual(self.workflow.getInfoFor(self.doc, 'review_state'),
|
||||
'published')
|
||||
|
||||
|
||||
def test_view_comments(self):
|
||||
"""Make sure published comments can be viewed by everyone.
|
||||
"""
|
||||
"""
|
||||
# Owner is allowed
|
||||
#self.login(default_user)
|
||||
#self.failUnless(checkPerm(View, self.doc))
|
||||
@@ -149,14 +149,14 @@ class CommentOneStateWorkflowTest(PloneTestCase):
|
||||
# Reader is allowed
|
||||
self.login('reader')
|
||||
self.failUnless(checkPerm(View, self.comment))
|
||||
|
||||
|
||||
|
||||
class CommentReviewWorkflowTest(PloneTestCase):
|
||||
"""Test the comment_review_workflow that ships with plone.app.discussion.
|
||||
"""
|
||||
|
||||
layer = DiscussionLayer
|
||||
|
||||
|
||||
def afterSetUp(self):
|
||||
# Allow discussion and
|
||||
self.loginAsPortalOwner()
|
||||
@@ -217,7 +217,7 @@ class CommentReviewWorkflowTest(PloneTestCase):
|
||||
def test_publish(self):
|
||||
self.portal.REQUEST.form['comment_id'] = self.comment_id
|
||||
self.portal.REQUEST.form['workflow_action'] = 'publish'
|
||||
self.assertEquals('pending',
|
||||
self.assertEquals('pending',
|
||||
self.portal.portal_workflow.getInfoFor(
|
||||
self.comment, 'review_state'))
|
||||
view = self.comment.restrictedTraverse('@@moderate-publish-comment')
|
||||
|
||||
Reference in New Issue
Block a user