Pep8.
This commit is contained in:
parent
20935da608
commit
849299f233
@ -68,7 +68,6 @@ class ConversationCatalogTest(unittest.TestCase):
|
|||||||
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,8 +107,10 @@ 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':
|
||||||
|
'/'.join(self.portal.doc1.getPhysicalPath())
|
||||||
|
},
|
||||||
portal_type="Document"
|
portal_type="Document"
|
||||||
))
|
))
|
||||||
doc1_brain = brains[0]
|
doc1_brain = brains[0]
|
||||||
@ -117,8 +118,10 @@ class ConversationCatalogTest(unittest.TestCase):
|
|||||||
|
|
||||||
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,31 +135,41 @@ 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':
|
||||||
|
'/'.join(self.portal.doc1.getPhysicalPath())
|
||||||
|
},
|
||||||
portal_type="Document"
|
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':
|
||||||
|
'/'.join(self.portal.doc1.getPhysicalPath())
|
||||||
|
},
|
||||||
portal_type="Document"
|
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':
|
||||||
|
'/'.join(self.portal.doc1.getPhysicalPath())
|
||||||
|
},
|
||||||
portal_type="Document"
|
portal_type="Document"
|
||||||
))
|
))
|
||||||
doc1_brain = brains[0]
|
doc1_brain = brains[0]
|
||||||
@ -179,8 +192,10 @@ 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':
|
||||||
|
'/'.join(self.portal.doc1.getPhysicalPath())
|
||||||
|
},
|
||||||
portal_type="Document"
|
portal_type="Document"
|
||||||
))
|
))
|
||||||
doc1_brain = brains[0]
|
doc1_brain = brains[0]
|
||||||
@ -190,8 +205,10 @@ 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':
|
||||||
|
'/'.join(self.portal.doc1.getPhysicalPath())
|
||||||
|
},
|
||||||
portal_type="Document"
|
portal_type="Document"
|
||||||
))
|
))
|
||||||
doc1_brain = brains[0]
|
doc1_brain = brains[0]
|
||||||
@ -200,8 +217,10 @@ class ConversationCatalogTest(unittest.TestCase):
|
|||||||
# 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':
|
||||||
|
'/'.join(self.portal.doc1.getPhysicalPath())
|
||||||
|
},
|
||||||
portal_type="Document"
|
portal_type="Document"
|
||||||
))
|
))
|
||||||
doc1_brain = brains[0]
|
doc1_brain = brains[0]
|
||||||
@ -209,8 +228,10 @@ class ConversationCatalogTest(unittest.TestCase):
|
|||||||
|
|
||||||
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':
|
||||||
|
'/'.join(self.portal.doc1.getPhysicalPath())
|
||||||
|
},
|
||||||
portal_type="Discussion Item"
|
portal_type="Discussion Item"
|
||||||
))
|
))
|
||||||
comment1_brain = brains[0]
|
comment1_brain = brains[0]
|
||||||
@ -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':
|
||||||
|
'/'.join(self.portal.doc1.getPhysicalPath())
|
||||||
|
},
|
||||||
portal_type="Document"
|
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(
|
||||||
|
id='folder1',
|
||||||
title='Folder 1',
|
title='Folder 1',
|
||||||
type_name='Folder')
|
type_name='Folder'
|
||||||
self.portal.invokeFactory(id='folder2',
|
)
|
||||||
|
self.portal.invokeFactory(
|
||||||
|
id='folder2',
|
||||||
title='Folder 2',
|
title='Folder 2',
|
||||||
type_name='Folder')
|
type_name='Folder'
|
||||||
self.portal.folder1.invokeFactory(id='moveme',
|
)
|
||||||
|
self.portal.folder1.invokeFactory(
|
||||||
|
id='moveme',
|
||||||
title='Move Me',
|
title='Move Me',
|
||||||
type_name='Document')
|
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)
|
||||||
@ -350,10 +389,11 @@ class CommentCatalogTest(unittest.TestCase):
|
|||||||
}
|
}
|
||||||
))
|
))
|
||||||
self.assertEqual(len(brains), 1)
|
self.assertEqual(len(brains), 1)
|
||||||
self.assertEqual(brains[0].getPath(),
|
self.assertEqual(
|
||||||
|
brains[0].getPath(),
|
||||||
'/plone/folder2/moveme/++conversation++default/' +
|
'/plone/folder2/moveme/++conversation++default/' +
|
||||||
str(comment_id))
|
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)
|
||||||
|
|
||||||
@ -395,9 +437,11 @@ class CommentCatalogTest(unittest.TestCase):
|
|||||||
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(
|
||||||
|
brains[0].getPath(),
|
||||||
'/plone/targetfolder/moveme/mydocument/++conversation++default/' +
|
'/plone/targetfolder/moveme/mydocument/++conversation++default/' +
|
||||||
str(comment_id))
|
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(
|
||||||
|
brains[0].getPath(),
|
||||||
'/plone/doc2/++conversation++default/' +
|
'/plone/doc2/++conversation++default/' +
|
||||||
str(self.comment_id))
|
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):
|
||||||
|
|
||||||
@ -523,8 +571,10 @@ 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':
|
||||||
|
'/'.join(self.portal.doc1.getPhysicalPath())
|
||||||
|
},
|
||||||
portal_type="Document"
|
portal_type="Document"
|
||||||
))
|
))
|
||||||
self.conversation = conversation
|
self.conversation = conversation
|
||||||
|
Loading…
Reference in New Issue
Block a user