From 81cba38a74865d38d18377e152603326ababc821 Mon Sep 17 00:00:00 2001 From: Timo Stollenwerk Date: Thu, 2 Sep 2010 20:00:43 +0000 Subject: [PATCH] Comment form test added. svn path=/plone.app.discussion/trunk/; revision=39608 --- plone/app/discussion/tests/test_comment.py | 2 + .../discussion/tests/test_comments_viewlet.py | 87 +++++++++++++------ 2 files changed, 64 insertions(+), 25 deletions(-) diff --git a/plone/app/discussion/tests/test_comment.py b/plone/app/discussion/tests/test_comment.py index 56d0548..ea4bab1 100644 --- a/plone/app/discussion/tests/test_comment.py +++ b/plone/app/discussion/tests/test_comment.py @@ -10,6 +10,7 @@ from plone.app.discussion.tests.layer import DiscussionLayer from plone.app.discussion.interfaces import IComment, IConversation, IReplies + class CommentTest(PloneTestCase): layer = DiscussionLayer @@ -127,6 +128,7 @@ class CommentTest(PloneTestCase): # TODO: is this correct? Redirect ist 301 self.assertEquals(200, self.app.REQUEST.response.getStatus()) + class RepliesTest(PloneTestCase): # test the IReplies adapter on a comment diff --git a/plone/app/discussion/tests/test_comments_viewlet.py b/plone/app/discussion/tests/test_comments_viewlet.py index 1510840..d21a793 100644 --- a/plone/app/discussion/tests/test_comments_viewlet.py +++ b/plone/app/discussion/tests/test_comments_viewlet.py @@ -2,10 +2,24 @@ import unittest from datetime import datetime +from Acquisition import Implicit + from zope.component import createObject, queryUtility from OFS.Image import Image +from zope.interface import alsoProvides +from zope.publisher.browser import TestRequest +from zope.annotation.interfaces import IAttributeAnnotatable +from z3c.form.interfaces import IFormLayer + +from zope.component import provideAdapter +from zope.publisher.interfaces.browser import IBrowserRequest +from zope.interface import Interface, implements + +from zope.interface import Interface, implements +from zope.component import getMultiAdapter + from plone.registry.interfaces import IRegistry from Products.CMFCore.utils import getToolByName @@ -15,6 +29,7 @@ from Products.PloneTestCase.ptc import PloneTestCase from Products.PloneTestCase.ptc import FunctionalTestCase 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.tests.layer import DiscussionLayer @@ -32,34 +47,56 @@ class TestCommentForm(PloneTestCase): None) self.membership_tool = getToolByName(self.folder, 'portal_membership') self.memberdata = self.portal.portal_memberdata - request = self.app.REQUEST - context = getattr(self.portal, 'doc1') - self.viewlet = CommentsViewlet(context, request, None, None) + self.request = self.app.REQUEST + self.context = getattr(self.portal, 'doc1') + self.viewlet = CommentsViewlet(self.context, self.request, None, None) def test_add_comment(self): - #form = CommentForm(self.viewlet, self.app.REQUEST) - #self.viewlet.form.render(form) - #self.viewlet.form.handleComment() - #from z3c.form.testing import TestRequest - #request = TestRequest(form={ - # 'form.widgets.title': u'bar', - # 'form.widgets.text': u'foo',} - #) - #cf = CommentForm(self.viewlet, request) - #cf.handleComments() - # Zope publisher uses Python list to mark