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
1 changed files with 47 additions and 48 deletions

View File

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