collection test added (failing).

svn path=/plone.app.discussion/trunk/; revision=33780
This commit is contained in:
Timo Stollenwerk 2010-02-05 22:40:38 +00:00
parent 89a9d879f4
commit 2ffbe75611
2 changed files with 24 additions and 6 deletions

View File

@ -186,7 +186,7 @@ class CommentCatalogTest(PloneTestCase):
def afterSetUp(self): def afterSetUp(self):
# First we need to create some content. # First we need to create some content.
self.loginAsPortalOwner() self.loginAsPortalOwner()
typetool = self.portal.portal_types self.typetool = typetool = self.portal.portal_types
typetool.constructContent('Document', self.portal, 'doc1') typetool.constructContent('Document', self.portal, 'doc1')
self.catalog = getToolByName(self.portal, 'portal_catalog') self.catalog = getToolByName(self.portal, 'portal_catalog')
@ -294,5 +294,19 @@ class CommentCatalogTest(PloneTestCase):
self.failUnless(brains) self.failUnless(brains)
self.assertEquals(len(brains), 6) self.assertEquals(len(brains), 6)
def test_collection(self):
self.typetool.constructContent('Topic', self.portal, 'topic')
topic = self.portal.topic
topic.addCriterion('type_crit', 'ATPortalTypeCriterion')
self.failUnless('crit__type_crit_ATPortalTypeCriterion' in topic)
topic.getCriterion('type_crit_ATPortalTypeCriterion').setValue('Comment')
query = topic.buildQuery()
self.assertEquals(len(query), 1)
self.assertEquals(query['type_crit'], ('Comment',))
# XXX: FAIL
#self.assertEquals(len(topic.queryCatalog()), 1)
def test_suite(): def test_suite():
return unittest.defaultTestLoader.loadTestsFromName(__name__) return unittest.defaultTestLoader.loadTestsFromName(__name__)

View File

@ -20,9 +20,9 @@ from Products.Five.testbrowser import Browser
from Products.PloneTestCase.ptc import PloneTestCase from Products.PloneTestCase.ptc import PloneTestCase
from Products.PloneTestCase.ptc import FunctionalTestCase from Products.PloneTestCase.ptc import FunctionalTestCase
from plone.app.discussion.browser.comments import CommentForm, CommentsViewlet
from plone.app.discussion.browser.comments import CommentsViewlet from plone.app.discussion.interfaces import IConversation, IComment
from plone.app.discussion.interfaces import IConversation, IComment, IReplies, IDiscussionSettings from plone.app.discussion.interfaces import IReplies, IDiscussionSettings
from plone.app.discussion.tests.layer import DiscussionLayer from plone.app.discussion.tests.layer import DiscussionLayer
@ -41,13 +41,17 @@ class TestCommentForm(PloneTestCase):
context = getattr(self.portal, 'doc1') context = getattr(self.portal, 'doc1')
self.viewlet = CommentsViewlet(context, request, None, None) 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 from z3c.form.testing import TestRequest
request = TestRequest(form={ request = TestRequest(form={
'form.widgets.title': u'bar', 'form.widgets.title': u'bar',
'form.widgets.text': u'foo',} 'form.widgets.text': u'foo',}
) )
#from plone.app.discussion.browser.comments import CommentForm cf = CommentForm(self.viewlet, request)
#cf = CommentForm(self.portal, request) #cf.handleComments()
# Zope publisher uses Python list to mark <select> values # Zope publisher uses Python list to mark <select> values
#self.portal.REQUEST["form.widgets.title"] = u"foo" #self.portal.REQUEST["form.widgets.title"] = u"foo"
#self.portal.REQUEST["form.widgets.title"] = u"Search" #self.portal.REQUEST["form.widgets.title"] = u"Search"