Use plone.app.testing in test_catalog.

svn path=/plone.app.discussion/trunk/; revision=48897
This commit is contained in:
Timo Stollenwerk 2011-04-16 09:13:39 +00:00
parent 4110b41ae6
commit e5d45dbd78

View File

@ -1,6 +1,6 @@
"""Test the plone.app.discussion catalog indexes """Test the plone.app.discussion catalog indexes
""" """
import unittest import unittest2 as unittest
from datetime import datetime from datetime import datetime
@ -9,16 +9,19 @@ from zope.annotation.interfaces import IAnnotations
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from Products.PloneTestCase.ptc import PloneTestCase from plone.app.testing import TEST_USER_ID, setRoles
from plone.app.discussion.tests.layer import DiscussionLayer from plone.app.discussion.testing import PLONE_APP_DISCUSSION_INTEGRATION_TESTING
from plone.app.discussion.interfaces import IConversation from plone.app.discussion.interfaces import IConversation
class CatalogSetupTest(PloneTestCase): class CatalogSetupTest(unittest.TestCase):
layer = DiscussionLayer layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING
def setUp(self):
self.portal = self.layer['portal']
def test_catalog_installed(self): def test_catalog_installed(self):
self.assertTrue('total_comments' in self.assertTrue('total_comments' in
@ -39,21 +42,19 @@ class CatalogSetupTest(PloneTestCase):
self.fail() self.fail()
class ConversationCatalogTest(PloneTestCase): class ConversationCatalogTest(unittest.TestCase):
layer = DiscussionLayer layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING
def afterSetUp(self): def setUp(self):
# First we need to create some content. self.portal = self.layer['portal']
self.loginAsPortalOwner() setRoles(self.portal, TEST_USER_ID, ['Manager'])
self.portal.invokeFactory(id='doc1', self.portal.invokeFactory(id='doc1',
Title='Document 1', Title='Document 1',
type_name='Document') type_name='Document')
self.catalog = getToolByName(self.portal, 'portal_catalog') self.catalog = getToolByName(self.portal, 'portal_catalog')
conversation = IConversation(self.portal.doc1) conversation = IConversation(self.portal.doc1)
comment1 = createObject('plone.Comment') comment1 = createObject('plone.Comment')
comment1.title = 'Comment 1' comment1.title = 'Comment 1'
comment1.text = 'Comment text' comment1.text = 'Comment text'
@ -132,7 +133,6 @@ class ConversationCatalogTest(PloneTestCase):
portal_type="Document" portal_type="Document"
)) ))
doc1_brain = brains[0] doc1_brain = brains[0]
self.assertEqual(doc1_brain.last_comment_date, self.assertEqual(doc1_brain.last_comment_date,
datetime(2006, 9, 17, 14, 18, 12)) datetime(2006, 9, 17, 14, 18, 12))
@ -203,14 +203,13 @@ class ConversationCatalogTest(PloneTestCase):
self.assertEqual(comment1_brain.total_comments, None) self.assertEqual(comment1_brain.total_comments, None)
class CommentCatalogTest(PloneTestCase): class CommentCatalogTest(unittest.TestCase):
layer = DiscussionLayer layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING
def afterSetUp(self): def setUp(self):
"""Create a document with a comment. self.portal = self.layer['portal']
""" setRoles(self.portal, TEST_USER_ID, ['Manager'])
self.loginAsPortalOwner()
self.portal.invokeFactory(id='doc1', self.portal.invokeFactory(id='doc1',
title='Document 1', title='Document 1',
type_name='Document') type_name='Document')
@ -368,13 +367,13 @@ class CommentCatalogTest(PloneTestCase):
self.assertEqual(len(topic.queryCatalog()), 1) self.assertEqual(len(topic.queryCatalog()), 1)
class NoConversationCatalogTest(PloneTestCase): class NoConversationCatalogTest(unittest.TestCase):
layer = DiscussionLayer layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING
def afterSetUp(self): def setUp(self):
# First we need to create some content. self.portal = self.layer['portal']
self.loginAsPortalOwner() setRoles(self.portal, TEST_USER_ID, ['Manager'])
self.portal.invokeFactory(id='doc1', self.portal.invokeFactory(id='doc1',
Title='Document 1', Title='Document 1',
type_name='Document') type_name='Document')