This commit is contained in:
Timo Stollenwerk 2013-04-17 19:07:40 +02:00
parent dcb2d3e7d4
commit 943065c15f
2 changed files with 58 additions and 31 deletions

View File

@ -15,9 +15,10 @@ from plone.app.discussion.testing import \
optionflags = ( optionflags = (
doctest.ELLIPSIS | \ doctest.ELLIPSIS |
doctest.NORMALIZE_WHITESPACE | \ doctest.NORMALIZE_WHITESPACE |
doctest.REPORT_ONLY_FIRST_FAILURE) doctest.REPORT_ONLY_FIRST_FAILURE
)
normal_testfiles = [ normal_testfiles = [
'functional_test_comments.txt', 'functional_test_comments.txt',
'functional_test_comment_review_workflow.txt', 'functional_test_comment_review_workflow.txt',

View File

@ -40,9 +40,11 @@ class ConversationIndexersTest(unittest.TestCase):
self.portal = self.layer['portal'] self.portal = self.layer['portal']
setRoles(self.portal, TEST_USER_ID, ['Manager']) 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'
)
# Create a conversation. # Create a conversation.
conversation = IConversation(self.portal.doc1) conversation = IConversation(self.portal.doc1)
@ -74,8 +76,10 @@ class ConversationIndexersTest(unittest.TestCase):
self.conversation = conversation self.conversation = conversation
def test_conversation_total_comments(self): def test_conversation_total_comments(self):
self.assertTrue(isinstance(catalog.total_comments, self.assertTrue(isinstance(
DelegatingIndexerFactory)) catalog.total_comments,
DelegatingIndexerFactory
))
self.assertEqual(catalog.total_comments(self.portal.doc1)(), 3) self.assertEqual(catalog.total_comments(self.portal.doc1)(), 3)
del self.conversation[self.new_id1] del self.conversation[self.new_id1]
self.assertEqual(catalog.total_comments(self.portal.doc1)(), 2) self.assertEqual(catalog.total_comments(self.portal.doc1)(), 2)
@ -84,13 +88,19 @@ class ConversationIndexersTest(unittest.TestCase):
self.assertEqual(catalog.total_comments(self.portal.doc1)(), 0) self.assertEqual(catalog.total_comments(self.portal.doc1)(), 0)
def test_conversation_last_comment_date(self): def test_conversation_last_comment_date(self):
self.assertTrue(isinstance(catalog.last_comment_date, self.assertTrue(isinstance(
DelegatingIndexerFactory)) catalog.last_comment_date,
self.assertEqual(catalog.last_comment_date(self.portal.doc1)(), DelegatingIndexerFactory
datetime(2009, 4, 12, 11, 12, 12)) ))
self.assertEqual(
catalog.last_comment_date(self.portal.doc1)(),
datetime(2009, 4, 12, 11, 12, 12)
)
del self.conversation[self.new_id3] del self.conversation[self.new_id3]
self.assertEqual(catalog.last_comment_date(self.portal.doc1)(), self.assertEqual(
datetime(2007, 12, 13, 4, 18, 12)) catalog.last_comment_date(self.portal.doc1)(),
datetime(2007, 12, 13, 4, 18, 12)
)
del self.conversation[self.new_id2] del self.conversation[self.new_id2]
del self.conversation[self.new_id1] del self.conversation[self.new_id1]
self.assertEqual(catalog.last_comment_date(self.portal.doc1)(), None) self.assertEqual(catalog.last_comment_date(self.portal.doc1)(), None)
@ -111,9 +121,11 @@ class CommentIndexersTest(unittest.TestCase):
self.portal = self.layer['portal'] self.portal = self.layer['portal']
setRoles(self.portal, TEST_USER_ID, ['Manager']) 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'
)
# Create a conversation. In this case we doesn't assign it to an # Create a conversation. In this case we doesn't assign it to an
# object, as we just want to check the Conversation object API. # object, as we just want to check the Conversation object API.
@ -138,8 +150,10 @@ class CommentIndexersTest(unittest.TestCase):
self.assertTrue(isinstance(catalog.title, DelegatingIndexerFactory)) self.assertTrue(isinstance(catalog.title, DelegatingIndexerFactory))
def test_description(self): def test_description(self):
self.assertEqual(catalog.description(self.comment)(), self.assertEqual(
'Lorem ipsum dolor sit amet.') catalog.description(self.comment)(),
'Lorem ipsum dolor sit amet.'
)
self.assertTrue( self.assertTrue(
isinstance(catalog.description, DelegatingIndexerFactory)) isinstance(catalog.description, DelegatingIndexerFactory))
@ -151,24 +165,36 @@ class CommentIndexersTest(unittest.TestCase):
comment_long.text = LONG_TEXT comment_long.text = LONG_TEXT
self.conversation.addComment(comment_long) self.conversation.addComment(comment_long)
self.assertEqual(catalog.description(comment_long)(), self.assertEqual(
LONG_TEXT_CUT.replace("\n", " ")) catalog.description(comment_long)(),
LONG_TEXT_CUT.replace("\n", " ")
)
def test_dates(self): def test_dates(self):
# Test if created, modified, effective etc. are set correctly # Test if created, modified, effective etc. are set correctly
self.assertEqual(catalog.created(self.comment)(), self.assertEqual(
DateTime(2006, 9, 17, 14, 18, 12, 'GMT')) catalog.created(self.comment)(),
self.assertEqual(catalog.effective(self.comment)(), DateTime(2006, 9, 17, 14, 18, 12, 'GMT')
DateTime(2006, 9, 17, 14, 18, 12, 'GMT')) )
self.assertEqual(catalog.modified(self.comment)(), self.assertEqual(
DateTime(2008, 3, 12, 7, 32, 52, 'GMT')) catalog.effective(self.comment)(),
DateTime(2006, 9, 17, 14, 18, 12, 'GMT')
)
self.assertEqual(
catalog.modified(self.comment)(),
DateTime(2008, 3, 12, 7, 32, 52, 'GMT')
)
def test_searchable_text(self): def test_searchable_text(self):
# Test if searchable text is a concatenation of title and comment text # Test if searchable text is a concatenation of title and comment text
self.assertEqual(catalog.searchable_text(self.comment)(), self.assertEqual(
('Lorem ipsum dolor sit amet.')) catalog.searchable_text(self.comment)(),
self.assertTrue(isinstance(catalog.searchable_text, ('Lorem ipsum dolor sit amet.')
DelegatingIndexerFactory)) )
self.assertTrue(isinstance(
catalog.searchable_text,
DelegatingIndexerFactory
))
def test_creator(self): def test_creator(self):
self.assertEqual(catalog.creator(self.comment)(), ('jim')) self.assertEqual(catalog.creator(self.comment)(), ('jim'))