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