From 2ffbe75611f5acdbd9602616b26d5b8ef7b01349 Mon Sep 17 00:00:00 2001 From: Timo Stollenwerk Date: Fri, 5 Feb 2010 22:40:38 +0000 Subject: [PATCH] collection test added (failing). svn path=/plone.app.discussion/trunk/; revision=33780 --- plone/app/discussion/tests/test_catalog.py | 16 +++++++++++++++- .../discussion/tests/test_comments_viewlet.py | 14 +++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/plone/app/discussion/tests/test_catalog.py b/plone/app/discussion/tests/test_catalog.py index 355484d..d8458a6 100644 --- a/plone/app/discussion/tests/test_catalog.py +++ b/plone/app/discussion/tests/test_catalog.py @@ -186,7 +186,7 @@ class CommentCatalogTest(PloneTestCase): def afterSetUp(self): # First we need to create some content. self.loginAsPortalOwner() - typetool = self.portal.portal_types + self.typetool = typetool = self.portal.portal_types typetool.constructContent('Document', self.portal, 'doc1') self.catalog = getToolByName(self.portal, 'portal_catalog') @@ -294,5 +294,19 @@ class CommentCatalogTest(PloneTestCase): self.failUnless(brains) 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(): return unittest.defaultTestLoader.loadTestsFromName(__name__) \ No newline at end of file diff --git a/plone/app/discussion/tests/test_comments_viewlet.py b/plone/app/discussion/tests/test_comments_viewlet.py index 74a5045..3b3d156 100644 --- a/plone/app/discussion/tests/test_comments_viewlet.py +++ b/plone/app/discussion/tests/test_comments_viewlet.py @@ -20,9 +20,9 @@ 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 CommentsViewlet -from plone.app.discussion.interfaces import IConversation, IComment, IReplies, IDiscussionSettings +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 @@ -41,13 +41,17 @@ class TestCommentForm(PloneTestCase): 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',} ) - #from plone.app.discussion.browser.comments import CommentForm - #cf = CommentForm(self.portal, request) + cf = CommentForm(self.viewlet, request) + #cf.handleComments() # Zope publisher uses Python list to mark