Fix ownership of comments.

This commit is contained in:
JeanMichel FRANCOIS
2013-11-04 16:30:14 +01:00
parent dcba2c2714
commit 410b8c998a
3 changed files with 29 additions and 0 deletions
@@ -120,6 +120,21 @@ class TestCommentForm(unittest.TestCase):
self.assertEqual(len(errors), 0)
self.assertFalse(commentForm.handleComment(commentForm, "foo"))
comments = IConversation(commentForm.context).getComments()
comments = [comment for comment in comments] # consume itertor
self.assertEqual(len(comments), 1)
for comment in comments:
self.assertEqual(comment.text, u"bar")
self.assertEqual(comment.creator, "test-user")
self.assertEqual(comment.getOwner().getUserName(), "test-user")
local_roles = comment.get_local_roles()
self.assertEqual(len(local_roles), 1)
userid, roles = local_roles[0]
self.assertEqual(userid, 'test-user')
self.assertEqual(len(roles), 1)
self.assertEqual(roles[0], 'Owner')
def test_add_anonymous_comment(self):
self.portal.doc1.allow_discussion = True
@@ -160,6 +175,16 @@ class TestCommentForm(unittest.TestCase):
self.assertEqual(len(errors), 0)
self.assertFalse(commentForm.handleComment(commentForm, "action"))
comments = IConversation(commentForm.context).getComments()
comments = [comment for comment in comments] # consume itertor
self.assertEqual(len(comments), 1)
for comment in IConversation(commentForm.context).getComments():
self.assertEqual(comment.text, u"bar")
self.assertIsNone(comment.creator)
roles = comment.get_local_roles()
self.assertEqual(len(roles), 0)
def test_can_not_add_comments_if_discussion_is_not_allowed(self):
"""Make sure that comments can't be posted if discussion is disabled.
"""