Avoid deprecation warnings and always specify a catalog query as a dict

svn path=/plone.app.discussion/trunk/; revision=48880
This commit is contained in:
Hanno Schlichting 2011-04-15 16:17:02 +00:00
parent 3708429a37
commit 811d4a0429

View File

@ -65,11 +65,11 @@ class ConversationCatalogTest(PloneTestCase):
new_comment1_id = conversation.addComment(comment1)
self.comment_id = new_comment1_id
brains = self.catalog.searchResults(
brains = self.catalog.searchResults(dict(
path={'query':
'/'.join(self.portal.doc1.getPhysicalPath()) },
portal_type="Document"
)
))
self.conversation = conversation
self.brains = brains
self.doc1_brain = brains[0]
@ -89,11 +89,11 @@ class ConversationCatalogTest(PloneTestCase):
comment2 = self.portal.doc1.restrictedTraverse(
'++conversation++default/%s' % new_comment2_id)
comment2.reindexObject()
brains = self.catalog.searchResults(
brains = self.catalog.searchResults(dict(
path={'query':
'/'.join(self.portal.doc1.getPhysicalPath()) },
portal_type="Document"
)
))
doc1_brain = brains[0]
self.assertEquals(doc1_brain.total_comments, 2)
@ -114,11 +114,11 @@ class ConversationCatalogTest(PloneTestCase):
comment2 = self.portal.doc1.restrictedTraverse(
'++conversation++default/%s' % new_comment2_id)
comment2.reindexObject()
brains = self.catalog.searchResults(
brains = self.catalog.searchResults(dict(
path={'query':
'/'.join(self.portal.doc1.getPhysicalPath()) },
portal_type="Document"
)
))
doc1_brain = brains[0]
self.assertEquals(doc1_brain.last_comment_date,
datetime(2009, 9, 17, 14, 18, 12))
@ -126,11 +126,11 @@ class ConversationCatalogTest(PloneTestCase):
# Remove the comment again
del self.conversation[new_comment2_id]
brains = self.catalog.searchResults(
brains = self.catalog.searchResults(dict(
path={'query':
'/'.join(self.portal.doc1.getPhysicalPath()) },
portal_type="Document"
)
))
doc1_brain = brains[0]
self.assertEquals(doc1_brain.last_comment_date,
@ -138,11 +138,11 @@ class ConversationCatalogTest(PloneTestCase):
# remove all comments
del self.conversation[self.new_comment1_id]
brains = self.catalog.searchResults(
brains = self.catalog.searchResults(dict(
path={'query':
'/'.join(self.portal.doc1.getPhysicalPath()) },
portal_type="Document"
)
))
doc1_brain = brains[0]
self.assertEquals(doc1_brain.last_comment_date, None)
@ -162,41 +162,41 @@ class ConversationCatalogTest(PloneTestCase):
'++conversation++default/%s' % new_comment2_id)
comment2.reindexObject()
brains = self.catalog.searchResults(
brains = self.catalog.searchResults(dict(
path={'query':
'/'.join(self.portal.doc1.getPhysicalPath()) },
portal_type="Document"
)
))
doc1_brain = brains[0]
self.assertEquals(doc1_brain.commentators, ('Emma', 'Jim'))
# remove one comments
del self.conversation[new_comment2_id]
brains = self.catalog.searchResults(
brains = self.catalog.searchResults(dict(
path={'query':
'/'.join(self.portal.doc1.getPhysicalPath()) },
portal_type="Document"
)
))
doc1_brain = brains[0]
self.assertEquals(doc1_brain.commentators, ('Jim',))
# remove all comments
del self.conversation[self.new_comment1_id]
brains = self.catalog.searchResults(
brains = self.catalog.searchResults(dict(
path={'query':
'/'.join(self.portal.doc1.getPhysicalPath()) },
portal_type="Document"
)
))
doc1_brain = brains[0]
self.assertEquals(doc1_brain.commentators, ())
def test_conversation_indexes_not_in_comments(self):
brains = self.catalog.searchResults(
brains = self.catalog.searchResults(dict(
path={'query':
'/'.join(self.portal.doc1.getPhysicalPath()) },
portal_type="Discussion Item"
)
))
comment1_brain = brains[0]
self.assertEquals(comment1_brain.commentators, None)
self.assertEquals(comment1_brain.last_comment_date, None)
@ -228,9 +228,9 @@ class CommentCatalogTest(PloneTestCase):
# Comment brain
self.comment = self.portal.doc1.restrictedTraverse(
'++conversation++default/%s' % new_comment1_id)
brains = self.catalog.searchResults(
brains = self.catalog.searchResults(dict(
path={'query':
'/'.join(self.comment.getPhysicalPath()) })
'/'.join(self.comment.getPhysicalPath())}))
self.comment_brain = brains[0]
def test_title(self):
@ -244,9 +244,9 @@ class CommentCatalogTest(PloneTestCase):
# Comment brain
comment = self.portal.doc1.restrictedTraverse(
'++conversation++default/%s' % cid)
brains = self.catalog.searchResults(
brains = self.catalog.searchResults(dict(
path={'query':
'/'.join(comment.getPhysicalPath()) })
'/'.join(comment.getPhysicalPath())}))
comment_brain = brains[0]
self.assertEquals(comment_brain.Title, "Anonymous on Document 1")
@ -274,19 +274,19 @@ class CommentCatalogTest(PloneTestCase):
# Make sure a comment is removed from the catalog as well when it is
# deleted.
del self.conversation[self.comment_id]
brains = self.catalog.searchResults(
brains = self.catalog.searchResults(dict(
path={'query':
'/'.join(self.comment.getPhysicalPath()) })
'/'.join(self.comment.getPhysicalPath())}))
self.assertEquals(len(brains), 0)
def test_remove_comments_when_content_object_is_removed(self):
"""Make sure all comments are removed from the catalog, if the content
object is removed.
"""
brains = self.catalog.searchResults(portal_type='Discussion Item')
brains = self.catalog.searchResults({'portal_type': 'Discussion Item'})
self.assertEquals(len(brains), 1)
self.portal.manage_delObjects(["doc1"])
brains = self.catalog.searchResults(portal_type='Discussion Item')
brains = self.catalog.searchResults({'portal_type': 'Discussion Item'})
self.assertEquals(len(brains), 0)
def test_clear_and_rebuild_catalog(self):
@ -294,7 +294,7 @@ class CommentCatalogTest(PloneTestCase):
self.catalog.clearFindAndRebuild()
# Check if comment is still there
brains = self.catalog.searchResults(portal_type='Discussion Item')
brains = self.catalog.searchResults({'portal_type': 'Discussion Item'})
self.failUnless(brains)
comment_brain = brains[0]
self.assertEquals(comment_brain.Title, u'Jim on Document 1')
@ -351,7 +351,7 @@ class CommentCatalogTest(PloneTestCase):
self.catalog.clearFindAndRebuild()
# Check if comments are still there
brains = self.catalog.searchResults(portal_type='Discussion Item')
brains = self.catalog.searchResults({'portal_type': 'Discussion Item'})
self.failUnless(brains)
self.assertEquals(len(brains), 6)
@ -383,11 +383,11 @@ class NoConversationCatalogTest(PloneTestCase):
conversation = IConversation(self.portal.doc1)
brains = self.catalog.searchResults(
brains = self.catalog.searchResults(dict(
path={'query':
'/'.join(self.portal.doc1.getPhysicalPath()) },
'/'.join(self.portal.doc1.getPhysicalPath())},
portal_type="Document"
)
))
self.conversation = conversation
self.brains = brains
self.doc1_brain = brains[0]