From fa7a1acd6457ddffd8686e6a61e32053f4ee1f1f Mon Sep 17 00:00:00 2001 From: Andreas Zeidler Date: Thu, 15 Aug 2013 00:00:42 +0200 Subject: [PATCH 1/2] add buildout configuration for standalone testing --- buildout.cfg | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 buildout.cfg diff --git a/buildout.cfg b/buildout.cfg new file mode 100644 index 0000000..60544df --- /dev/null +++ b/buildout.cfg @@ -0,0 +1,7 @@ +[buildout] +extends = https://raw.github.com/collective/buildout.plonetest/master/test-4.3.x.cfg +package-name = plone.app.discussion +package-extras = [test] + +[versions] +plone.app.discussion = From b02778939127f43446726204e62779befc8d7d07 Mon Sep 17 00:00:00 2001 From: Andreas Zeidler Date: Thu, 15 Aug 2013 00:01:22 +0200 Subject: [PATCH 2/2] prevent the viewlet from raising an error for objects that are not annotatable --- plone/app/discussion/browser/comments.py | 5 ++++- plone/app/discussion/tests/test_comments_viewlet.py | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/plone/app/discussion/browser/comments.py b/plone/app/discussion/browser/comments.py index 529df18..bcf5dbe 100644 --- a/plone/app/discussion/browser/comments.py +++ b/plone/app/discussion/browser/comments.py @@ -358,7 +358,10 @@ class CommentsViewlet(ViewletBase): returned with workflow actions. """ context = aq_inner(self.context) - conversation = IConversation(context) + conversation = IConversation(context, None) + + if conversation is None: + return iter([]) wf = getToolByName(context, 'portal_workflow') diff --git a/plone/app/discussion/tests/test_comments_viewlet.py b/plone/app/discussion/tests/test_comments_viewlet.py index 1844b28..8b742c8 100644 --- a/plone/app/discussion/tests/test_comments_viewlet.py +++ b/plone/app/discussion/tests/test_comments_viewlet.py @@ -370,6 +370,14 @@ class TestCommentsViewlet(unittest.TestCase): replies.next() self.assertRaises(StopIteration, replies.next) + def test_get_replies_on_non_annotatable_object(self): + context = self.portal.MailHost # the mail host is not annotatable + viewlet = CommentsViewlet(context, self.request, None, None) + replies = viewlet.get_replies() + self.assertEqual(len(tuple(replies)), 0) + replies = viewlet.get_replies() + self.assertRaises(StopIteration, replies.next) + def test_get_replies_with_workflow_actions(self): self.assertFalse(self.viewlet.get_replies(workflow_actions=True)) comment = createObject('plone.Comment')