Pep8.
This commit is contained in:
parent
20935da608
commit
849299f233
@ -67,8 +67,7 @@ class ConversationCatalogTest(unittest.TestCase):
|
|||||||
id='doc1',
|
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')
|
||||||
@ -108,17 +107,21 @@ class ConversationCatalogTest(unittest.TestCase):
|
|||||||
'++conversation++default/%s' % new_comment2_id)
|
'++conversation++default/%s' % new_comment2_id)
|
||||||
comment2.reindexObject()
|
comment2.reindexObject()
|
||||||
brains = self.catalog.searchResults(dict(
|
brains = self.catalog.searchResults(dict(
|
||||||
path={'query':
|
path={
|
||||||
'/'.join(self.portal.doc1.getPhysicalPath())},
|
'query':
|
||||||
portal_type="Document"
|
'/'.join(self.portal.doc1.getPhysicalPath())
|
||||||
))
|
},
|
||||||
|
portal_type="Document"
|
||||||
|
))
|
||||||
doc1_brain = brains[0]
|
doc1_brain = brains[0]
|
||||||
self.assertEqual(doc1_brain.total_comments, 2)
|
self.assertEqual(doc1_brain.total_comments, 2)
|
||||||
|
|
||||||
def test_last_comment_date(self):
|
def test_last_comment_date(self):
|
||||||
self.assertTrue('last_comment_date' in self.doc1_brain)
|
self.assertTrue('last_comment_date' in self.doc1_brain)
|
||||||
self.assertEqual(self.doc1_brain.last_comment_date,
|
self.assertEqual(
|
||||||
datetime(2006, 9, 17, 14, 18, 12))
|
self.doc1_brain.last_comment_date,
|
||||||
|
datetime(2006, 9, 17, 14, 18, 12)
|
||||||
|
)
|
||||||
|
|
||||||
# Add another comment and check if last comment date is updated.
|
# Add another comment and check if last comment date is updated.
|
||||||
comment2 = createObject('plone.Comment')
|
comment2 = createObject('plone.Comment')
|
||||||
@ -132,33 +135,43 @@ class ConversationCatalogTest(unittest.TestCase):
|
|||||||
'++conversation++default/%s' % new_comment2_id)
|
'++conversation++default/%s' % new_comment2_id)
|
||||||
comment2.reindexObject()
|
comment2.reindexObject()
|
||||||
brains = self.catalog.searchResults(dict(
|
brains = self.catalog.searchResults(dict(
|
||||||
path={'query':
|
path={
|
||||||
'/'.join(self.portal.doc1.getPhysicalPath())},
|
'query':
|
||||||
portal_type="Document"
|
'/'.join(self.portal.doc1.getPhysicalPath())
|
||||||
))
|
},
|
||||||
|
portal_type="Document"
|
||||||
|
))
|
||||||
doc1_brain = brains[0]
|
doc1_brain = brains[0]
|
||||||
self.assertEqual(doc1_brain.last_comment_date,
|
self.assertEqual(
|
||||||
datetime(2009, 9, 17, 14, 18, 12))
|
doc1_brain.last_comment_date,
|
||||||
|
datetime(2009, 9, 17, 14, 18, 12)
|
||||||
|
)
|
||||||
|
|
||||||
# Remove the comment again
|
# Remove the comment again
|
||||||
del self.conversation[new_comment2_id]
|
del self.conversation[new_comment2_id]
|
||||||
|
|
||||||
brains = self.catalog.searchResults(dict(
|
brains = self.catalog.searchResults(dict(
|
||||||
path={'query':
|
path={
|
||||||
'/'.join(self.portal.doc1.getPhysicalPath())},
|
'query':
|
||||||
portal_type="Document"
|
'/'.join(self.portal.doc1.getPhysicalPath())
|
||||||
))
|
},
|
||||||
|
portal_type="Document"
|
||||||
|
))
|
||||||
doc1_brain = brains[0]
|
doc1_brain = brains[0]
|
||||||
self.assertEqual(doc1_brain.last_comment_date,
|
self.assertEqual(
|
||||||
datetime(2006, 9, 17, 14, 18, 12))
|
doc1_brain.last_comment_date,
|
||||||
|
datetime(2006, 9, 17, 14, 18, 12)
|
||||||
|
)
|
||||||
|
|
||||||
# remove all comments
|
# remove all comments
|
||||||
del self.conversation[self.new_comment1_id]
|
del self.conversation[self.new_comment1_id]
|
||||||
brains = self.catalog.searchResults(dict(
|
brains = self.catalog.searchResults(dict(
|
||||||
path={'query':
|
path={
|
||||||
'/'.join(self.portal.doc1.getPhysicalPath())},
|
'query':
|
||||||
portal_type="Document"
|
'/'.join(self.portal.doc1.getPhysicalPath())
|
||||||
))
|
},
|
||||||
|
portal_type="Document"
|
||||||
|
))
|
||||||
doc1_brain = brains[0]
|
doc1_brain = brains[0]
|
||||||
self.assertEqual(doc1_brain.last_comment_date, None)
|
self.assertEqual(doc1_brain.last_comment_date, None)
|
||||||
|
|
||||||
@ -179,10 +192,12 @@ class ConversationCatalogTest(unittest.TestCase):
|
|||||||
comment2.reindexObject()
|
comment2.reindexObject()
|
||||||
|
|
||||||
brains = self.catalog.searchResults(dict(
|
brains = self.catalog.searchResults(dict(
|
||||||
path={'query':
|
path={
|
||||||
'/'.join(self.portal.doc1.getPhysicalPath())},
|
'query':
|
||||||
portal_type="Document"
|
'/'.join(self.portal.doc1.getPhysicalPath())
|
||||||
))
|
},
|
||||||
|
portal_type="Document"
|
||||||
|
))
|
||||||
doc1_brain = brains[0]
|
doc1_brain = brains[0]
|
||||||
|
|
||||||
self.assertEqual(doc1_brain.commentators, ('Jim', 'Emma'))
|
self.assertEqual(doc1_brain.commentators, ('Jim', 'Emma'))
|
||||||
@ -190,29 +205,35 @@ class ConversationCatalogTest(unittest.TestCase):
|
|||||||
# remove one comments
|
# remove one comments
|
||||||
del self.conversation[new_comment2_id]
|
del self.conversation[new_comment2_id]
|
||||||
brains = self.catalog.searchResults(dict(
|
brains = self.catalog.searchResults(dict(
|
||||||
path={'query':
|
path={
|
||||||
'/'.join(self.portal.doc1.getPhysicalPath())},
|
'query':
|
||||||
portal_type="Document"
|
'/'.join(self.portal.doc1.getPhysicalPath())
|
||||||
))
|
},
|
||||||
|
portal_type="Document"
|
||||||
|
))
|
||||||
doc1_brain = brains[0]
|
doc1_brain = brains[0]
|
||||||
self.assertEqual(doc1_brain.commentators, ('Jim',))
|
self.assertEqual(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(dict(
|
brains = self.catalog.searchResults(dict(
|
||||||
path={'query':
|
path={
|
||||||
'/'.join(self.portal.doc1.getPhysicalPath())},
|
'query':
|
||||||
portal_type="Document"
|
'/'.join(self.portal.doc1.getPhysicalPath())
|
||||||
))
|
},
|
||||||
|
portal_type="Document"
|
||||||
|
))
|
||||||
doc1_brain = brains[0]
|
doc1_brain = brains[0]
|
||||||
self.assertEqual(doc1_brain.commentators, ())
|
self.assertEqual(doc1_brain.commentators, ())
|
||||||
|
|
||||||
def test_conversation_indexes_not_in_comments(self):
|
def test_conversation_indexes_not_in_comments(self):
|
||||||
brains = self.catalog.searchResults(dict(
|
brains = self.catalog.searchResults(dict(
|
||||||
path={'query':
|
path={
|
||||||
'/'.join(self.portal.doc1.getPhysicalPath())},
|
'query':
|
||||||
portal_type="Discussion Item"
|
'/'.join(self.portal.doc1.getPhysicalPath())
|
||||||
))
|
},
|
||||||
|
portal_type="Discussion Item"
|
||||||
|
))
|
||||||
comment1_brain = brains[0]
|
comment1_brain = brains[0]
|
||||||
self.assertEqual(comment1_brain.commentators, None)
|
self.assertEqual(comment1_brain.commentators, None)
|
||||||
self.assertEqual(comment1_brain.last_comment_date, None)
|
self.assertEqual(comment1_brain.last_comment_date, None)
|
||||||
@ -222,13 +243,16 @@ class ConversationCatalogTest(unittest.TestCase):
|
|||||||
self.comment1.manage_permission("View", roles=tuple())
|
self.comment1.manage_permission("View", roles=tuple())
|
||||||
self.portal.doc1.reindexObject()
|
self.portal.doc1.reindexObject()
|
||||||
brains = self.catalog.searchResults(dict(
|
brains = self.catalog.searchResults(dict(
|
||||||
path={'query':
|
path={
|
||||||
'/'.join(self.portal.doc1.getPhysicalPath())},
|
'query':
|
||||||
portal_type="Document"
|
'/'.join(self.portal.doc1.getPhysicalPath())
|
||||||
))
|
},
|
||||||
|
portal_type="Document"
|
||||||
|
))
|
||||||
doc1_brain = brains[0]
|
doc1_brain = brains[0]
|
||||||
self.assertEqual(doc1_brain.commentators, ())
|
self.assertEqual(doc1_brain.commentators, ())
|
||||||
|
|
||||||
|
|
||||||
class CommentCatalogTest(unittest.TestCase):
|
class CommentCatalogTest(unittest.TestCase):
|
||||||
|
|
||||||
layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING
|
layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING
|
||||||
@ -255,8 +279,11 @@ class CommentCatalogTest(unittest.TestCase):
|
|||||||
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(dict(
|
brains = self.catalog.searchResults(dict(
|
||||||
path={'query':
|
path={
|
||||||
'/'.join(self.comment.getPhysicalPath())}))
|
'query':
|
||||||
|
'/'.join(self.comment.getPhysicalPath())
|
||||||
|
}
|
||||||
|
))
|
||||||
self.comment_brain = brains[0]
|
self.comment_brain = brains[0]
|
||||||
|
|
||||||
def test_title(self):
|
def test_title(self):
|
||||||
@ -271,8 +298,11 @@ class CommentCatalogTest(unittest.TestCase):
|
|||||||
comment = self.portal.doc1.restrictedTraverse(
|
comment = self.portal.doc1.restrictedTraverse(
|
||||||
'++conversation++default/%s' % cid)
|
'++conversation++default/%s' % cid)
|
||||||
brains = self.catalog.searchResults(dict(
|
brains = self.catalog.searchResults(dict(
|
||||||
path={'query':
|
path={
|
||||||
'/'.join(comment.getPhysicalPath())}))
|
'query':
|
||||||
|
'/'.join(comment.getPhysicalPath())
|
||||||
|
}
|
||||||
|
))
|
||||||
comment_brain = brains[0]
|
comment_brain = brains[0]
|
||||||
self.assertEqual(comment_brain.Title, "Anonymous on Document 1")
|
self.assertEqual(comment_brain.Title, "Anonymous on Document 1")
|
||||||
|
|
||||||
@ -301,8 +331,11 @@ class CommentCatalogTest(unittest.TestCase):
|
|||||||
# deleted.
|
# deleted.
|
||||||
del self.conversation[self.comment_id]
|
del self.conversation[self.comment_id]
|
||||||
brains = self.catalog.searchResults(dict(
|
brains = self.catalog.searchResults(dict(
|
||||||
path={'query':
|
path={
|
||||||
'/'.join(self.comment.getPhysicalPath())}))
|
'query':
|
||||||
|
'/'.join(self.comment.getPhysicalPath())
|
||||||
|
}
|
||||||
|
))
|
||||||
self.assertEqual(len(brains), 0)
|
self.assertEqual(len(brains), 0)
|
||||||
|
|
||||||
def test_remove_comments_when_content_object_is_removed(self):
|
def test_remove_comments_when_content_object_is_removed(self):
|
||||||
@ -317,15 +350,21 @@ class CommentCatalogTest(unittest.TestCase):
|
|||||||
|
|
||||||
def test_move_comments_when_content_object_is_moved(self):
|
def test_move_comments_when_content_object_is_moved(self):
|
||||||
# Create two folders and a content object with a comment
|
# Create two folders and a content object with a comment
|
||||||
self.portal.invokeFactory(id='folder1',
|
self.portal.invokeFactory(
|
||||||
title='Folder 1',
|
id='folder1',
|
||||||
type_name='Folder')
|
title='Folder 1',
|
||||||
self.portal.invokeFactory(id='folder2',
|
type_name='Folder'
|
||||||
title='Folder 2',
|
)
|
||||||
type_name='Folder')
|
self.portal.invokeFactory(
|
||||||
self.portal.folder1.invokeFactory(id='moveme',
|
id='folder2',
|
||||||
title='Move Me',
|
title='Folder 2',
|
||||||
type_name='Document')
|
type_name='Folder'
|
||||||
|
)
|
||||||
|
self.portal.folder1.invokeFactory(
|
||||||
|
id='moveme',
|
||||||
|
title='Move Me',
|
||||||
|
type_name='Document'
|
||||||
|
)
|
||||||
conversation = IConversation(self.portal.folder1.moveme)
|
conversation = IConversation(self.portal.folder1.moveme)
|
||||||
comment = createObject('plone.Comment')
|
comment = createObject('plone.Comment')
|
||||||
comment_id = conversation.addComment(comment)
|
comment_id = conversation.addComment(comment)
|
||||||
@ -338,22 +377,23 @@ class CommentCatalogTest(unittest.TestCase):
|
|||||||
|
|
||||||
# Make sure no old comment brains are
|
# Make sure no old comment brains are
|
||||||
brains = self.catalog.searchResults(dict(
|
brains = self.catalog.searchResults(dict(
|
||||||
portal_type="Discussion Item",
|
portal_type="Discussion Item",
|
||||||
path={'query': '/'.join(self.portal.folder1.getPhysicalPath())}
|
path={'query': '/'.join(self.portal.folder1.getPhysicalPath())}
|
||||||
))
|
))
|
||||||
self.assertEqual(len(brains), 0)
|
self.assertEqual(len(brains), 0)
|
||||||
|
|
||||||
brains = self.catalog.searchResults(dict(
|
brains = self.catalog.searchResults(dict(
|
||||||
portal_type="Discussion Item",
|
portal_type="Discussion Item",
|
||||||
path={
|
path={
|
||||||
'query': '/'.join(self.portal.folder2.getPhysicalPath())
|
'query': '/'.join(self.portal.folder2.getPhysicalPath())
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
self.assertEqual(len(brains), 1)
|
self.assertEqual(len(brains), 1)
|
||||||
self.assertEqual(brains[0].getPath(),
|
self.assertEqual(
|
||||||
'/plone/folder2/moveme/++conversation++default/' +
|
brains[0].getPath(),
|
||||||
str(comment_id))
|
'/plone/folder2/moveme/++conversation++default/' +
|
||||||
|
str(comment_id)
|
||||||
|
)
|
||||||
|
|
||||||
def test_move_upper_level_folder(self):
|
def test_move_upper_level_folder(self):
|
||||||
# create a folder with a nested structure
|
# create a folder with a nested structure
|
||||||
@ -371,7 +411,9 @@ class CommentCatalogTest(unittest.TestCase):
|
|||||||
type_name='Folder')
|
type_name='Folder')
|
||||||
|
|
||||||
# create comment on my-document
|
# create comment on my-document
|
||||||
conversation = IConversation(self.portal.sourcefolder.moveme.mydocument)
|
conversation = IConversation(
|
||||||
|
self.portal.sourcefolder.moveme.mydocument
|
||||||
|
)
|
||||||
comment = createObject('plone.Comment')
|
comment = createObject('plone.Comment')
|
||||||
comment_id = conversation.addComment(comment)
|
comment_id = conversation.addComment(comment)
|
||||||
|
|
||||||
@ -384,20 +426,22 @@ class CommentCatalogTest(unittest.TestCase):
|
|||||||
|
|
||||||
# Make sure no old comment brains are left
|
# Make sure no old comment brains are left
|
||||||
brains = self.catalog.searchResults(dict(
|
brains = self.catalog.searchResults(dict(
|
||||||
portal_type="Discussion Item",
|
portal_type="Discussion Item",
|
||||||
path={'query': '/plone/sourcefolder/moveme'}
|
path={'query': '/plone/sourcefolder/moveme'}
|
||||||
))
|
))
|
||||||
self.assertEqual(len(brains), 0)
|
self.assertEqual(len(brains), 0)
|
||||||
|
|
||||||
# make sure comments are correctly index on the target
|
# make sure comments are correctly index on the target
|
||||||
brains = self.catalog.searchResults(dict(
|
brains = self.catalog.searchResults(dict(
|
||||||
portal_type="Discussion Item",
|
portal_type="Discussion Item",
|
||||||
path={'query': '/plone/targetfolder/moveme'}
|
path={'query': '/plone/targetfolder/moveme'}
|
||||||
))
|
))
|
||||||
self.assertEqual(len(brains), 1)
|
self.assertEqual(len(brains), 1)
|
||||||
self.assertEqual(brains[0].getPath(),
|
self.assertEqual(
|
||||||
'/plone/targetfolder/moveme/mydocument/++conversation++default/' +
|
brains[0].getPath(),
|
||||||
str(comment_id))
|
'/plone/targetfolder/moveme/mydocument/++conversation++default/' +
|
||||||
|
str(comment_id)
|
||||||
|
)
|
||||||
|
|
||||||
def test_update_comments_when_content_object_is_renamed(self):
|
def test_update_comments_when_content_object_is_renamed(self):
|
||||||
# We need to commit here so that _p_jar isn't None and move will work
|
# We need to commit here so that _p_jar isn't None and move will work
|
||||||
@ -408,9 +452,11 @@ class CommentCatalogTest(unittest.TestCase):
|
|||||||
brains = self.catalog.searchResults(
|
brains = self.catalog.searchResults(
|
||||||
portal_type='Discussion Item')
|
portal_type='Discussion Item')
|
||||||
self.assertEqual(len(brains), 1)
|
self.assertEqual(len(brains), 1)
|
||||||
self.assertEqual(brains[0].getPath(),
|
self.assertEqual(
|
||||||
'/plone/doc2/++conversation++default/' +
|
brains[0].getPath(),
|
||||||
str(self.comment_id))
|
'/plone/doc2/++conversation++default/' +
|
||||||
|
str(self.comment_id)
|
||||||
|
)
|
||||||
|
|
||||||
def test_clear_and_rebuild_catalog(self):
|
def test_clear_and_rebuild_catalog(self):
|
||||||
# Clear and rebuild catalog
|
# Clear and rebuild catalog
|
||||||
@ -421,9 +467,11 @@ class CommentCatalogTest(unittest.TestCase):
|
|||||||
self.assertTrue(brains)
|
self.assertTrue(brains)
|
||||||
comment_brain = brains[0]
|
comment_brain = brains[0]
|
||||||
self.assertEqual(comment_brain.Title, u'Jim on Document 1')
|
self.assertEqual(comment_brain.Title, u'Jim on Document 1')
|
||||||
self.assertEqual(comment_brain.getPath(),
|
self.assertEqual(
|
||||||
|
comment_brain.getPath(),
|
||||||
'/plone/doc1/++conversation++default/' +
|
'/plone/doc1/++conversation++default/' +
|
||||||
str(self.comment_id))
|
str(self.comment_id)
|
||||||
|
)
|
||||||
|
|
||||||
def test_clear_and_rebuild_catalog_for_nested_comments(self):
|
def test_clear_and_rebuild_catalog_for_nested_comments(self):
|
||||||
|
|
||||||
@ -496,9 +544,9 @@ class CommentCatalogTest(unittest.TestCase):
|
|||||||
self.portal.invokeFactory('Collection', id='collection')
|
self.portal.invokeFactory('Collection', id='collection')
|
||||||
collection = self.portal.collection
|
collection = self.portal.collection
|
||||||
collection.query = [{
|
collection.query = [{
|
||||||
'i': 'Type',
|
'i': 'Type',
|
||||||
'o': 'plone.app.querystring.operation.string.is',
|
'o': 'plone.app.querystring.operation.string.is',
|
||||||
'v': 'Comment',
|
'v': 'Comment',
|
||||||
}]
|
}]
|
||||||
|
|
||||||
self.assertEqual(len(collection.results()), 1)
|
self.assertEqual(len(collection.results()), 1)
|
||||||
@ -523,10 +571,12 @@ class NoConversationCatalogTest(unittest.TestCase):
|
|||||||
conversation = IConversation(self.portal.doc1)
|
conversation = IConversation(self.portal.doc1)
|
||||||
|
|
||||||
brains = self.catalog.searchResults(dict(
|
brains = self.catalog.searchResults(dict(
|
||||||
path={'query':
|
path={
|
||||||
'/'.join(self.portal.doc1.getPhysicalPath())},
|
'query':
|
||||||
portal_type="Document"
|
'/'.join(self.portal.doc1.getPhysicalPath())
|
||||||
))
|
},
|
||||||
|
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