import unittest from datetime import datetime, timedelta from plone.registry import Registry from zope.component import createObject, queryUtility from Acquisition import aq_base, aq_parent, aq_inner from OFS.Image import Image from plone.app.vocabularies.types import BAD_TYPES from plone.registry.interfaces import IRegistry from Products.CMFCore.FSImage import FSImage from Products.CMFCore.utils import getToolByName from Products.CMFPlone.tests import dummy from Products.Five.testbrowser import Browser from Products.PloneTestCase.ptc import PloneTestCase from Products.PloneTestCase.ptc import FunctionalTestCase from plone.app.discussion.browser.comments import CommentForm, CommentsViewlet from plone.app.discussion.interfaces import IConversation, IComment from plone.app.discussion.interfaces import IReplies, IDiscussionSettings from plone.app.discussion.tests.layer import DiscussionLayer class TestCommentForm(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', 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) 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