add comment test for the IReplies adapter for comments added.

svn path=/plone.app.discussion/trunk/; revision=27099
This commit is contained in:
Timo Stollenwerk 2009-05-25 07:02:11 +00:00
parent a948f15971
commit ac5d96250b
1 changed files with 67 additions and 30 deletions

View File

@ -5,7 +5,7 @@ from zope.component import createObject
from Products.PloneTestCase.ptc import PloneTestCase
from plone.app.discussion.tests.layer import DiscussionLayer
from plone.app.discussion.interfaces import IComment, IConversation
from plone.app.discussion.interfaces import IComment, IConversation, IReplies
class CommentTest(PloneTestCase):
@ -97,7 +97,44 @@ class RepliesTest(PloneTestCase):
typetool.constructContent('Document', self.portal, 'doc1')
def test_add_comment(self):
pass
# Add comments to a CommentReplies adapter
# 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)
# Pretend that we have traversed to the comment by aq wrapping it.
conversation = conversation.__of__(self.portal.doc1)
# Add a comment to the conversation
replies = IReplies(conversation)
comment = createObject('plone.Comment')
comment.title = 'Comment 1'
comment.text = 'Comment text'
new_id = replies.addComment(comment)
# Add a reply to the CommentReplies adapter of the first comment
re_comment = createObject('plone.Comment')
re_comment.title = 'Re: Comment 1'
re_comment.text = 'Comment text'
replies = IReplies(comment)
new_re_id = replies.addComment(re_comment)
# check that replies provides the IReplies interface
self.assert_(IReplies.providedBy(replies))
# Make sure our comment was added
self.failUnless(new_re_id in replies)
# Make sure it is also reflected in the conversation
self.failUnless(new_re_id in conversation)
# Make sure the conversation has the correct comment id
self.assertEquals(conversation[new_re_id].comment_id, new_re_id)
def test_delete_comment(self):
pass