Avoid using deprecated test assertions, see http://docs.python.org/dev/library/unittest.html#deprecated-aliases for the full list
svn path=/plone.app.discussion/trunk/; revision=48881
This commit is contained in:
parent
811d4a0429
commit
9db8909ea7
@ -54,7 +54,7 @@ you need to set it up and tear it down in each test.
|
|||||||
};
|
};
|
||||||
|
|
||||||
window.equals = function(a, b, msg) {
|
window.equals = function(a, b, msg) {
|
||||||
assertEquals(msg ? msg : '', b, a);
|
assertEqual(msg ? msg : '', b, a);
|
||||||
};
|
};
|
||||||
|
|
||||||
window.start = window.stop = function() {
|
window.start = window.stop = function() {
|
||||||
|
@ -21,13 +21,13 @@ class CatalogSetupTest(PloneTestCase):
|
|||||||
layer = DiscussionLayer
|
layer = DiscussionLayer
|
||||||
|
|
||||||
def test_catalog_installed(self):
|
def test_catalog_installed(self):
|
||||||
self.failUnless('total_comments' in
|
self.assertTrue('total_comments' in
|
||||||
self.portal.portal_catalog.indexes())
|
self.portal.portal_catalog.indexes())
|
||||||
self.failUnless('commentators' in
|
self.assertTrue('commentators' in
|
||||||
self.portal.portal_catalog.indexes())
|
self.portal.portal_catalog.indexes())
|
||||||
self.failUnless('total_comments' in
|
self.assertTrue('total_comments' in
|
||||||
self.portal.portal_catalog.schema())
|
self.portal.portal_catalog.schema())
|
||||||
self.failUnless('in_response_to' in
|
self.assertTrue('in_response_to' in
|
||||||
self.portal.portal_catalog.schema())
|
self.portal.portal_catalog.schema())
|
||||||
|
|
||||||
def test_collection_criteria_installed(self):
|
def test_collection_criteria_installed(self):
|
||||||
@ -77,8 +77,8 @@ class ConversationCatalogTest(PloneTestCase):
|
|||||||
self.new_comment1_id = new_comment1_id
|
self.new_comment1_id = new_comment1_id
|
||||||
|
|
||||||
def test_total_comments(self):
|
def test_total_comments(self):
|
||||||
self.failUnless('total_comments' in self.doc1_brain)
|
self.assertTrue('total_comments' in self.doc1_brain)
|
||||||
self.assertEquals(self.doc1_brain.total_comments, 1)
|
self.assertEqual(self.doc1_brain.total_comments, 1)
|
||||||
|
|
||||||
comment2 = createObject('plone.Comment')
|
comment2 = createObject('plone.Comment')
|
||||||
comment2.title = 'Comment 2'
|
comment2.title = 'Comment 2'
|
||||||
@ -95,11 +95,11 @@ class ConversationCatalogTest(PloneTestCase):
|
|||||||
portal_type="Document"
|
portal_type="Document"
|
||||||
))
|
))
|
||||||
doc1_brain = brains[0]
|
doc1_brain = brains[0]
|
||||||
self.assertEquals(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.failUnless('last_comment_date' in self.doc1_brain)
|
self.assertTrue('last_comment_date' in self.doc1_brain)
|
||||||
self.assertEquals(self.doc1_brain.last_comment_date,
|
self.assertEqual(self.doc1_brain.last_comment_date,
|
||||||
datetime(2006, 9, 17, 14, 18, 12))
|
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.
|
||||||
@ -120,7 +120,7 @@ class ConversationCatalogTest(PloneTestCase):
|
|||||||
portal_type="Document"
|
portal_type="Document"
|
||||||
))
|
))
|
||||||
doc1_brain = brains[0]
|
doc1_brain = brains[0]
|
||||||
self.assertEquals(doc1_brain.last_comment_date,
|
self.assertEqual(doc1_brain.last_comment_date,
|
||||||
datetime(2009, 9, 17, 14, 18, 12))
|
datetime(2009, 9, 17, 14, 18, 12))
|
||||||
|
|
||||||
# Remove the comment again
|
# Remove the comment again
|
||||||
@ -133,7 +133,7 @@ class ConversationCatalogTest(PloneTestCase):
|
|||||||
))
|
))
|
||||||
doc1_brain = brains[0]
|
doc1_brain = brains[0]
|
||||||
|
|
||||||
self.assertEquals(doc1_brain.last_comment_date,
|
self.assertEqual(doc1_brain.last_comment_date,
|
||||||
datetime(2006, 9, 17, 14, 18, 12))
|
datetime(2006, 9, 17, 14, 18, 12))
|
||||||
|
|
||||||
# remove all comments
|
# remove all comments
|
||||||
@ -144,11 +144,11 @@ class ConversationCatalogTest(PloneTestCase):
|
|||||||
portal_type="Document"
|
portal_type="Document"
|
||||||
))
|
))
|
||||||
doc1_brain = brains[0]
|
doc1_brain = brains[0]
|
||||||
self.assertEquals(doc1_brain.last_comment_date, None)
|
self.assertEqual(doc1_brain.last_comment_date, None)
|
||||||
|
|
||||||
def test_commentators(self):
|
def test_commentators(self):
|
||||||
self.failUnless('commentators' in self.doc1_brain)
|
self.assertTrue('commentators' in self.doc1_brain)
|
||||||
self.assertEquals(self.doc1_brain.commentators, ('Jim',))
|
self.assertEqual(self.doc1_brain.commentators, ('Jim',))
|
||||||
|
|
||||||
# add another comment with another author
|
# add another comment with another author
|
||||||
comment2 = createObject('plone.Comment')
|
comment2 = createObject('plone.Comment')
|
||||||
@ -169,7 +169,7 @@ class ConversationCatalogTest(PloneTestCase):
|
|||||||
))
|
))
|
||||||
doc1_brain = brains[0]
|
doc1_brain = brains[0]
|
||||||
|
|
||||||
self.assertEquals(doc1_brain.commentators, ('Emma', 'Jim'))
|
self.assertEqual(doc1_brain.commentators, ('Emma', 'Jim'))
|
||||||
|
|
||||||
# remove one comments
|
# remove one comments
|
||||||
del self.conversation[new_comment2_id]
|
del self.conversation[new_comment2_id]
|
||||||
@ -179,7 +179,7 @@ class ConversationCatalogTest(PloneTestCase):
|
|||||||
portal_type="Document"
|
portal_type="Document"
|
||||||
))
|
))
|
||||||
doc1_brain = brains[0]
|
doc1_brain = brains[0]
|
||||||
self.assertEquals(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]
|
||||||
@ -189,7 +189,7 @@ class ConversationCatalogTest(PloneTestCase):
|
|||||||
portal_type="Document"
|
portal_type="Document"
|
||||||
))
|
))
|
||||||
doc1_brain = brains[0]
|
doc1_brain = brains[0]
|
||||||
self.assertEquals(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(
|
||||||
@ -198,9 +198,9 @@ class ConversationCatalogTest(PloneTestCase):
|
|||||||
portal_type="Discussion Item"
|
portal_type="Discussion Item"
|
||||||
))
|
))
|
||||||
comment1_brain = brains[0]
|
comment1_brain = brains[0]
|
||||||
self.assertEquals(comment1_brain.commentators, None)
|
self.assertEqual(comment1_brain.commentators, None)
|
||||||
self.assertEquals(comment1_brain.last_comment_date, None)
|
self.assertEqual(comment1_brain.last_comment_date, None)
|
||||||
self.assertEquals(comment1_brain.total_comments, None)
|
self.assertEqual(comment1_brain.total_comments, None)
|
||||||
|
|
||||||
|
|
||||||
class CommentCatalogTest(PloneTestCase):
|
class CommentCatalogTest(PloneTestCase):
|
||||||
@ -234,7 +234,7 @@ class CommentCatalogTest(PloneTestCase):
|
|||||||
self.comment_brain = brains[0]
|
self.comment_brain = brains[0]
|
||||||
|
|
||||||
def test_title(self):
|
def test_title(self):
|
||||||
self.assertEquals(self.comment_brain.Title, 'Jim on Document 1')
|
self.assertEqual(self.comment_brain.Title, 'Jim on Document 1')
|
||||||
|
|
||||||
def test_no_name_title(self):
|
def test_no_name_title(self):
|
||||||
comment = createObject('plone.Comment')
|
comment = createObject('plone.Comment')
|
||||||
@ -248,27 +248,27 @@ class CommentCatalogTest(PloneTestCase):
|
|||||||
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.assertEqual(comment_brain.Title, "Anonymous on Document 1")
|
||||||
|
|
||||||
def test_type(self):
|
def test_type(self):
|
||||||
self.assertEquals(self.comment_brain.portal_type, 'Discussion Item')
|
self.assertEqual(self.comment_brain.portal_type, 'Discussion Item')
|
||||||
self.assertEquals(self.comment_brain.meta_type, 'Discussion Item')
|
self.assertEqual(self.comment_brain.meta_type, 'Discussion Item')
|
||||||
self.assertEquals(self.comment_brain.Type, 'Comment')
|
self.assertEqual(self.comment_brain.Type, 'Comment')
|
||||||
|
|
||||||
def test_review_state(self):
|
def test_review_state(self):
|
||||||
self.assertEquals(self.comment_brain.review_state, 'published')
|
self.assertEqual(self.comment_brain.review_state, 'published')
|
||||||
|
|
||||||
def test_creator(self):
|
def test_creator(self):
|
||||||
self.assertEquals(self.comment_brain.Creator, 'Jim')
|
self.assertEqual(self.comment_brain.Creator, 'Jim')
|
||||||
|
|
||||||
def test_in_response_to(self):
|
def test_in_response_to(self):
|
||||||
"""Make sure in_response_to returns the title or id of the content
|
"""Make sure in_response_to returns the title or id of the content
|
||||||
object the comment was added to.
|
object the comment was added to.
|
||||||
"""
|
"""
|
||||||
self.assertEquals(self.comment_brain.in_response_to, 'Document 1')
|
self.assertEqual(self.comment_brain.in_response_to, 'Document 1')
|
||||||
|
|
||||||
def test_add_comment(self):
|
def test_add_comment(self):
|
||||||
self.failUnless(self.comment_brain)
|
self.assertTrue(self.comment_brain)
|
||||||
|
|
||||||
def test_delete_comment(self):
|
def test_delete_comment(self):
|
||||||
# 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
|
||||||
@ -277,17 +277,17 @@ class CommentCatalogTest(PloneTestCase):
|
|||||||
brains = self.catalog.searchResults(dict(
|
brains = self.catalog.searchResults(dict(
|
||||||
path={'query':
|
path={'query':
|
||||||
'/'.join(self.comment.getPhysicalPath())}))
|
'/'.join(self.comment.getPhysicalPath())}))
|
||||||
self.assertEquals(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):
|
||||||
"""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.assertEqual(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.assertEqual(len(brains), 0)
|
||||||
|
|
||||||
def test_clear_and_rebuild_catalog(self):
|
def test_clear_and_rebuild_catalog(self):
|
||||||
# Clear and rebuild catalog
|
# Clear and rebuild catalog
|
||||||
@ -295,9 +295,9 @@ class CommentCatalogTest(PloneTestCase):
|
|||||||
|
|
||||||
# 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.assertTrue(brains)
|
||||||
comment_brain = brains[0]
|
comment_brain = brains[0]
|
||||||
self.assertEquals(comment_brain.Title, u'Jim on Document 1')
|
self.assertEqual(comment_brain.Title, u'Jim on Document 1')
|
||||||
|
|
||||||
def test_clear_and_rebuild_catalog_for_nested_comments(self):
|
def test_clear_and_rebuild_catalog_for_nested_comments(self):
|
||||||
|
|
||||||
@ -352,8 +352,8 @@ class CommentCatalogTest(PloneTestCase):
|
|||||||
|
|
||||||
# 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.assertTrue(brains)
|
||||||
self.assertEquals(len(brains), 6)
|
self.assertEqual(len(brains), 6)
|
||||||
|
|
||||||
def test_collection(self):
|
def test_collection(self):
|
||||||
self.portal.invokeFactory(id='topic', type_name='Topic')
|
self.portal.invokeFactory(id='topic', type_name='Topic')
|
||||||
@ -363,9 +363,9 @@ class CommentCatalogTest(PloneTestCase):
|
|||||||
query = topic.buildQuery()
|
query = topic.buildQuery()
|
||||||
|
|
||||||
# Make sure the comment we just added is returned by the collection
|
# Make sure the comment we just added is returned by the collection
|
||||||
self.assertEquals(len(query), 1)
|
self.assertEqual(len(query), 1)
|
||||||
self.assertEquals(query['Type'], 'Comment')
|
self.assertEqual(query['Type'], 'Comment')
|
||||||
self.assertEquals(len(topic.queryCatalog()), 1)
|
self.assertEqual(len(topic.queryCatalog()), 1)
|
||||||
|
|
||||||
|
|
||||||
class NoConversationCatalogTest(PloneTestCase):
|
class NoConversationCatalogTest(PloneTestCase):
|
||||||
@ -393,11 +393,11 @@ class NoConversationCatalogTest(PloneTestCase):
|
|||||||
self.doc1_brain = brains[0]
|
self.doc1_brain = brains[0]
|
||||||
|
|
||||||
def test_total_comments(self):
|
def test_total_comments(self):
|
||||||
self.failUnless('total_comments' in self.doc1_brain)
|
self.assertTrue('total_comments' in self.doc1_brain)
|
||||||
self.assertEquals(self.doc1_brain.total_comments, 0)
|
self.assertEqual(self.doc1_brain.total_comments, 0)
|
||||||
|
|
||||||
# Make sure no conversation has been created
|
# Make sure no conversation has been created
|
||||||
self.assert_('plone.app.discussion:conversation' not in
|
self.assertTrue('plone.app.discussion:conversation' not in
|
||||||
IAnnotations(self.portal.doc1))
|
IAnnotations(self.portal.doc1))
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ class CommentTest(PloneTestCase):
|
|||||||
|
|
||||||
def test_factory(self):
|
def test_factory(self):
|
||||||
comment1 = createObject('plone.Comment')
|
comment1 = createObject('plone.Comment')
|
||||||
self.assert_(IComment.providedBy(comment1))
|
self.assertTrue(IComment.providedBy(comment1))
|
||||||
|
|
||||||
def test_UTCDates(self):
|
def test_UTCDates(self):
|
||||||
utc_to_local_diff = datetime.datetime.now() - datetime.datetime.utcnow()
|
utc_to_local_diff = datetime.datetime.now() - datetime.datetime.utcnow()
|
||||||
@ -61,9 +61,9 @@ class CommentTest(PloneTestCase):
|
|||||||
def test_id(self):
|
def test_id(self):
|
||||||
comment1 = createObject('plone.Comment')
|
comment1 = createObject('plone.Comment')
|
||||||
comment1.comment_id = 123
|
comment1.comment_id = 123
|
||||||
self.assertEquals('123', comment1.id)
|
self.assertEqual('123', comment1.id)
|
||||||
self.assertEquals('123', comment1.getId())
|
self.assertEqual('123', comment1.getId())
|
||||||
self.assertEquals(u'123', comment1.__name__)
|
self.assertEqual(u'123', comment1.__name__)
|
||||||
|
|
||||||
def test_uid(self):
|
def test_uid(self):
|
||||||
conversation = IConversation(self.portal.doc1)
|
conversation = IConversation(self.portal.doc1)
|
||||||
@ -71,7 +71,7 @@ class CommentTest(PloneTestCase):
|
|||||||
conversation.addComment(comment1)
|
conversation.addComment(comment1)
|
||||||
comment_brain = self.catalog.searchResults(
|
comment_brain = self.catalog.searchResults(
|
||||||
portal_type = 'Discussion Item')[0]
|
portal_type = 'Discussion Item')[0]
|
||||||
self.failUnless(comment_brain.UID)
|
self.assertTrue(comment_brain.UID)
|
||||||
|
|
||||||
def test_uid_is_unique(self):
|
def test_uid_is_unique(self):
|
||||||
conversation = IConversation(self.portal.doc1)
|
conversation = IConversation(self.portal.doc1)
|
||||||
@ -81,7 +81,7 @@ class CommentTest(PloneTestCase):
|
|||||||
conversation.addComment(comment2)
|
conversation.addComment(comment2)
|
||||||
brains = self.catalog.searchResults(
|
brains = self.catalog.searchResults(
|
||||||
portal_type = 'Discussion Item')
|
portal_type = 'Discussion Item')
|
||||||
self.assertNotEquals(brains[0].UID, brains[1].UID)
|
self.assertNotEqual(brains[0].UID, brains[1].UID)
|
||||||
|
|
||||||
def test_comment_uid_differs_from_content_uid(self):
|
def test_comment_uid_differs_from_content_uid(self):
|
||||||
conversation = IConversation(self.portal.doc1)
|
conversation = IConversation(self.portal.doc1)
|
||||||
@ -89,20 +89,20 @@ class CommentTest(PloneTestCase):
|
|||||||
conversation.addComment(comment1)
|
conversation.addComment(comment1)
|
||||||
comment_brain = self.catalog.searchResults(
|
comment_brain = self.catalog.searchResults(
|
||||||
portal_type = 'Discussion Item')[0]
|
portal_type = 'Discussion Item')[0]
|
||||||
self.assertNotEquals(self.document_brain.UID, comment_brain.UID)
|
self.assertNotEqual(self.document_brain.UID, comment_brain.UID)
|
||||||
|
|
||||||
def test_title(self):
|
def test_title(self):
|
||||||
conversation = IConversation(self.portal.doc1)
|
conversation = IConversation(self.portal.doc1)
|
||||||
comment1 = createObject('plone.Comment')
|
comment1 = createObject('plone.Comment')
|
||||||
comment1.creator = "Jim Fulton"
|
comment1.creator = "Jim Fulton"
|
||||||
conversation.addComment(comment1)
|
conversation.addComment(comment1)
|
||||||
self.assertEquals("Jim Fulton on Document 1", comment1.Title())
|
self.assertEqual("Jim Fulton on Document 1", comment1.Title())
|
||||||
|
|
||||||
def test_no_name_title(self):
|
def test_no_name_title(self):
|
||||||
conversation = IConversation(self.portal.doc1)
|
conversation = IConversation(self.portal.doc1)
|
||||||
comment1 = createObject('plone.Comment')
|
comment1 = createObject('plone.Comment')
|
||||||
conversation.addComment(comment1)
|
conversation.addComment(comment1)
|
||||||
self.assertEquals("Anonymous on Document 1", comment1.Title())
|
self.assertEqual("Anonymous on Document 1", comment1.Title())
|
||||||
|
|
||||||
def test_title_special_characters(self):
|
def test_title_special_characters(self):
|
||||||
self.portal.invokeFactory(id='doc_sp_chars',
|
self.portal.invokeFactory(id='doc_sp_chars',
|
||||||
@ -112,54 +112,54 @@ class CommentTest(PloneTestCase):
|
|||||||
comment1 = createObject('plone.Comment')
|
comment1 = createObject('plone.Comment')
|
||||||
comment1.creator = u"Tarek Ziadé"
|
comment1.creator = u"Tarek Ziadé"
|
||||||
conversation.addComment(comment1)
|
conversation.addComment(comment1)
|
||||||
self.assertEquals(u"Tarek Ziadé on Document äüö", comment1.Title())
|
self.assertEqual(u"Tarek Ziadé on Document äüö", comment1.Title())
|
||||||
|
|
||||||
def test_creator(self):
|
def test_creator(self):
|
||||||
comment1 = createObject('plone.Comment')
|
comment1 = createObject('plone.Comment')
|
||||||
comment1.creator = "Jim"
|
comment1.creator = "Jim"
|
||||||
self.assertEquals("Jim", comment1.Creator())
|
self.assertEqual("Jim", comment1.Creator())
|
||||||
|
|
||||||
def test_type(self):
|
def test_type(self):
|
||||||
comment1 = createObject('plone.Comment')
|
comment1 = createObject('plone.Comment')
|
||||||
self.assertEquals(comment1.Type(), 'Comment')
|
self.assertEqual(comment1.Type(), 'Comment')
|
||||||
|
|
||||||
def test_getText(self):
|
def test_getText(self):
|
||||||
comment1 = createObject('plone.Comment')
|
comment1 = createObject('plone.Comment')
|
||||||
comment1.text = """First paragraph
|
comment1.text = """First paragraph
|
||||||
|
|
||||||
Second paragraph"""
|
Second paragraph"""
|
||||||
self.assertEquals(comment1.getText(),
|
self.assertEqual(comment1.getText(),
|
||||||
"<p>First paragraph<br /><br /> Second paragraph</p>")
|
"<p>First paragraph<br /><br /> Second paragraph</p>")
|
||||||
|
|
||||||
def test_getText_escapes_HTML(self):
|
def test_getText_escapes_HTML(self):
|
||||||
comment1 = createObject('plone.Comment')
|
comment1 = createObject('plone.Comment')
|
||||||
comment1.text = """<b>Got HTML?</b>"""
|
comment1.text = """<b>Got HTML?</b>"""
|
||||||
self.assertEquals(comment1.getText(),
|
self.assertEqual(comment1.getText(),
|
||||||
"<p><b>Got HTML?</b></p>")
|
"<p><b>Got HTML?</b></p>")
|
||||||
|
|
||||||
def test_getText_with_non_ascii_characters(self):
|
def test_getText_with_non_ascii_characters(self):
|
||||||
comment1 = createObject('plone.Comment')
|
comment1 = createObject('plone.Comment')
|
||||||
comment1.text = u"""Umlaute sind ä, ö und ü."""
|
comment1.text = u"""Umlaute sind ä, ö und ü."""
|
||||||
self.assertEquals(comment1.getText(),
|
self.assertEqual(comment1.getText(),
|
||||||
'<p>Umlaute sind \xc3\xa4, \xc3\xb6 und \xc3\xbc.</p>')
|
'<p>Umlaute sind \xc3\xa4, \xc3\xb6 und \xc3\xbc.</p>')
|
||||||
|
|
||||||
def test_getText_doesnt_link(self):
|
def test_getText_doesnt_link(self):
|
||||||
comment1 = createObject('plone.Comment')
|
comment1 = createObject('plone.Comment')
|
||||||
comment1.text = "Go to http://www.plone.org"
|
comment1.text = "Go to http://www.plone.org"
|
||||||
self.assertEquals(comment1.getText(),
|
self.assertEqual(comment1.getText(),
|
||||||
"<p>Go to http://www.plone.org</p>")
|
"<p>Go to http://www.plone.org</p>")
|
||||||
|
|
||||||
def test_getText_uses_comment_mime_type(self):
|
def test_getText_uses_comment_mime_type(self):
|
||||||
comment1 = createObject('plone.Comment')
|
comment1 = createObject('plone.Comment')
|
||||||
comment1.text = "Go to http://www.plone.org"
|
comment1.text = "Go to http://www.plone.org"
|
||||||
comment1.mime_type = 'text/x-web-intelligent'
|
comment1.mime_type = 'text/x-web-intelligent'
|
||||||
self.assertEquals(comment1.getText(),
|
self.assertEqual(comment1.getText(),
|
||||||
'Go to <a href="http://www.plone.org" rel="nofollow">http://www.plone.org</a>')
|
'Go to <a href="http://www.plone.org" rel="nofollow">http://www.plone.org</a>')
|
||||||
|
|
||||||
def test_getText_w_custom_targetMimetype(self):
|
def test_getText_w_custom_targetMimetype(self):
|
||||||
comment1 = createObject('plone.Comment')
|
comment1 = createObject('plone.Comment')
|
||||||
comment1.text = 'para'
|
comment1.text = 'para'
|
||||||
self.assertEquals(comment1.getText(targetMimetype='text/plain'), 'para')
|
self.assertEqual(comment1.getText(targetMimetype='text/plain'), 'para')
|
||||||
|
|
||||||
def test_traversal(self):
|
def test_traversal(self):
|
||||||
# make sure comments are traversable, have an id, absolute_url and
|
# make sure comments are traversable, have an id, absolute_url and
|
||||||
@ -174,11 +174,11 @@ class CommentTest(PloneTestCase):
|
|||||||
|
|
||||||
comment = self.portal.doc1.restrictedTraverse(
|
comment = self.portal.doc1.restrictedTraverse(
|
||||||
'++conversation++default/%s' % new_comment1_id)
|
'++conversation++default/%s' % new_comment1_id)
|
||||||
self.assert_(IComment.providedBy(comment))
|
self.assertTrue(IComment.providedBy(comment))
|
||||||
|
|
||||||
self.assertEquals(('', 'plone', 'doc1', '++conversation++default',
|
self.assertEqual(('', 'plone', 'doc1', '++conversation++default',
|
||||||
str(new_comment1_id)), comment.getPhysicalPath())
|
str(new_comment1_id)), comment.getPhysicalPath())
|
||||||
self.assertEquals('http://nohost/plone/doc1/++conversation++default/' +
|
self.assertEqual('http://nohost/plone/doc1/++conversation++default/' +
|
||||||
str(new_comment1_id), comment.absolute_url())
|
str(new_comment1_id), comment.absolute_url())
|
||||||
|
|
||||||
def test_workflow(self):
|
def test_workflow(self):
|
||||||
@ -196,26 +196,26 @@ class CommentTest(PloneTestCase):
|
|||||||
|
|
||||||
# Make sure comments use the 'comment_review_workflow'
|
# Make sure comments use the 'comment_review_workflow'
|
||||||
chain = self.portal.portal_workflow.getChainFor(comment)
|
chain = self.portal.portal_workflow.getChainFor(comment)
|
||||||
self.assertEquals(('comment_review_workflow',), chain)
|
self.assertEqual(('comment_review_workflow',), chain)
|
||||||
|
|
||||||
# Ensure the initial state was entered and recorded
|
# Ensure the initial state was entered and recorded
|
||||||
self.assertEquals(1,
|
self.assertEqual(1,
|
||||||
len(comment.workflow_history['comment_review_workflow']))
|
len(comment.workflow_history['comment_review_workflow']))
|
||||||
self.assertEquals(None,
|
self.assertEqual(None,
|
||||||
comment.workflow_history['comment_review_workflow'][0]\
|
comment.workflow_history['comment_review_workflow'][0]\
|
||||||
['action'])
|
['action'])
|
||||||
self.assertEquals('pending',
|
self.assertEqual('pending',
|
||||||
self.portal.portal_workflow.getInfoFor(comment, 'review_state'))
|
self.portal.portal_workflow.getInfoFor(comment, 'review_state'))
|
||||||
|
|
||||||
def test_fti(self):
|
def test_fti(self):
|
||||||
# test that we can look up an FTI for Discussion Item
|
# test that we can look up an FTI for Discussion Item
|
||||||
|
|
||||||
self.assert_("Discussion Item" in self.portal.portal_types.objectIds())
|
self.assertTrue("Discussion Item" in self.portal.portal_types.objectIds())
|
||||||
|
|
||||||
comment1 = createObject('plone.Comment')
|
comment1 = createObject('plone.Comment')
|
||||||
|
|
||||||
fti = self.portal.portal_types.getTypeInfo(comment1)
|
fti = self.portal.portal_types.getTypeInfo(comment1)
|
||||||
self.assertEquals('Discussion Item', fti.getTypeInfo(comment1).getId())
|
self.assertEqual('Discussion Item', fti.getTypeInfo(comment1).getId())
|
||||||
|
|
||||||
def test_view(self):
|
def test_view(self):
|
||||||
# make sure that the comment view is there and redirects to the right
|
# make sure that the comment view is there and redirects to the right
|
||||||
@ -236,14 +236,14 @@ class CommentTest(PloneTestCase):
|
|||||||
'++conversation++default/%s' % new_comment1_id)
|
'++conversation++default/%s' % new_comment1_id)
|
||||||
|
|
||||||
# make sure the view is there
|
# make sure the view is there
|
||||||
self.failUnless(getMultiAdapter((comment, self.app.REQUEST),
|
self.assertTrue(getMultiAdapter((comment, self.app.REQUEST),
|
||||||
name='view'))
|
name='view'))
|
||||||
|
|
||||||
# make sure the HTTP redirect (status code 302) works when a comment
|
# make sure the HTTP redirect (status code 302) works when a comment
|
||||||
# is called directly
|
# is called directly
|
||||||
view = View(comment, self.app.REQUEST)
|
view = View(comment, self.app.REQUEST)
|
||||||
View.__call__(view)
|
View.__call__(view)
|
||||||
self.assertEquals(self.app.REQUEST.response.status, 302)
|
self.assertEqual(self.app.REQUEST.response.status, 302)
|
||||||
|
|
||||||
|
|
||||||
class RepliesTest(PloneTestCase):
|
class RepliesTest(PloneTestCase):
|
||||||
@ -284,16 +284,16 @@ class RepliesTest(PloneTestCase):
|
|||||||
new_re_id = replies.addComment(re_comment)
|
new_re_id = replies.addComment(re_comment)
|
||||||
|
|
||||||
# check that replies provides the IReplies interface
|
# check that replies provides the IReplies interface
|
||||||
self.assert_(IReplies.providedBy(replies))
|
self.assertTrue(IReplies.providedBy(replies))
|
||||||
|
|
||||||
# Make sure our comment was added
|
# Make sure our comment was added
|
||||||
self.failUnless(new_re_id in replies)
|
self.assertTrue(new_re_id in replies)
|
||||||
|
|
||||||
# Make sure it is also reflected in the conversation
|
# Make sure it is also reflected in the conversation
|
||||||
self.failUnless(new_re_id in conversation)
|
self.assertTrue(new_re_id in conversation)
|
||||||
|
|
||||||
# Make sure the conversation has the correct comment id
|
# Make sure the conversation has the correct comment id
|
||||||
self.assertEquals(conversation[new_re_id].comment_id, new_re_id)
|
self.assertEqual(conversation[new_re_id].comment_id, new_re_id)
|
||||||
|
|
||||||
def test_delete_comment(self):
|
def test_delete_comment(self):
|
||||||
# Add and remove a comment to a CommentReplies adapter
|
# Add and remove a comment to a CommentReplies adapter
|
||||||
@ -323,10 +323,10 @@ class RepliesTest(PloneTestCase):
|
|||||||
del replies[new_re_id]
|
del replies[new_re_id]
|
||||||
|
|
||||||
# Make sure there is no comment left in CommentReplies
|
# Make sure there is no comment left in CommentReplies
|
||||||
self.assertEquals(len(replies), 0)
|
self.assertEqual(len(replies), 0)
|
||||||
|
|
||||||
# Make sure the first comment is still in the conversation
|
# Make sure the first comment is still in the conversation
|
||||||
self.assertEquals(conversation.total_comments, 1)
|
self.assertEqual(conversation.total_comments, 1)
|
||||||
|
|
||||||
def test_traversal(self):
|
def test_traversal(self):
|
||||||
# Create a nested structure of comment replies and check the traversal
|
# Create a nested structure of comment replies and check the traversal
|
||||||
@ -370,22 +370,22 @@ class RepliesTest(PloneTestCase):
|
|||||||
re_re_re_comment = self.portal.doc1.restrictedTraverse(
|
re_re_re_comment = self.portal.doc1.restrictedTraverse(
|
||||||
'++conversation++default/%s' % new_re_re_re_id)
|
'++conversation++default/%s' % new_re_re_re_id)
|
||||||
|
|
||||||
self.assertEquals(('', 'plone', 'doc1', '++conversation++default',
|
self.assertEqual(('', 'plone', 'doc1', '++conversation++default',
|
||||||
str(new_id)), comment.getPhysicalPath())
|
str(new_id)), comment.getPhysicalPath())
|
||||||
self.assertEquals('http://nohost/plone/doc1/++conversation++default/' +
|
self.assertEqual('http://nohost/plone/doc1/++conversation++default/' +
|
||||||
str(new_id), comment.absolute_url())
|
str(new_id), comment.absolute_url())
|
||||||
self.assertEquals(('', 'plone', 'doc1', '++conversation++default',
|
self.assertEqual(('', 'plone', 'doc1', '++conversation++default',
|
||||||
str(new_re_id)), re_comment.getPhysicalPath())
|
str(new_re_id)), re_comment.getPhysicalPath())
|
||||||
self.assertEquals('http://nohost/plone/doc1/++conversation++default/' +
|
self.assertEqual('http://nohost/plone/doc1/++conversation++default/' +
|
||||||
str(new_re_id), re_comment.absolute_url())
|
str(new_re_id), re_comment.absolute_url())
|
||||||
self.assertEquals(('', 'plone', 'doc1', '++conversation++default',
|
self.assertEqual(('', 'plone', 'doc1', '++conversation++default',
|
||||||
str(new_re_re_id)), re_re_comment.getPhysicalPath())
|
str(new_re_re_id)), re_re_comment.getPhysicalPath())
|
||||||
self.assertEquals('http://nohost/plone/doc1/++conversation++default/' +
|
self.assertEqual('http://nohost/plone/doc1/++conversation++default/' +
|
||||||
str(new_re_re_id), re_re_comment.absolute_url())
|
str(new_re_re_id), re_re_comment.absolute_url())
|
||||||
self.assertEquals(('', 'plone', 'doc1', '++conversation++default',
|
self.assertEqual(('', 'plone', 'doc1', '++conversation++default',
|
||||||
str(new_re_re_re_id)),
|
str(new_re_re_re_id)),
|
||||||
re_re_re_comment.getPhysicalPath())
|
re_re_re_comment.getPhysicalPath())
|
||||||
self.assertEquals('http://nohost/plone/doc1/++conversation++default/' +
|
self.assertEqual('http://nohost/plone/doc1/++conversation++default/' +
|
||||||
str(new_re_re_re_id),
|
str(new_re_re_re_id),
|
||||||
re_re_re_comment.absolute_url())
|
re_re_re_comment.absolute_url())
|
||||||
|
|
||||||
|
@ -89,8 +89,8 @@ class TestCommentForm(PloneTestCase):
|
|||||||
commentForm.update()
|
commentForm.update()
|
||||||
data, errors = commentForm.extractData() # pylint: disable-msg=W0612
|
data, errors = commentForm.extractData() # pylint: disable-msg=W0612
|
||||||
|
|
||||||
self.assertEquals(len(errors), 1)
|
self.assertEqual(len(errors), 1)
|
||||||
self.failIf(commentForm.handleComment(commentForm, "foo"))
|
self.assertFalse(commentForm.handleComment(commentForm, "foo"))
|
||||||
|
|
||||||
# The form is submitted successfully, if the required text field is
|
# The form is submitted successfully, if the required text field is
|
||||||
# filled out
|
# filled out
|
||||||
@ -101,8 +101,8 @@ class TestCommentForm(PloneTestCase):
|
|||||||
commentForm.update()
|
commentForm.update()
|
||||||
data, errors = commentForm.extractData() # pylint: disable-msg=W0612
|
data, errors = commentForm.extractData() # pylint: disable-msg=W0612
|
||||||
|
|
||||||
self.assertEquals(len(errors), 0)
|
self.assertEqual(len(errors), 0)
|
||||||
self.failIf(commentForm.handleComment(commentForm, "foo"))
|
self.assertFalse(commentForm.handleComment(commentForm, "foo"))
|
||||||
|
|
||||||
def test_add_anonymous_comment(self):
|
def test_add_anonymous_comment(self):
|
||||||
"""Add a comment as anonymous.
|
"""Add a comment as anonymous.
|
||||||
@ -142,8 +142,8 @@ class TestCommentForm(PloneTestCase):
|
|||||||
commentForm.update()
|
commentForm.update()
|
||||||
data, errors = commentForm.extractData() # pylint: disable-msg=W0612
|
data, errors = commentForm.extractData() # pylint: disable-msg=W0612
|
||||||
|
|
||||||
self.assertEquals(len(errors), 0)
|
self.assertEqual(len(errors), 0)
|
||||||
self.failIf(commentForm.handleComment(commentForm, "action"))
|
self.assertFalse(commentForm.handleComment(commentForm, "action"))
|
||||||
|
|
||||||
def test_can_not_add_comments_if_discussion_is_not_allowed(self):
|
def test_can_not_add_comments_if_discussion_is_not_allowed(self):
|
||||||
"""Make sure that comments can't be posted if discussion is disabled.
|
"""Make sure that comments can't be posted if discussion is disabled.
|
||||||
@ -172,7 +172,7 @@ class TestCommentForm(PloneTestCase):
|
|||||||
|
|
||||||
# No form errors, but raise unauthorized because discussion is not
|
# No form errors, but raise unauthorized because discussion is not
|
||||||
# allowed
|
# allowed
|
||||||
self.assertEquals(len(errors), 0)
|
self.assertEqual(len(errors), 0)
|
||||||
self.assertRaises(Unauthorized,
|
self.assertRaises(Unauthorized,
|
||||||
commentForm.handleComment,
|
commentForm.handleComment,
|
||||||
commentForm,
|
commentForm,
|
||||||
@ -206,7 +206,7 @@ class TestCommentForm(PloneTestCase):
|
|||||||
commentForm.update()
|
commentForm.update()
|
||||||
data, errors = commentForm.extractData() # pylint: disable-msg=W0612
|
data, errors = commentForm.extractData() # pylint: disable-msg=W0612
|
||||||
|
|
||||||
self.assertEquals(len(errors), 0)
|
self.assertEqual(len(errors), 0)
|
||||||
self.assertRaises(Unauthorized,
|
self.assertRaises(Unauthorized,
|
||||||
commentForm.handleComment,
|
commentForm.handleComment,
|
||||||
commentForm,
|
commentForm,
|
||||||
@ -240,21 +240,21 @@ class TestCommentsViewlet(PloneTestCase):
|
|||||||
|
|
||||||
def test_can_reply(self):
|
def test_can_reply(self):
|
||||||
# Portal owner can reply
|
# Portal owner can reply
|
||||||
self.failUnless(self.viewlet.can_reply())
|
self.assertTrue(self.viewlet.can_reply())
|
||||||
self.logout()
|
self.logout()
|
||||||
# Anonymous users can not reply
|
# Anonymous users can not reply
|
||||||
self.failIf(self.viewlet.can_reply())
|
self.assertFalse(self.viewlet.can_reply())
|
||||||
|
|
||||||
def test_can_review(self):
|
def test_can_review(self):
|
||||||
# Portal owner has 'can review' permission
|
# Portal owner has 'can review' permission
|
||||||
self.failUnless(self.viewlet.can_review())
|
self.assertTrue(self.viewlet.can_review())
|
||||||
self.logout()
|
self.logout()
|
||||||
# Anonymous has no 'can review' permission
|
# Anonymous has no 'can review' permission
|
||||||
self.failIf(self.viewlet.can_review())
|
self.assertFalse(self.viewlet.can_review())
|
||||||
# The reviewer role has the 'Review comments' permission
|
# The reviewer role has the 'Review comments' permission
|
||||||
self.portal.acl_users._doAddUser('reviewer', 'secret', ['Reviewer'], [])
|
self.portal.acl_users._doAddUser('reviewer', 'secret', ['Reviewer'], [])
|
||||||
self.login('reviewer')
|
self.login('reviewer')
|
||||||
self.failUnless(self.viewlet.can_review())
|
self.assertTrue(self.viewlet.can_review())
|
||||||
|
|
||||||
def test_can_manage(self):
|
def test_can_manage(self):
|
||||||
"""We keep this method for backward compatibility. This method has been
|
"""We keep this method for backward compatibility. This method has been
|
||||||
@ -262,29 +262,29 @@ class TestCommentsViewlet(PloneTestCase):
|
|||||||
do API changes in beta releases.
|
do API changes in beta releases.
|
||||||
"""
|
"""
|
||||||
# Portal owner has 'can review' permission
|
# Portal owner has 'can review' permission
|
||||||
self.failUnless(self.viewlet.can_manage())
|
self.assertTrue(self.viewlet.can_manage())
|
||||||
self.logout()
|
self.logout()
|
||||||
# Anonymous has no 'can review' permission
|
# Anonymous has no 'can review' permission
|
||||||
self.failIf(self.viewlet.can_manage())
|
self.assertFalse(self.viewlet.can_manage())
|
||||||
# The reviewer role has the 'Review comments' permission
|
# The reviewer role has the 'Review comments' permission
|
||||||
self.portal.acl_users._doAddUser('reviewer', 'secret', ['Reviewer'], [])
|
self.portal.acl_users._doAddUser('reviewer', 'secret', ['Reviewer'], [])
|
||||||
self.login('reviewer')
|
self.login('reviewer')
|
||||||
self.failUnless(self.viewlet.can_manage())
|
self.assertTrue(self.viewlet.can_manage())
|
||||||
|
|
||||||
def test_is_discussion_allowed(self):
|
def test_is_discussion_allowed(self):
|
||||||
# By default, discussion is disabled
|
# By default, discussion is disabled
|
||||||
self.failIf(self.viewlet.is_discussion_allowed())
|
self.assertFalse(self.viewlet.is_discussion_allowed())
|
||||||
# Enable discussion
|
# Enable discussion
|
||||||
portal_discussion = getToolByName(self.portal, 'portal_discussion')
|
portal_discussion = getToolByName(self.portal, 'portal_discussion')
|
||||||
portal_discussion.overrideDiscussionFor(self.portal.doc1, True)
|
portal_discussion.overrideDiscussionFor(self.portal.doc1, True)
|
||||||
# Test if discussion has been enabled
|
# Test if discussion has been enabled
|
||||||
self.failUnless(self.viewlet.is_discussion_allowed())
|
self.assertTrue(self.viewlet.is_discussion_allowed())
|
||||||
|
|
||||||
def test_comment_transform_message(self):
|
def test_comment_transform_message(self):
|
||||||
|
|
||||||
# Default transform is plain/text and comment moderation disabled
|
# Default transform is plain/text and comment moderation disabled
|
||||||
self.failUnless(self.viewlet.comment_transform_message())
|
self.assertTrue(self.viewlet.comment_transform_message())
|
||||||
self.assertEquals(
|
self.assertEqual(
|
||||||
self.viewlet.comment_transform_message(),
|
self.viewlet.comment_transform_message(),
|
||||||
"You can add a comment by filling out the form below. Plain text " +
|
"You can add a comment by filling out the form below. Plain text " +
|
||||||
"formatting.")
|
"formatting.")
|
||||||
@ -295,7 +295,7 @@ class TestCommentsViewlet(PloneTestCase):
|
|||||||
settings.text_transform = "text/x-web-intelligent"
|
settings.text_transform = "text/x-web-intelligent"
|
||||||
|
|
||||||
# Make sure the comment description changes accordingly
|
# Make sure the comment description changes accordingly
|
||||||
self.assertEquals(
|
self.assertEqual(
|
||||||
self.viewlet.comment_transform_message(),
|
self.viewlet.comment_transform_message(),
|
||||||
"You can add a comment by filling out the form below. " +
|
"You can add a comment by filling out the form below. " +
|
||||||
"Plain text formatting. Web and email addresses are transformed " +
|
"Plain text formatting. Web and email addresses are transformed " +
|
||||||
@ -307,41 +307,41 @@ class TestCommentsViewlet(PloneTestCase):
|
|||||||
('comment_review_workflow,'))
|
('comment_review_workflow,'))
|
||||||
|
|
||||||
# Make sure the comment description shows that comments are moderated
|
# Make sure the comment description shows that comments are moderated
|
||||||
self.assertEquals(
|
self.assertEqual(
|
||||||
self.viewlet.comment_transform_message(),
|
self.viewlet.comment_transform_message(),
|
||||||
"You can add a comment by filling out the form below. " +
|
"You can add a comment by filling out the form below. " +
|
||||||
"Plain text formatting. Web and email addresses are transformed " +
|
"Plain text formatting. Web and email addresses are transformed " +
|
||||||
"into clickable links. Comments are moderated.")
|
"into clickable links. Comments are moderated.")
|
||||||
|
|
||||||
def test_has_replies(self):
|
def test_has_replies(self):
|
||||||
self.assertEquals(self.viewlet.has_replies(), False)
|
self.assertEqual(self.viewlet.has_replies(), False)
|
||||||
comment = createObject('plone.Comment')
|
comment = createObject('plone.Comment')
|
||||||
comment.text = 'Comment text'
|
comment.text = 'Comment text'
|
||||||
conversation = IConversation(self.portal.doc1)
|
conversation = IConversation(self.portal.doc1)
|
||||||
conversation.addComment(comment)
|
conversation.addComment(comment)
|
||||||
self.assertEquals(self.viewlet.has_replies(), True)
|
self.assertEqual(self.viewlet.has_replies(), True)
|
||||||
|
|
||||||
def test_get_replies(self):
|
def test_get_replies(self):
|
||||||
self.failIf(self.viewlet.get_replies())
|
self.assertFalse(self.viewlet.get_replies())
|
||||||
comment = createObject('plone.Comment')
|
comment = createObject('plone.Comment')
|
||||||
comment.text = 'Comment text'
|
comment.text = 'Comment text'
|
||||||
conversation = IConversation(self.portal.doc1)
|
conversation = IConversation(self.portal.doc1)
|
||||||
conversation.addComment(comment)
|
conversation.addComment(comment)
|
||||||
conversation.addComment(comment)
|
conversation.addComment(comment)
|
||||||
replies = self.viewlet.get_replies()
|
replies = self.viewlet.get_replies()
|
||||||
self.assertEquals(len(tuple(replies)), 2)
|
self.assertEqual(len(tuple(replies)), 2)
|
||||||
replies = self.viewlet.get_replies()
|
replies = self.viewlet.get_replies()
|
||||||
replies.next()
|
replies.next()
|
||||||
replies.next()
|
replies.next()
|
||||||
self.assertRaises(StopIteration, replies.next)
|
self.assertRaises(StopIteration, replies.next)
|
||||||
|
|
||||||
def test_get_replies_with_workflow_actions(self):
|
def test_get_replies_with_workflow_actions(self):
|
||||||
self.failIf(self.viewlet.get_replies(workflow_actions=True))
|
self.assertFalse(self.viewlet.get_replies(workflow_actions=True))
|
||||||
comment = createObject('plone.Comment')
|
comment = createObject('plone.Comment')
|
||||||
comment.text = 'Comment text'
|
comment.text = 'Comment text'
|
||||||
conversation = IConversation(self.portal.doc1)
|
conversation = IConversation(self.portal.doc1)
|
||||||
c1 = conversation.addComment(comment)
|
c1 = conversation.addComment(comment)
|
||||||
self.assertEquals(
|
self.assertEqual(
|
||||||
len(tuple(self.viewlet.get_replies(workflow_actions=True))), 1)
|
len(tuple(self.viewlet.get_replies(workflow_actions=True))), 1)
|
||||||
# Enable moderation workflow
|
# Enable moderation workflow
|
||||||
self.portal.portal_workflow.setChainForPortalTypes(
|
self.portal.portal_workflow.setChainForPortalTypes(
|
||||||
@ -349,10 +349,10 @@ class TestCommentsViewlet(PloneTestCase):
|
|||||||
('comment_review_workflow,'))
|
('comment_review_workflow,'))
|
||||||
# Check if workflow actions are available
|
# Check if workflow actions are available
|
||||||
reply = self.viewlet.get_replies(workflow_actions=True).next()
|
reply = self.viewlet.get_replies(workflow_actions=True).next()
|
||||||
self.failUnless(reply.has_key('actions'))
|
self.assertTrue(reply.has_key('actions'))
|
||||||
self.assertEquals(reply['actions'][0]['id'],
|
self.assertEqual(reply['actions'][0]['id'],
|
||||||
'publish')
|
'publish')
|
||||||
self.assertEquals(reply['actions'][0]['url'],
|
self.assertEqual(reply['actions'][0]['url'],
|
||||||
'http://nohost/plone/doc1/++conversation++default/%s' % int(c1) +
|
'http://nohost/plone/doc1/++conversation++default/%s' % int(c1) +
|
||||||
'/content_status_modify?workflow_action=publish')
|
'/content_status_modify?workflow_action=publish')
|
||||||
|
|
||||||
@ -362,11 +362,11 @@ class TestCommentsViewlet(PloneTestCase):
|
|||||||
IConversation(self.portal.doc1)
|
IConversation(self.portal.doc1)
|
||||||
portal_membership = getToolByName(self.portal, 'portal_membership')
|
portal_membership = getToolByName(self.portal, 'portal_membership')
|
||||||
m = portal_membership.getAuthenticatedMember()
|
m = portal_membership.getAuthenticatedMember()
|
||||||
self.assertEquals(self.viewlet.get_commenter_home_url(m.getUserName()),
|
self.assertEqual(self.viewlet.get_commenter_home_url(m.getUserName()),
|
||||||
'http://nohost/plone/author/portal_owner')
|
'http://nohost/plone/author/portal_owner')
|
||||||
|
|
||||||
def test_get_commenter_home_url_is_none(self):
|
def test_get_commenter_home_url_is_none(self):
|
||||||
self.failIf(self.viewlet.get_commenter_home_url())
|
self.assertFalse(self.viewlet.get_commenter_home_url())
|
||||||
|
|
||||||
def test_get_commenter_portrait(self):
|
def test_get_commenter_portrait(self):
|
||||||
|
|
||||||
@ -393,11 +393,11 @@ class TestCommentsViewlet(PloneTestCase):
|
|||||||
portrait_url = self.viewlet.get_commenter_portrait('jim')
|
portrait_url = self.viewlet.get_commenter_portrait('jim')
|
||||||
|
|
||||||
# Check if the correct member image URL is returned
|
# Check if the correct member image URL is returned
|
||||||
self.assertEquals(portrait_url,
|
self.assertEqual(portrait_url,
|
||||||
'http://nohost/plone/portal_memberdata/portraits/jim')
|
'http://nohost/plone/portal_memberdata/portraits/jim')
|
||||||
|
|
||||||
def test_get_commenter_portrait_is_none(self):
|
def test_get_commenter_portrait_is_none(self):
|
||||||
self.assertEquals(self.viewlet.get_commenter_portrait(),
|
self.assertEqual(self.viewlet.get_commenter_portrait(),
|
||||||
'defaultUser.gif')
|
'defaultUser.gif')
|
||||||
|
|
||||||
def test_get_commenter_portrait_without_userimage(self):
|
def test_get_commenter_portrait_without_userimage(self):
|
||||||
@ -420,35 +420,35 @@ class TestCommentsViewlet(PloneTestCase):
|
|||||||
# Check if the correct default member image URL is returned.
|
# Check if the correct default member image URL is returned.
|
||||||
# Note that Products.PlonePAS 4.0.5 and later have .png and
|
# Note that Products.PlonePAS 4.0.5 and later have .png and
|
||||||
# earlier versions have .gif.
|
# earlier versions have .gif.
|
||||||
self.failUnless(portrait_url in
|
self.assertTrue(portrait_url in
|
||||||
('http://nohost/plone/defaultUser.png',
|
('http://nohost/plone/defaultUser.png',
|
||||||
'http://nohost/plone/defaultUser.gif'))
|
'http://nohost/plone/defaultUser.gif'))
|
||||||
|
|
||||||
def test_anonymous_discussion_allowed(self):
|
def test_anonymous_discussion_allowed(self):
|
||||||
# Anonymous discussion is not allowed by default
|
# Anonymous discussion is not allowed by default
|
||||||
self.failIf(self.viewlet.anonymous_discussion_allowed())
|
self.assertFalse(self.viewlet.anonymous_discussion_allowed())
|
||||||
# Allow anonymous discussion
|
# Allow anonymous discussion
|
||||||
registry = queryUtility(IRegistry)
|
registry = queryUtility(IRegistry)
|
||||||
registry['plone.app.discussion.interfaces.IDiscussionSettings.' +
|
registry['plone.app.discussion.interfaces.IDiscussionSettings.' +
|
||||||
'anonymous_comments'] = True
|
'anonymous_comments'] = True
|
||||||
# Test if anonymous discussion is allowed for the viewlet
|
# Test if anonymous discussion is allowed for the viewlet
|
||||||
self.failUnless(self.viewlet.anonymous_discussion_allowed())
|
self.assertTrue(self.viewlet.anonymous_discussion_allowed())
|
||||||
|
|
||||||
def test_show_commenter_image(self):
|
def test_show_commenter_image(self):
|
||||||
self.failUnless(self.viewlet.show_commenter_image())
|
self.assertTrue(self.viewlet.show_commenter_image())
|
||||||
registry = queryUtility(IRegistry)
|
registry = queryUtility(IRegistry)
|
||||||
registry['plone.app.discussion.interfaces.IDiscussionSettings.' +
|
registry['plone.app.discussion.interfaces.IDiscussionSettings.' +
|
||||||
'show_commenter_image'] = False
|
'show_commenter_image'] = False
|
||||||
self.failIf(self.viewlet.show_commenter_image())
|
self.assertFalse(self.viewlet.show_commenter_image())
|
||||||
|
|
||||||
def test_is_anonymous(self):
|
def test_is_anonymous(self):
|
||||||
self.failIf(self.viewlet.is_anonymous())
|
self.assertFalse(self.viewlet.is_anonymous())
|
||||||
self.logout()
|
self.logout()
|
||||||
self.failUnless(self.viewlet.is_anonymous())
|
self.assertTrue(self.viewlet.is_anonymous())
|
||||||
|
|
||||||
def test_login_action(self):
|
def test_login_action(self):
|
||||||
self.viewlet.update()
|
self.viewlet.update()
|
||||||
self.assertEquals(self.viewlet.login_action(),
|
self.assertEqual(self.viewlet.login_action(),
|
||||||
'http://nohost/plone/login_form?came_from=http%3A//nohost')
|
'http://nohost/plone/login_form?came_from=http%3A//nohost')
|
||||||
|
|
||||||
def test_format_time(self):
|
def test_format_time(self):
|
||||||
@ -464,7 +464,7 @@ class TestCommentsViewlet(PloneTestCase):
|
|||||||
python_time = datetime(
|
python_time = datetime(
|
||||||
*time.gmtime(time.mktime(python_time.timetuple()))[:7])
|
*time.gmtime(time.mktime(python_time.timetuple()))[:7])
|
||||||
localized_time = self.viewlet.format_time(python_time)
|
localized_time = self.viewlet.format_time(python_time)
|
||||||
self.assertEquals(localized_time, "Feb 01, 2009 11:32 PM")
|
self.assertEqual(localized_time, "Feb 01, 2009 11:32 PM")
|
||||||
|
|
||||||
|
|
||||||
def test_suite():
|
def test_suite():
|
||||||
|
@ -26,67 +26,67 @@ class RegistryTest(PloneTestCase):
|
|||||||
|
|
||||||
def test_registry_registered(self):
|
def test_registry_registered(self):
|
||||||
registry = queryUtility(IRegistry)
|
registry = queryUtility(IRegistry)
|
||||||
self.failUnless(registry.forInterface(IDiscussionSettings))
|
self.assertTrue(registry.forInterface(IDiscussionSettings))
|
||||||
|
|
||||||
def test_discussion_controlpanel_view(self):
|
def test_discussion_controlpanel_view(self):
|
||||||
view = getMultiAdapter((self.portal, self.portal.REQUEST),
|
view = getMultiAdapter((self.portal, self.portal.REQUEST),
|
||||||
name="discussion-settings")
|
name="discussion-settings")
|
||||||
view = view.__of__(self.portal)
|
view = view.__of__(self.portal)
|
||||||
self.failUnless(view())
|
self.assertTrue(view())
|
||||||
|
|
||||||
def test_discussion_in_controlpanel(self):
|
def test_discussion_in_controlpanel(self):
|
||||||
# Check if discussion is in the control panel
|
# Check if discussion is in the control panel
|
||||||
self.controlpanel = getToolByName(self.portal, "portal_controlpanel")
|
self.controlpanel = getToolByName(self.portal, "portal_controlpanel")
|
||||||
self.failUnless('discussion' in [a.getAction(self)['id']
|
self.assertTrue('discussion' in [a.getAction(self)['id']
|
||||||
for a in self.controlpanel.listActions()])
|
for a in self.controlpanel.listActions()])
|
||||||
|
|
||||||
def test_globally_enabled(self):
|
def test_globally_enabled(self):
|
||||||
# Check globally_enabled record
|
# Check globally_enabled record
|
||||||
self.failUnless('globally_enabled' in IDiscussionSettings)
|
self.assertTrue('globally_enabled' in IDiscussionSettings)
|
||||||
self.assertEquals(
|
self.assertEqual(
|
||||||
self.registry['plone.app.discussion.interfaces.' +
|
self.registry['plone.app.discussion.interfaces.' +
|
||||||
'IDiscussionSettings.globally_enabled'],
|
'IDiscussionSettings.globally_enabled'],
|
||||||
False)
|
False)
|
||||||
|
|
||||||
def test_anonymous_comments(self):
|
def test_anonymous_comments(self):
|
||||||
# Check anonymous_comments record
|
# Check anonymous_comments record
|
||||||
self.failUnless('anonymous_comments' in IDiscussionSettings)
|
self.assertTrue('anonymous_comments' in IDiscussionSettings)
|
||||||
self.assertEquals(self.registry['plone.app.discussion.interfaces.' +
|
self.assertEqual(self.registry['plone.app.discussion.interfaces.' +
|
||||||
'IDiscussionSettings.anonymous_comments'], False)
|
'IDiscussionSettings.anonymous_comments'], False)
|
||||||
|
|
||||||
def test_moderation_enabled(self):
|
def test_moderation_enabled(self):
|
||||||
# Check globally_enabled record
|
# Check globally_enabled record
|
||||||
self.failUnless('moderation_enabled' in IDiscussionSettings)
|
self.assertTrue('moderation_enabled' in IDiscussionSettings)
|
||||||
self.assertEquals(
|
self.assertEqual(
|
||||||
self.registry['plone.app.discussion.interfaces.' +
|
self.registry['plone.app.discussion.interfaces.' +
|
||||||
'IDiscussionSettings.moderation_enabled'],
|
'IDiscussionSettings.moderation_enabled'],
|
||||||
False)
|
False)
|
||||||
|
|
||||||
def test_text_transform(self):
|
def test_text_transform(self):
|
||||||
self.failUnless('text_transform' in IDiscussionSettings)
|
self.assertTrue('text_transform' in IDiscussionSettings)
|
||||||
self.assertEquals(
|
self.assertEqual(
|
||||||
self.registry['plone.app.discussion.interfaces.' +
|
self.registry['plone.app.discussion.interfaces.' +
|
||||||
'IDiscussionSettings.text_transform'],
|
'IDiscussionSettings.text_transform'],
|
||||||
'text/plain')
|
'text/plain')
|
||||||
|
|
||||||
def test_captcha(self):
|
def test_captcha(self):
|
||||||
# Check globally_enabled record
|
# Check globally_enabled record
|
||||||
self.failUnless('captcha' in IDiscussionSettings)
|
self.assertTrue('captcha' in IDiscussionSettings)
|
||||||
self.assertEquals(self.registry['plone.app.discussion.interfaces.' +
|
self.assertEqual(self.registry['plone.app.discussion.interfaces.' +
|
||||||
'IDiscussionSettings.captcha'],
|
'IDiscussionSettings.captcha'],
|
||||||
'disabled')
|
'disabled')
|
||||||
|
|
||||||
def test_show_commenter_image(self):
|
def test_show_commenter_image(self):
|
||||||
# Check show_commenter_image record
|
# Check show_commenter_image record
|
||||||
self.failUnless('show_commenter_image' in IDiscussionSettings)
|
self.assertTrue('show_commenter_image' in IDiscussionSettings)
|
||||||
self.assertEquals(self.registry['plone.app.discussion.interfaces.' +
|
self.assertEqual(self.registry['plone.app.discussion.interfaces.' +
|
||||||
'IDiscussionSettings.show_commenter_image'], True)
|
'IDiscussionSettings.show_commenter_image'], True)
|
||||||
|
|
||||||
def test_moderator_notification_enabled(self):
|
def test_moderator_notification_enabled(self):
|
||||||
# Check show_commenter_image record
|
# Check show_commenter_image record
|
||||||
self.failUnless('moderator_notification_enabled' in
|
self.assertTrue('moderator_notification_enabled' in
|
||||||
IDiscussionSettings)
|
IDiscussionSettings)
|
||||||
self.assertEquals(self.registry['plone.app.discussion.interfaces.' +
|
self.assertEqual(self.registry['plone.app.discussion.interfaces.' +
|
||||||
'IDiscussionSettings.moderator_notification_enabled'], False)
|
'IDiscussionSettings.moderator_notification_enabled'], False)
|
||||||
|
|
||||||
#def test_user_notification_enabled(self):
|
#def test_user_notification_enabled(self):
|
||||||
@ -94,8 +94,8 @@ class RegistryTest(PloneTestCase):
|
|||||||
# show_commenter_image = self.registry.records['plone.app.discussion.' +
|
# show_commenter_image = self.registry.records['plone.app.discussion.' +
|
||||||
# 'interfaces.IDiscussionSettings.user_notification_enabled']
|
# 'interfaces.IDiscussionSettings.user_notification_enabled']
|
||||||
#
|
#
|
||||||
# self.failUnless('user_notification_enabled' in IDiscussionSettings)
|
# self.assertTrue('user_notification_enabled' in IDiscussionSettings)
|
||||||
# self.assertEquals(self.registry['plone.app.discussion.interfaces.' +
|
# self.assertEqual(self.registry['plone.app.discussion.interfaces.' +
|
||||||
# 'IDiscussionSettings.user_notification_enabled'], False)
|
# 'IDiscussionSettings.user_notification_enabled'], False)
|
||||||
|
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ class ConfigurationChangedSubscriberTest(PloneTestCase):
|
|||||||
changes.
|
changes.
|
||||||
"""
|
"""
|
||||||
# By default the one_state_workflow without moderation is enabled
|
# By default the one_state_workflow without moderation is enabled
|
||||||
self.assertEquals(('one_state_workflow',),
|
self.assertEqual(('one_state_workflow',),
|
||||||
self.portal.portal_workflow.getChainForPortalType(
|
self.portal.portal_workflow.getChainForPortalType(
|
||||||
'Discussion Item'))
|
'Discussion Item'))
|
||||||
|
|
||||||
@ -124,12 +124,12 @@ class ConfigurationChangedSubscriberTest(PloneTestCase):
|
|||||||
|
|
||||||
# Make sure the comment_review_workflow with moderation enabled is
|
# Make sure the comment_review_workflow with moderation enabled is
|
||||||
# enabled
|
# enabled
|
||||||
self.assertEquals(('comment_review_workflow',),
|
self.assertEqual(('comment_review_workflow',),
|
||||||
self.portal.portal_workflow.getChainForPortalType(
|
self.portal.portal_workflow.getChainForPortalType(
|
||||||
'Discussion Item'))
|
'Discussion Item'))
|
||||||
# And back
|
# And back
|
||||||
self.settings.moderation_enabled = False
|
self.settings.moderation_enabled = False
|
||||||
self.assertEquals(('one_state_workflow',),
|
self.assertEqual(('one_state_workflow',),
|
||||||
self.portal.portal_workflow.getChainForPortalType(
|
self.portal.portal_workflow.getChainForPortalType(
|
||||||
'Discussion Item'))
|
'Discussion Item'))
|
||||||
|
|
||||||
|
@ -57,15 +57,15 @@ class ConversationTest(PloneTestCase):
|
|||||||
new_id = conversation.addComment(comment)
|
new_id = conversation.addComment(comment)
|
||||||
|
|
||||||
# Check that the conversation methods return the correct data
|
# Check that the conversation methods return the correct data
|
||||||
self.assert_(isinstance(comment.comment_id, long))
|
self.assertTrue(isinstance(comment.comment_id, long))
|
||||||
self.assert_(IComment.providedBy(conversation[new_id]))
|
self.assertTrue(IComment.providedBy(conversation[new_id]))
|
||||||
self.assertEquals(aq_base(conversation[new_id].__parent__),
|
self.assertEqual(aq_base(conversation[new_id].__parent__),
|
||||||
aq_base(conversation))
|
aq_base(conversation))
|
||||||
self.assertEquals(new_id, comment.comment_id)
|
self.assertEqual(new_id, comment.comment_id)
|
||||||
self.assertEquals(len(list(conversation.getComments())), 1)
|
self.assertEqual(len(list(conversation.getComments())), 1)
|
||||||
self.assertEquals(len(tuple(conversation.getThreads())), 1)
|
self.assertEqual(len(tuple(conversation.getThreads())), 1)
|
||||||
self.assertEquals(conversation.total_comments, 1)
|
self.assertEqual(conversation.total_comments, 1)
|
||||||
self.assert_(conversation.last_comment_date - datetime.utcnow() <
|
self.assertTrue(conversation.last_comment_date - datetime.utcnow() <
|
||||||
timedelta(seconds=1))
|
timedelta(seconds=1))
|
||||||
|
|
||||||
def test_delete_comment(self):
|
def test_delete_comment(self):
|
||||||
@ -82,17 +82,17 @@ class ConversationTest(PloneTestCase):
|
|||||||
new_id = conversation.addComment(comment)
|
new_id = conversation.addComment(comment)
|
||||||
|
|
||||||
# make sure the comment has been added
|
# make sure the comment has been added
|
||||||
self.assertEquals(len(list(conversation.getComments())), 1)
|
self.assertEqual(len(list(conversation.getComments())), 1)
|
||||||
self.assertEquals(len(tuple(conversation.getThreads())), 1)
|
self.assertEqual(len(tuple(conversation.getThreads())), 1)
|
||||||
self.assertEquals(conversation.total_comments, 1)
|
self.assertEqual(conversation.total_comments, 1)
|
||||||
|
|
||||||
# delete the comment we just created
|
# delete the comment we just created
|
||||||
del conversation[new_id]
|
del conversation[new_id]
|
||||||
|
|
||||||
# make sure there is no comment left in the conversation
|
# make sure there is no comment left in the conversation
|
||||||
self.assertEquals(len(list(conversation.getComments())), 0)
|
self.assertEqual(len(list(conversation.getComments())), 0)
|
||||||
self.assertEquals(len(tuple(conversation.getThreads())), 0)
|
self.assertEqual(len(tuple(conversation.getThreads())), 0)
|
||||||
self.assertEquals(conversation.total_comments, 0)
|
self.assertEqual(conversation.total_comments, 0)
|
||||||
|
|
||||||
def test_delete_recursive(self):
|
def test_delete_recursive(self):
|
||||||
# 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
|
||||||
@ -148,7 +148,7 @@ class ConversationTest(PloneTestCase):
|
|||||||
|
|
||||||
del conversation[new_id_1]
|
del conversation[new_id_1]
|
||||||
|
|
||||||
self.assertEquals(
|
self.assertEqual(
|
||||||
[{'comment': comment2, 'depth': 0, 'id': new_id_2},
|
[{'comment': comment2, 'depth': 0, 'id': new_id_2},
|
||||||
{'comment': comment2_1, 'depth': 1, 'id': new_id_2_1},
|
{'comment': comment2_1, 'depth': 1, 'id': new_id_2_1},
|
||||||
], list(conversation.getThreads()))
|
], list(conversation.getThreads()))
|
||||||
@ -165,9 +165,9 @@ class ConversationTest(PloneTestCase):
|
|||||||
self.portal.manage_delObjects(['doc1'])
|
self.portal.manage_delObjects(['doc1'])
|
||||||
|
|
||||||
# Make sure the comment has been deleted as well
|
# Make sure the comment has been deleted as well
|
||||||
self.assertEquals(len(list(conversation.getComments())), 0)
|
self.assertEqual(len(list(conversation.getComments())), 0)
|
||||||
self.assertEquals(len(tuple(conversation.getThreads())), 0)
|
self.assertEqual(len(tuple(conversation.getThreads())), 0)
|
||||||
self.assertEquals(conversation.total_comments, 0)
|
self.assertEqual(conversation.total_comments, 0)
|
||||||
|
|
||||||
def test_allow_discussion(self):
|
def test_allow_discussion(self):
|
||||||
# This is not a real test! It's only there to understand the
|
# This is not a real test! It's only there to understand the
|
||||||
@ -187,52 +187,52 @@ class ConversationTest(PloneTestCase):
|
|||||||
type_fti = getattr(portal_types, type)
|
type_fti = getattr(portal_types, type)
|
||||||
if type not in BAD_TYPES:
|
if type not in BAD_TYPES:
|
||||||
if type != 'Discussion Item':
|
if type != 'Discussion Item':
|
||||||
self.failIf(type_fti.allowDiscussion())
|
self.assertFalse(type_fti.allowDiscussion())
|
||||||
|
|
||||||
# By default, allow_discussion on newly created content objects is
|
# By default, allow_discussion on newly created content objects is
|
||||||
# set to False
|
# set to False
|
||||||
portal_discussion = getToolByName(self.portal, 'portal_discussion')
|
portal_discussion = getToolByName(self.portal, 'portal_discussion')
|
||||||
self.assertEquals(portal_discussion.isDiscussionAllowedFor(
|
self.assertEqual(portal_discussion.isDiscussionAllowedFor(
|
||||||
self.portal.doc1), False)
|
self.portal.doc1), False)
|
||||||
self.assertEquals(self.portal.doc1.getTypeInfo().allowDiscussion(),
|
self.assertEqual(self.portal.doc1.getTypeInfo().allowDiscussion(),
|
||||||
False)
|
False)
|
||||||
|
|
||||||
# The allow discussion flag is None by default
|
# The allow discussion flag is None by default
|
||||||
self.failIf(getattr(self.portal.doc1, 'allow_discussion', None))
|
self.assertFalse(getattr(self.portal.doc1, 'allow_discussion', None))
|
||||||
|
|
||||||
# But isDiscussionAllowedFor, also checks if discussion is allowed on
|
# But isDiscussionAllowedFor, also checks if discussion is allowed on
|
||||||
# the content type. So we allow discussion on the Document content
|
# the content type. So we allow discussion on the Document content
|
||||||
# type and check if the Document object allows discussion now.
|
# type and check if the Document object allows discussion now.
|
||||||
document_fti = getattr(portal_types, 'Document')
|
document_fti = getattr(portal_types, 'Document')
|
||||||
document_fti.manage_changeProperties(allow_discussion = True)
|
document_fti.manage_changeProperties(allow_discussion = True)
|
||||||
self.assertEquals(portal_discussion.isDiscussionAllowedFor(
|
self.assertEqual(portal_discussion.isDiscussionAllowedFor(
|
||||||
self.portal.doc1), True)
|
self.portal.doc1), True)
|
||||||
self.assertEquals(self.portal.doc1.getTypeInfo().allowDiscussion(),
|
self.assertEqual(self.portal.doc1.getTypeInfo().allowDiscussion(),
|
||||||
True)
|
True)
|
||||||
|
|
||||||
# We can also override the allow_discussion locally
|
# We can also override the allow_discussion locally
|
||||||
self.portal_discussion.overrideDiscussionFor(self.portal.doc1, False)
|
self.portal_discussion.overrideDiscussionFor(self.portal.doc1, False)
|
||||||
# Check if the Document discussion is disabled
|
# Check if the Document discussion is disabled
|
||||||
self.assertEquals(portal_discussion.isDiscussionAllowedFor(
|
self.assertEqual(portal_discussion.isDiscussionAllowedFor(
|
||||||
self.portal.doc1), False)
|
self.portal.doc1), False)
|
||||||
# Check that the local allow_discussion flag is now explicitly set to
|
# Check that the local allow_discussion flag is now explicitly set to
|
||||||
# False
|
# False
|
||||||
self.assertEquals(getattr(self.portal.doc1, 'allow_discussion', None),
|
self.assertEqual(getattr(self.portal.doc1, 'allow_discussion', None),
|
||||||
False)
|
False)
|
||||||
|
|
||||||
# Disallow discussion on the Document content type again
|
# Disallow discussion on the Document content type again
|
||||||
document_fti.manage_changeProperties(allow_discussion = False)
|
document_fti.manage_changeProperties(allow_discussion = False)
|
||||||
self.assertEquals(portal_discussion.isDiscussionAllowedFor(
|
self.assertEqual(portal_discussion.isDiscussionAllowedFor(
|
||||||
self.portal.doc1), False)
|
self.portal.doc1), False)
|
||||||
self.assertEquals(self.portal.doc1.getTypeInfo().allowDiscussion(),
|
self.assertEqual(self.portal.doc1.getTypeInfo().allowDiscussion(),
|
||||||
False)
|
False)
|
||||||
|
|
||||||
# Now we override allow_discussion again (True) for the Document
|
# Now we override allow_discussion again (True) for the Document
|
||||||
# content object
|
# content object
|
||||||
self.portal_discussion.overrideDiscussionFor(self.portal.doc1, True)
|
self.portal_discussion.overrideDiscussionFor(self.portal.doc1, True)
|
||||||
self.assertEquals(portal_discussion.isDiscussionAllowedFor(
|
self.assertEqual(portal_discussion.isDiscussionAllowedFor(
|
||||||
self.portal.doc1), True)
|
self.portal.doc1), True)
|
||||||
self.assertEquals(getattr(self.portal.doc1, 'allow_discussion', None),
|
self.assertEqual(getattr(self.portal.doc1, 'allow_discussion', None),
|
||||||
True)
|
True)
|
||||||
|
|
||||||
def test_comments_enabled_on_doc_in_subfolder(self):
|
def test_comments_enabled_on_doc_in_subfolder(self):
|
||||||
@ -250,7 +250,7 @@ class ConversationTest(PloneTestCase):
|
|||||||
|
|
||||||
doc = self.portal.folder1.doc2
|
doc = self.portal.folder1.doc2
|
||||||
conversation = doc.restrictedTraverse('@@conversation_view')
|
conversation = doc.restrictedTraverse('@@conversation_view')
|
||||||
self.assertEquals(conversation.enabled(), False)
|
self.assertEqual(conversation.enabled(), False)
|
||||||
|
|
||||||
# We have to allow discussion on Document content type, since
|
# We have to allow discussion on Document content type, since
|
||||||
# otherwise allow_discussion will always return False
|
# otherwise allow_discussion will always return False
|
||||||
@ -258,7 +258,7 @@ class ConversationTest(PloneTestCase):
|
|||||||
document_fti = getattr(portal_types, 'Document')
|
document_fti = getattr(portal_types, 'Document')
|
||||||
document_fti.manage_changeProperties(allow_discussion = True)
|
document_fti.manage_changeProperties(allow_discussion = True)
|
||||||
|
|
||||||
self.assertEquals(conversation.enabled(), True)
|
self.assertEqual(conversation.enabled(), True)
|
||||||
|
|
||||||
def test_disable_commenting_globally(self):
|
def test_disable_commenting_globally(self):
|
||||||
|
|
||||||
@ -273,7 +273,7 @@ class ConversationTest(PloneTestCase):
|
|||||||
document_fti.manage_changeProperties(allow_discussion = True)
|
document_fti.manage_changeProperties(allow_discussion = True)
|
||||||
|
|
||||||
# Check if conversation is enabled now
|
# Check if conversation is enabled now
|
||||||
self.assertEquals(conversation.enabled(), True)
|
self.assertEqual(conversation.enabled(), True)
|
||||||
|
|
||||||
# Disable commenting in the registry
|
# Disable commenting in the registry
|
||||||
registry = queryUtility(IRegistry)
|
registry = queryUtility(IRegistry)
|
||||||
@ -281,11 +281,11 @@ class ConversationTest(PloneTestCase):
|
|||||||
settings.globally_enabled = False
|
settings.globally_enabled = False
|
||||||
|
|
||||||
# Check if commenting is disabled on the conversation
|
# Check if commenting is disabled on the conversation
|
||||||
self.assertEquals(conversation.enabled(), False)
|
self.assertEqual(conversation.enabled(), False)
|
||||||
|
|
||||||
# Enable discussion again
|
# Enable discussion again
|
||||||
settings.globally_enabled = True
|
settings.globally_enabled = True
|
||||||
self.assertEquals(conversation.enabled(), True)
|
self.assertEqual(conversation.enabled(), True)
|
||||||
|
|
||||||
|
|
||||||
def test_allow_discussion_for_news_items(self):
|
def test_allow_discussion_for_news_items(self):
|
||||||
@ -301,7 +301,7 @@ class ConversationTest(PloneTestCase):
|
|||||||
document_fti.manage_changeProperties(allow_discussion = True)
|
document_fti.manage_changeProperties(allow_discussion = True)
|
||||||
|
|
||||||
# Check if conversation is enabled now
|
# Check if conversation is enabled now
|
||||||
self.assertEquals(conversation.enabled(), True)
|
self.assertEqual(conversation.enabled(), True)
|
||||||
|
|
||||||
# Disable commenting in the registry
|
# Disable commenting in the registry
|
||||||
registry = queryUtility(IRegistry)
|
registry = queryUtility(IRegistry)
|
||||||
@ -309,11 +309,11 @@ class ConversationTest(PloneTestCase):
|
|||||||
settings.globally_enabled = False
|
settings.globally_enabled = False
|
||||||
|
|
||||||
# Check if commenting is disabled on the conversation
|
# Check if commenting is disabled on the conversation
|
||||||
self.assertEquals(conversation.enabled(), False)
|
self.assertEqual(conversation.enabled(), False)
|
||||||
|
|
||||||
# Enable discussion again
|
# Enable discussion again
|
||||||
settings.globally_enabled = True
|
settings.globally_enabled = True
|
||||||
self.assertEquals(conversation.enabled(), True)
|
self.assertEqual(conversation.enabled(), True)
|
||||||
|
|
||||||
def test_disable_commenting_for_content_type(self):
|
def test_disable_commenting_for_content_type(self):
|
||||||
|
|
||||||
@ -322,7 +322,7 @@ class ConversationTest(PloneTestCase):
|
|||||||
'@@conversation_view')
|
'@@conversation_view')
|
||||||
|
|
||||||
# The Document content type is disabled by default
|
# The Document content type is disabled by default
|
||||||
self.assertEquals(conversation.enabled(), False)
|
self.assertEqual(conversation.enabled(), False)
|
||||||
|
|
||||||
# Allow discussion on Document content type
|
# Allow discussion on Document content type
|
||||||
portal_types = getToolByName(self.portal, 'portal_types')
|
portal_types = getToolByName(self.portal, 'portal_types')
|
||||||
@ -330,7 +330,7 @@ class ConversationTest(PloneTestCase):
|
|||||||
document_fti.manage_changeProperties(allow_discussion = True)
|
document_fti.manage_changeProperties(allow_discussion = True)
|
||||||
|
|
||||||
# Check if conversation is enabled now
|
# Check if conversation is enabled now
|
||||||
self.assertEquals(conversation.enabled(), True)
|
self.assertEqual(conversation.enabled(), True)
|
||||||
|
|
||||||
# Disallow discussion on Document content type
|
# Disallow discussion on Document content type
|
||||||
portal_types = getToolByName(self.portal, 'portal_types')
|
portal_types = getToolByName(self.portal, 'portal_types')
|
||||||
@ -338,7 +338,7 @@ class ConversationTest(PloneTestCase):
|
|||||||
document_fti.manage_changeProperties(allow_discussion = False)
|
document_fti.manage_changeProperties(allow_discussion = False)
|
||||||
|
|
||||||
# Check if conversation is enabled now
|
# Check if conversation is enabled now
|
||||||
self.assertEquals(conversation.enabled(), False)
|
self.assertEqual(conversation.enabled(), False)
|
||||||
|
|
||||||
def test_allow_discussion_on_folder(self):
|
def test_allow_discussion_on_folder(self):
|
||||||
# The enabled method should always return False for the folder
|
# The enabled method should always return False for the folder
|
||||||
@ -359,7 +359,7 @@ class ConversationTest(PloneTestCase):
|
|||||||
document_fti.manage_changeProperties(allow_discussion = True)
|
document_fti.manage_changeProperties(allow_discussion = True)
|
||||||
|
|
||||||
# Always return False
|
# Always return False
|
||||||
self.failIf(conversation.enabled())
|
self.assertFalse(conversation.enabled())
|
||||||
|
|
||||||
def test_is_discussion_allowed_for_folder(self):
|
def test_is_discussion_allowed_for_folder(self):
|
||||||
# When a content item provides IFolderish from CMF and
|
# When a content item provides IFolderish from CMF and
|
||||||
@ -378,19 +378,19 @@ class ConversationTest(PloneTestCase):
|
|||||||
doc1 = self.portal.f1.doc1
|
doc1 = self.portal.f1.doc1
|
||||||
doc1_conversation = doc1.restrictedTraverse('@@conversation_view')
|
doc1_conversation = doc1.restrictedTraverse('@@conversation_view')
|
||||||
|
|
||||||
self.assertEquals(doc1_conversation.enabled(), False)
|
self.assertEqual(doc1_conversation.enabled(), False)
|
||||||
|
|
||||||
# Allow commenting for the folder
|
# Allow commenting for the folder
|
||||||
self.portal_discussion.overrideDiscussionFor(f1, True)
|
self.portal_discussion.overrideDiscussionFor(f1, True)
|
||||||
|
|
||||||
# Check if the content objects allows discussion
|
# Check if the content objects allows discussion
|
||||||
self.assertEquals(doc1_conversation.enabled(), True)
|
self.assertEqual(doc1_conversation.enabled(), True)
|
||||||
|
|
||||||
# Turn commenting for the folder off
|
# Turn commenting for the folder off
|
||||||
self.portal_discussion.overrideDiscussionFor(f1, False)
|
self.portal_discussion.overrideDiscussionFor(f1, False)
|
||||||
|
|
||||||
# Check if content objects do not allow discussion anymore
|
# Check if content objects do not allow discussion anymore
|
||||||
self.assertEquals(doc1_conversation.enabled(), False)
|
self.assertEqual(doc1_conversation.enabled(), False)
|
||||||
|
|
||||||
def test_is_discussion_allowed_on_content_object(self):
|
def test_is_discussion_allowed_on_content_object(self):
|
||||||
# Allow discussion on a single content object
|
# Allow discussion on a single content object
|
||||||
@ -400,16 +400,16 @@ class ConversationTest(PloneTestCase):
|
|||||||
'@@conversation_view')
|
'@@conversation_view')
|
||||||
|
|
||||||
# Discussion is disallowed by default
|
# Discussion is disallowed by default
|
||||||
self.assertEquals(conversation.enabled(), False)
|
self.assertEqual(conversation.enabled(), False)
|
||||||
|
|
||||||
# Allow discussion on content object
|
# Allow discussion on content object
|
||||||
self.portal_discussion.overrideDiscussionFor(self.portal.doc1, True)
|
self.portal_discussion.overrideDiscussionFor(self.portal.doc1, True)
|
||||||
|
|
||||||
# Check if discussion is now allowed on the content object
|
# Check if discussion is now allowed on the content object
|
||||||
self.assertEquals(conversation.enabled(), True)
|
self.assertEqual(conversation.enabled(), True)
|
||||||
|
|
||||||
self.portal_discussion.overrideDiscussionFor(self.portal.doc1, False)
|
self.portal_discussion.overrideDiscussionFor(self.portal.doc1, False)
|
||||||
self.assertEquals(conversation.enabled(), False)
|
self.assertEqual(conversation.enabled(), False)
|
||||||
|
|
||||||
def test_dict_operations(self):
|
def test_dict_operations(self):
|
||||||
# test dict operations and acquisition wrapping
|
# test dict operations and acquisition wrapping
|
||||||
@ -433,41 +433,41 @@ class ConversationTest(PloneTestCase):
|
|||||||
|
|
||||||
# check if get returns a comment object, and None if the key
|
# check if get returns a comment object, and None if the key
|
||||||
# can not be found
|
# can not be found
|
||||||
self.failUnless(IComment.providedBy(conversation.get(new_id1)))
|
self.assertTrue(IComment.providedBy(conversation.get(new_id1)))
|
||||||
self.failUnless(IComment.providedBy(conversation.get(new_id2)))
|
self.assertTrue(IComment.providedBy(conversation.get(new_id2)))
|
||||||
self.assertEquals(conversation.get(123), None)
|
self.assertEqual(conversation.get(123), None)
|
||||||
|
|
||||||
# check if keys return the ids of all comments
|
# check if keys return the ids of all comments
|
||||||
self.assertEquals(len(conversation.keys()), 2)
|
self.assertEqual(len(conversation.keys()), 2)
|
||||||
self.failUnless(new_id1 in conversation.keys())
|
self.assertTrue(new_id1 in conversation.keys())
|
||||||
self.failUnless(new_id2 in conversation.keys())
|
self.assertTrue(new_id2 in conversation.keys())
|
||||||
self.failIf(123 in conversation.keys())
|
self.assertFalse(123 in conversation.keys())
|
||||||
|
|
||||||
# check if items returns (key, comment object) pairs
|
# check if items returns (key, comment object) pairs
|
||||||
self.assertEquals(len(conversation.items()), 2)
|
self.assertEqual(len(conversation.items()), 2)
|
||||||
self.failUnless((new_id1, comment1) in conversation.items())
|
self.assertTrue((new_id1, comment1) in conversation.items())
|
||||||
self.failUnless((new_id2, comment2) in conversation.items())
|
self.assertTrue((new_id2, comment2) in conversation.items())
|
||||||
|
|
||||||
# check if values returns the two comment objects
|
# check if values returns the two comment objects
|
||||||
self.assertEquals(len(conversation.values()), 2)
|
self.assertEqual(len(conversation.values()), 2)
|
||||||
self.failUnless(comment1 in conversation.values())
|
self.assertTrue(comment1 in conversation.values())
|
||||||
self.failUnless(comment2 in conversation.values())
|
self.assertTrue(comment2 in conversation.values())
|
||||||
|
|
||||||
# check if comment ids are in iterkeys
|
# check if comment ids are in iterkeys
|
||||||
self.failUnless(new_id1 in conversation.iterkeys())
|
self.assertTrue(new_id1 in conversation.iterkeys())
|
||||||
self.failUnless(new_id2 in conversation.iterkeys())
|
self.assertTrue(new_id2 in conversation.iterkeys())
|
||||||
self.failIf(123 in conversation.iterkeys())
|
self.assertFalse(123 in conversation.iterkeys())
|
||||||
|
|
||||||
# check if comment objects are in itervalues
|
# check if comment objects are in itervalues
|
||||||
self.failUnless(comment1 in conversation.itervalues())
|
self.assertTrue(comment1 in conversation.itervalues())
|
||||||
self.failUnless(comment2 in conversation.itervalues())
|
self.assertTrue(comment2 in conversation.itervalues())
|
||||||
|
|
||||||
# check if iteritems returns (key, comment object) pairs
|
# check if iteritems returns (key, comment object) pairs
|
||||||
self.failUnless((new_id1, comment1) in conversation.iteritems())
|
self.assertTrue((new_id1, comment1) in conversation.iteritems())
|
||||||
self.failUnless((new_id2, comment2) in conversation.iteritems())
|
self.assertTrue((new_id2, comment2) in conversation.iteritems())
|
||||||
|
|
||||||
# TODO test acquisition wrapping
|
# TODO test acquisition wrapping
|
||||||
#self.failUnless(aq_base(aq_parent(comment1)) is conversation)
|
#self.assertTrue(aq_base(aq_parent(comment1)) is conversation)
|
||||||
|
|
||||||
def test_total_comments(self):
|
def test_total_comments(self):
|
||||||
# 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
|
||||||
@ -491,7 +491,7 @@ class ConversationTest(PloneTestCase):
|
|||||||
conversation.addComment(comment2)
|
conversation.addComment(comment2)
|
||||||
conversation.addComment(comment3)
|
conversation.addComment(comment3)
|
||||||
|
|
||||||
self.assertEquals(conversation.total_comments, 3)
|
self.assertEqual(conversation.total_comments, 3)
|
||||||
|
|
||||||
def test_commentators(self):
|
def test_commentators(self):
|
||||||
# add and remove a few comments to make sure the commentators
|
# add and remove a few comments to make sure the commentators
|
||||||
@ -501,7 +501,7 @@ class ConversationTest(PloneTestCase):
|
|||||||
# object, as we just want to check the Conversation object API.
|
# object, as we just want to check the Conversation object API.
|
||||||
conversation = IConversation(self.portal.doc1)
|
conversation = IConversation(self.portal.doc1)
|
||||||
|
|
||||||
self.assertEquals(conversation.total_comments, 0)
|
self.assertEqual(conversation.total_comments, 0)
|
||||||
|
|
||||||
# Add a four comments from three different users
|
# Add a four comments from three different users
|
||||||
# Note: in real life, we always create
|
# Note: in real life, we always create
|
||||||
@ -528,29 +528,29 @@ class ConversationTest(PloneTestCase):
|
|||||||
new_comment4_id = conversation.addComment(comment4)
|
new_comment4_id = conversation.addComment(comment4)
|
||||||
|
|
||||||
# check if all commentators are in the commentators list
|
# check if all commentators are in the commentators list
|
||||||
self.assertEquals(conversation.total_comments, 4)
|
self.assertEqual(conversation.total_comments, 4)
|
||||||
self.failUnless('Jim' in conversation.commentators)
|
self.assertTrue('Jim' in conversation.commentators)
|
||||||
self.failUnless('Joe' in conversation.commentators)
|
self.assertTrue('Joe' in conversation.commentators)
|
||||||
self.failUnless('Jack' in conversation.commentators)
|
self.assertTrue('Jack' in conversation.commentators)
|
||||||
|
|
||||||
# remove the comment from Jack
|
# remove the comment from Jack
|
||||||
del conversation[new_comment3_id]
|
del conversation[new_comment3_id]
|
||||||
|
|
||||||
# check if Jack is still in the commentators list (since
|
# check if Jack is still in the commentators list (since
|
||||||
# he had added two comments)
|
# he had added two comments)
|
||||||
self.failUnless('Jim' in conversation.commentators)
|
self.assertTrue('Jim' in conversation.commentators)
|
||||||
self.failUnless('Joe' in conversation.commentators)
|
self.assertTrue('Joe' in conversation.commentators)
|
||||||
self.failUnless('Jack' in conversation.commentators)
|
self.assertTrue('Jack' in conversation.commentators)
|
||||||
self.assertEquals(conversation.total_comments, 3)
|
self.assertEqual(conversation.total_comments, 3)
|
||||||
|
|
||||||
# remove the second comment from Jack
|
# remove the second comment from Jack
|
||||||
del conversation[new_comment4_id]
|
del conversation[new_comment4_id]
|
||||||
|
|
||||||
# check if Jack has been removed from the commentators list
|
# check if Jack has been removed from the commentators list
|
||||||
self.failUnless('Jim' in conversation.commentators)
|
self.assertTrue('Jim' in conversation.commentators)
|
||||||
self.failUnless('Joe' in conversation.commentators)
|
self.assertTrue('Joe' in conversation.commentators)
|
||||||
self.failIf('Jack' in conversation.commentators)
|
self.assertFalse('Jack' in conversation.commentators)
|
||||||
self.assertEquals(conversation.total_comments, 2)
|
self.assertEqual(conversation.total_comments, 2)
|
||||||
|
|
||||||
def test_last_comment_date(self):
|
def test_last_comment_date(self):
|
||||||
# add and remove some comments and check if last_comment_date
|
# add and remove some comments and check if last_comment_date
|
||||||
@ -580,9 +580,9 @@ class ConversationTest(PloneTestCase):
|
|||||||
new_comment3_id = conversation.addComment(comment3)
|
new_comment3_id = conversation.addComment(comment3)
|
||||||
|
|
||||||
# check if the latest comment is exactly one day old
|
# check if the latest comment is exactly one day old
|
||||||
self.assert_(conversation.last_comment_date < datetime.utcnow() -
|
self.assertTrue(conversation.last_comment_date < datetime.utcnow() -
|
||||||
timedelta(hours=23, minutes=59, seconds=59))
|
timedelta(hours=23, minutes=59, seconds=59))
|
||||||
self.assert_(conversation.last_comment_date >
|
self.assertTrue(conversation.last_comment_date >
|
||||||
datetime.utcnow() - timedelta(days=1, seconds=1))
|
datetime.utcnow() - timedelta(days=1, seconds=1))
|
||||||
|
|
||||||
# remove the latest comment
|
# remove the latest comment
|
||||||
@ -590,9 +590,9 @@ class ConversationTest(PloneTestCase):
|
|||||||
|
|
||||||
# check if the latest comment has been updated
|
# check if the latest comment has been updated
|
||||||
# the latest comment should be exactly two days old
|
# the latest comment should be exactly two days old
|
||||||
self.assert_(conversation.last_comment_date < datetime.utcnow() -
|
self.assertTrue(conversation.last_comment_date < datetime.utcnow() -
|
||||||
timedelta(days=1, hours=23, minutes=59, seconds=59))
|
timedelta(days=1, hours=23, minutes=59, seconds=59))
|
||||||
self.assert_(conversation.last_comment_date > datetime.utcnow() -
|
self.assertTrue(conversation.last_comment_date > datetime.utcnow() -
|
||||||
timedelta(days=2, seconds=1))
|
timedelta(days=2, seconds=1))
|
||||||
|
|
||||||
# remove the latest comment again
|
# remove the latest comment again
|
||||||
@ -600,9 +600,9 @@ class ConversationTest(PloneTestCase):
|
|||||||
|
|
||||||
# check if the latest comment has been updated
|
# check if the latest comment has been updated
|
||||||
# the latest comment should be exactly four days old
|
# the latest comment should be exactly four days old
|
||||||
self.assert_(conversation.last_comment_date < datetime.utcnow() -
|
self.assertTrue(conversation.last_comment_date < datetime.utcnow() -
|
||||||
timedelta(days=3, hours=23, minutes=59, seconds=59))
|
timedelta(days=3, hours=23, minutes=59, seconds=59))
|
||||||
self.assert_(conversation.last_comment_date > datetime.utcnow() -
|
self.assertTrue(conversation.last_comment_date > datetime.utcnow() -
|
||||||
timedelta(days=4, seconds=2))
|
timedelta(days=4, seconds=2))
|
||||||
|
|
||||||
def test_get_comments_full(self):
|
def test_get_comments_full(self):
|
||||||
@ -666,7 +666,7 @@ class ConversationTest(PloneTestCase):
|
|||||||
|
|
||||||
# Get threads
|
# Get threads
|
||||||
|
|
||||||
self.assertEquals(
|
self.assertEqual(
|
||||||
[{'comment': comment1, 'depth': 0, 'id': new_id_1},
|
[{'comment': comment1, 'depth': 0, 'id': new_id_1},
|
||||||
{'comment': comment1_1, 'depth': 1, 'id': new_id_1_1},
|
{'comment': comment1_1, 'depth': 1, 'id': new_id_1_1},
|
||||||
{'comment': comment1_1_1, 'depth': 2, 'id': new_id_1_1_1},
|
{'comment': comment1_1_1, 'depth': 2, 'id': new_id_1_1_1},
|
||||||
@ -685,11 +685,11 @@ class ConversationTest(PloneTestCase):
|
|||||||
|
|
||||||
conversation = self.portal.doc1.restrictedTraverse(
|
conversation = self.portal.doc1.restrictedTraverse(
|
||||||
'++conversation++default')
|
'++conversation++default')
|
||||||
self.assert_(IConversation.providedBy(conversation))
|
self.assertTrue(IConversation.providedBy(conversation))
|
||||||
|
|
||||||
self.assertEquals(('', 'plone', 'doc1', '++conversation++default'),
|
self.assertEqual(('', 'plone', 'doc1', '++conversation++default'),
|
||||||
conversation.getPhysicalPath())
|
conversation.getPhysicalPath())
|
||||||
self.assertEquals('http://nohost/plone/doc1/++conversation++default',
|
self.assertEqual('http://nohost/plone/doc1/++conversation++default',
|
||||||
conversation.absolute_url())
|
conversation.absolute_url())
|
||||||
|
|
||||||
def test_parent(self):
|
def test_parent(self):
|
||||||
@ -699,19 +699,19 @@ class ConversationTest(PloneTestCase):
|
|||||||
conversation = IConversation(self.portal.doc1)
|
conversation = IConversation(self.portal.doc1)
|
||||||
|
|
||||||
# Check the parent
|
# Check the parent
|
||||||
self.failUnless(conversation.__parent__)
|
self.assertTrue(conversation.__parent__)
|
||||||
self.failUnless(aq_parent(conversation))
|
self.assertTrue(aq_parent(conversation))
|
||||||
|
|
||||||
self.assertEquals(conversation.__parent__.getId(), 'doc1')
|
self.assertEqual(conversation.__parent__.getId(), 'doc1')
|
||||||
|
|
||||||
def test_discussion_item_not_in_bad_types(self):
|
def test_discussion_item_not_in_bad_types(self):
|
||||||
self.failIf('Discussion Item' in BAD_TYPES)
|
self.assertFalse('Discussion Item' in BAD_TYPES)
|
||||||
|
|
||||||
def test_no_comment(self):
|
def test_no_comment(self):
|
||||||
conversation = IConversation(self.portal.doc1)
|
conversation = IConversation(self.portal.doc1)
|
||||||
|
|
||||||
# Make sure no conversation has been created
|
# Make sure no conversation has been created
|
||||||
self.assert_('plone.app.discussion:conversation' not in
|
self.assertTrue('plone.app.discussion:conversation' not in
|
||||||
IAnnotations(self.portal.doc1))
|
IAnnotations(self.portal.doc1))
|
||||||
|
|
||||||
|
|
||||||
@ -742,15 +742,15 @@ class RepliesTest(PloneTestCase):
|
|||||||
new_id = replies.addComment(comment)
|
new_id = replies.addComment(comment)
|
||||||
|
|
||||||
# check that replies provides the IReplies interface
|
# check that replies provides the IReplies interface
|
||||||
self.assert_(IReplies.providedBy(replies))
|
self.assertTrue(IReplies.providedBy(replies))
|
||||||
|
|
||||||
# Make sure our comment was added
|
# Make sure our comment was added
|
||||||
self.failUnless(new_id in replies)
|
self.assertTrue(new_id in replies)
|
||||||
|
|
||||||
# Make sure it is also reflected in the conversation
|
# Make sure it is also reflected in the conversation
|
||||||
self.failUnless(new_id in conversation)
|
self.assertTrue(new_id in conversation)
|
||||||
|
|
||||||
self.assertEquals(conversation[new_id].comment_id, new_id)
|
self.assertEqual(conversation[new_id].comment_id, new_id)
|
||||||
|
|
||||||
def test_delete_comment(self):
|
def test_delete_comment(self):
|
||||||
# Create and remove a comment and check if the replies adapter
|
# Create and remove a comment and check if the replies adapter
|
||||||
@ -769,13 +769,13 @@ class RepliesTest(PloneTestCase):
|
|||||||
new_id = replies.addComment(comment)
|
new_id = replies.addComment(comment)
|
||||||
|
|
||||||
# make sure the comment has been added
|
# make sure the comment has been added
|
||||||
self.assertEquals(len(replies), 1)
|
self.assertEqual(len(replies), 1)
|
||||||
|
|
||||||
# delete the comment we just created
|
# delete the comment we just created
|
||||||
del replies[new_id]
|
del replies[new_id]
|
||||||
|
|
||||||
# make sure there is no comment left in the conversation
|
# make sure there is no comment left in the conversation
|
||||||
self.assertEquals(len(replies), 0)
|
self.assertEqual(len(replies), 0)
|
||||||
|
|
||||||
def test_dict_api(self):
|
def test_dict_api(self):
|
||||||
# This test is for the ConversationReplies as well as the
|
# This test is for the ConversationReplies as well as the
|
||||||
@ -842,11 +842,11 @@ class RepliesTest(PloneTestCase):
|
|||||||
|
|
||||||
# check that replies only contain the direct comments
|
# check that replies only contain the direct comments
|
||||||
# and no comments deeper than 1
|
# and no comments deeper than 1
|
||||||
self.assertEquals(conversation.total_comments, 6)
|
self.assertEqual(conversation.total_comments, 6)
|
||||||
self.assertEquals(len(replies), 2)
|
self.assertEqual(len(replies), 2)
|
||||||
self.assertEquals(len(replies_to_comment1), 2)
|
self.assertEqual(len(replies_to_comment1), 2)
|
||||||
self.assertEquals(len(replies_to_comment1_1), 1)
|
self.assertEqual(len(replies_to_comment1_1), 1)
|
||||||
self.assertEquals(len(replies_to_comment2), 1)
|
self.assertEqual(len(replies_to_comment2), 1)
|
||||||
|
|
||||||
def test_suite():
|
def test_suite():
|
||||||
return unittest.defaultTestLoader.loadTestsFromName(__name__)
|
return unittest.defaultTestLoader.loadTestsFromName(__name__)
|
||||||
|
@ -71,32 +71,32 @@ class ConversationIndexersTest(PloneTestCase):
|
|||||||
self.conversation = conversation
|
self.conversation = conversation
|
||||||
|
|
||||||
def test_conversation_total_comments(self):
|
def test_conversation_total_comments(self):
|
||||||
self.assert_(isinstance(catalog.total_comments,
|
self.assertTrue(isinstance(catalog.total_comments,
|
||||||
DelegatingIndexerFactory))
|
DelegatingIndexerFactory))
|
||||||
self.assertEquals(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.assertEquals(catalog.total_comments(self.portal.doc1)(), 2)
|
self.assertEqual(catalog.total_comments(self.portal.doc1)(), 2)
|
||||||
del self.conversation[self.new_id2]
|
del self.conversation[self.new_id2]
|
||||||
del self.conversation[self.new_id3]
|
del self.conversation[self.new_id3]
|
||||||
self.assertEquals(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.assert_(isinstance(catalog.last_comment_date,
|
self.assertTrue(isinstance(catalog.last_comment_date,
|
||||||
DelegatingIndexerFactory))
|
DelegatingIndexerFactory))
|
||||||
self.assertEquals(catalog.last_comment_date(self.portal.doc1)(),
|
self.assertEqual(catalog.last_comment_date(self.portal.doc1)(),
|
||||||
datetime(2009, 4, 12, 11, 12, 12))
|
datetime(2009, 4, 12, 11, 12, 12))
|
||||||
del self.conversation[self.new_id3]
|
del self.conversation[self.new_id3]
|
||||||
self.assertEquals(catalog.last_comment_date(self.portal.doc1)(),
|
self.assertEqual(catalog.last_comment_date(self.portal.doc1)(),
|
||||||
datetime(2007, 12, 13, 4, 18, 12))
|
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.assertEquals(catalog.last_comment_date(self.portal.doc1)(), None)
|
self.assertEqual(catalog.last_comment_date(self.portal.doc1)(), None)
|
||||||
|
|
||||||
def test_conversation_commentators(self):
|
def test_conversation_commentators(self):
|
||||||
pass
|
pass
|
||||||
#self.assertEquals(catalog.commentators(self.portal.doc1)(),
|
#self.assertEqual(catalog.commentators(self.portal.doc1)(),
|
||||||
# ('Jim', 'Emma', 'Lukas'))
|
# ('Jim', 'Emma', 'Lukas'))
|
||||||
#self.assert_(isinstance(catalog.commentators,
|
#self.assertTrue(isinstance(catalog.commentators,
|
||||||
# DelegatingIndexerFactory))
|
# DelegatingIndexerFactory))
|
||||||
|
|
||||||
|
|
||||||
@ -129,13 +129,13 @@ class CommentIndexersTest(PloneTestCase):
|
|||||||
self.conversation = conversation
|
self.conversation = conversation
|
||||||
|
|
||||||
def test_title(self):
|
def test_title(self):
|
||||||
self.assertEquals(catalog.title(self.comment)(), 'Jim on Document 1')
|
self.assertEqual(catalog.title(self.comment)(), 'Jim on Document 1')
|
||||||
self.assert_(isinstance(catalog.title, DelegatingIndexerFactory))
|
self.assertTrue(isinstance(catalog.title, DelegatingIndexerFactory))
|
||||||
|
|
||||||
def test_description(self):
|
def test_description(self):
|
||||||
self.assertEquals(catalog.description(self.comment)(),
|
self.assertEqual(catalog.description(self.comment)(),
|
||||||
'Lorem ipsum dolor sit amet.')
|
'Lorem ipsum dolor sit amet.')
|
||||||
self.assert_(isinstance(catalog.description, DelegatingIndexerFactory))
|
self.assertTrue(isinstance(catalog.description, DelegatingIndexerFactory))
|
||||||
|
|
||||||
def test_description_long(self):
|
def test_description_long(self):
|
||||||
# Create a 50 word comment and make sure the description returns
|
# Create a 50 word comment and make sure the description returns
|
||||||
@ -145,32 +145,32 @@ class CommentIndexersTest(PloneTestCase):
|
|||||||
comment_long.text = LONG_TEXT
|
comment_long.text = LONG_TEXT
|
||||||
|
|
||||||
self.conversation.addComment(comment_long)
|
self.conversation.addComment(comment_long)
|
||||||
self.assertEquals(catalog.description(comment_long)(),
|
self.assertEqual(catalog.description(comment_long)(),
|
||||||
LONG_TEXT_CUT.replace("\n", " "))
|
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.assertEquals(catalog.created(self.comment)(),
|
self.assertEqual(catalog.created(self.comment)(),
|
||||||
DateTime(2006, 9, 17, 14, 18, 12, 'GMT'))
|
DateTime(2006, 9, 17, 14, 18, 12, 'GMT'))
|
||||||
self.assertEquals(catalog.effective(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.assertEquals(catalog.modified(self.comment)(),
|
self.assertEqual(catalog.modified(self.comment)(),
|
||||||
DateTime(2008, 3, 12, 7, 32, 52, 'GMT'))
|
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.assertEquals(catalog.searchable_text(self.comment)(),
|
self.assertEqual(catalog.searchable_text(self.comment)(),
|
||||||
('Lorem ipsum dolor sit amet.'))
|
('Lorem ipsum dolor sit amet.'))
|
||||||
self.assert_(isinstance(catalog.searchable_text,
|
self.assertTrue(isinstance(catalog.searchable_text,
|
||||||
DelegatingIndexerFactory))
|
DelegatingIndexerFactory))
|
||||||
|
|
||||||
def test_creator(self):
|
def test_creator(self):
|
||||||
self.assertEquals(catalog.creator(self.comment)(), ('Jim'))
|
self.assertEqual(catalog.creator(self.comment)(), ('Jim'))
|
||||||
|
|
||||||
def test_in_response_to(self):
|
def test_in_response_to(self):
|
||||||
# make sure in_response_to returns the title or id of the content
|
# make sure in_response_to returns the title or id of the content
|
||||||
# object the comment was added to
|
# object the comment was added to
|
||||||
self.assertEquals(catalog.in_response_to(self.comment)(), 'Document 1')
|
self.assertEqual(catalog.in_response_to(self.comment)(), 'Document 1')
|
||||||
|
|
||||||
|
|
||||||
def test_suite():
|
def test_suite():
|
||||||
|
@ -49,37 +49,37 @@ class MigrationTest(PloneTestCase):
|
|||||||
reply.setReplyTo(self.doc)
|
reply.setReplyTo(self.doc)
|
||||||
reply.creation_date = DateTime(2003, 3, 11, 9, 28, 6, 'GMT')
|
reply.creation_date = DateTime(2003, 3, 11, 9, 28, 6, 'GMT')
|
||||||
reply.modification_date = DateTime(2009, 7, 12, 19, 38, 7, 'GMT')
|
reply.modification_date = DateTime(2009, 7, 12, 19, 38, 7, 'GMT')
|
||||||
self.assertEquals(reply.Title(), 'My Title')
|
self.assertEqual(reply.Title(), 'My Title')
|
||||||
self.assertEquals(reply.EditableBody(), 'My Text')
|
self.assertEqual(reply.EditableBody(), 'My Text')
|
||||||
self.failUnless('Jim' in reply.listCreators())
|
self.assertTrue('Jim' in reply.listCreators())
|
||||||
self.assertEquals(talkback.replyCount(self.doc), 1)
|
self.assertEqual(talkback.replyCount(self.doc), 1)
|
||||||
self.assertEquals(reply.inReplyTo(), self.doc)
|
self.assertEqual(reply.inReplyTo(), self.doc)
|
||||||
|
|
||||||
# Call migration script
|
# Call migration script
|
||||||
self.view()
|
self.view()
|
||||||
|
|
||||||
# Make sure a conversation has been created
|
# Make sure a conversation has been created
|
||||||
self.failUnless('plone.app.discussion:conversation' in
|
self.assertTrue('plone.app.discussion:conversation' in
|
||||||
IAnnotations(self.doc))
|
IAnnotations(self.doc))
|
||||||
conversation = IConversation(self.doc)
|
conversation = IConversation(self.doc)
|
||||||
|
|
||||||
# Check migration
|
# Check migration
|
||||||
self.assertEquals(conversation.total_comments, 1)
|
self.assertEqual(conversation.total_comments, 1)
|
||||||
self.failUnless(conversation.getComments().next())
|
self.assertTrue(conversation.getComments().next())
|
||||||
comment1 = conversation.values()[0]
|
comment1 = conversation.values()[0]
|
||||||
self.assert_(IComment.providedBy(comment1))
|
self.assertTrue(IComment.providedBy(comment1))
|
||||||
self.assertEquals(comment1.Title(), 'My Title')
|
self.assertEqual(comment1.Title(), 'My Title')
|
||||||
self.assertEquals(comment1.text, '<p>My Text</p>\n')
|
self.assertEqual(comment1.text, '<p>My Text</p>\n')
|
||||||
self.assertEquals(comment1.mime_type, 'text/html')
|
self.assertEqual(comment1.mime_type, 'text/html')
|
||||||
self.assertEquals(comment1.Creator(), 'Jim')
|
self.assertEqual(comment1.Creator(), 'Jim')
|
||||||
self.assertEquals(comment1.creation_date,
|
self.assertEqual(comment1.creation_date,
|
||||||
datetime(2003, 3, 11, 9, 28, 6))
|
datetime(2003, 3, 11, 9, 28, 6))
|
||||||
self.assertEquals(comment1.modification_date,
|
self.assertEqual(comment1.modification_date,
|
||||||
datetime(2009, 7, 12, 19, 38, 7))
|
datetime(2009, 7, 12, 19, 38, 7))
|
||||||
self.assertEquals(
|
self.assertEqual(
|
||||||
[{'comment': comment1, 'depth': 0, 'id': long(comment1.id)},]
|
[{'comment': comment1, 'depth': 0, 'id': long(comment1.id)},]
|
||||||
, list(conversation.getThreads()))
|
, list(conversation.getThreads()))
|
||||||
self.failIf(self.doc.talkback)
|
self.assertFalse(self.doc.talkback)
|
||||||
|
|
||||||
def test_migrate_nested_comments(self):
|
def test_migrate_nested_comments(self):
|
||||||
# Create some nested comments and migrate them
|
# Create some nested comments and migrate them
|
||||||
@ -108,9 +108,9 @@ class MigrationTest(PloneTestCase):
|
|||||||
comment1_1 = talkback_comment1.getReplies()[0]
|
comment1_1 = talkback_comment1.getReplies()[0]
|
||||||
talkback_comment1_1 = self.discussion.getDiscussionFor(comment1_1)
|
talkback_comment1_1 = self.discussion.getDiscussionFor(comment1_1)
|
||||||
|
|
||||||
self.assertEquals(len(talkback.getReplies()), 1)
|
self.assertEqual(len(talkback.getReplies()), 1)
|
||||||
self.assertEquals(len(talkback_comment1.getReplies()), 1)
|
self.assertEqual(len(talkback_comment1.getReplies()), 1)
|
||||||
self.assertEquals(len(talkback_comment1_1.getReplies()), 0)
|
self.assertEqual(len(talkback_comment1_1.getReplies()), 0)
|
||||||
|
|
||||||
#Re: Re: First comment
|
#Re: Re: First comment
|
||||||
talkback_comment1_1.createReply(title='Re: Re: First comment',
|
talkback_comment1_1.createReply(title='Re: Re: First comment',
|
||||||
@ -143,7 +143,7 @@ class MigrationTest(PloneTestCase):
|
|||||||
|
|
||||||
# Check migration
|
# Check migration
|
||||||
conversation = IConversation(self.doc)
|
conversation = IConversation(self.doc)
|
||||||
self.assertEquals(conversation.total_comments, 8)
|
self.assertEqual(conversation.total_comments, 8)
|
||||||
|
|
||||||
comment1 = conversation.values()[0]
|
comment1 = conversation.values()[0]
|
||||||
comment1_1 = conversation.values()[1]
|
comment1_1 = conversation.values()[1]
|
||||||
@ -154,7 +154,7 @@ class MigrationTest(PloneTestCase):
|
|||||||
comment1_4 = conversation.values()[6]
|
comment1_4 = conversation.values()[6]
|
||||||
comment2 = conversation.values()[7]
|
comment2 = conversation.values()[7]
|
||||||
|
|
||||||
self.assertEquals(
|
self.assertEqual(
|
||||||
[{'comment': comment1, 'depth': 0, 'id': long(comment1.id)},
|
[{'comment': comment1, 'depth': 0, 'id': long(comment1.id)},
|
||||||
{'comment': comment1_1, 'depth': 1, 'id': long(comment1_1.id)},
|
{'comment': comment1_1, 'depth': 1, 'id': long(comment1_1.id)},
|
||||||
{'comment': comment1_1_1, 'depth': 2, 'id': long(comment1_1_1.id)},
|
{'comment': comment1_1_1, 'depth': 2, 'id': long(comment1_1_1.id)},
|
||||||
@ -166,7 +166,7 @@ class MigrationTest(PloneTestCase):
|
|||||||
], list(conversation.getThreads()))
|
], list(conversation.getThreads()))
|
||||||
|
|
||||||
talkback = self.discussion.getDiscussionFor(self.doc)
|
talkback = self.discussion.getDiscussionFor(self.doc)
|
||||||
self.assertEquals(len(talkback.getReplies()), 0)
|
self.assertEqual(len(talkback.getReplies()), 0)
|
||||||
|
|
||||||
def test_migrate_nested_comments_with_filter(self):
|
def test_migrate_nested_comments_with_filter(self):
|
||||||
# Create some nested comments and migrate them.
|
# Create some nested comments and migrate them.
|
||||||
@ -191,9 +191,9 @@ class MigrationTest(PloneTestCase):
|
|||||||
comment1_1 = talkback_comment1.getReplies()[0]
|
comment1_1 = talkback_comment1.getReplies()[0]
|
||||||
talkback_comment1_1 = self.discussion.getDiscussionFor(comment1_1)
|
talkback_comment1_1 = self.discussion.getDiscussionFor(comment1_1)
|
||||||
|
|
||||||
self.assertEquals(len(talkback.getReplies()), 1)
|
self.assertEqual(len(talkback.getReplies()), 1)
|
||||||
self.assertEquals(len(talkback_comment1.getReplies()), 1)
|
self.assertEqual(len(talkback_comment1.getReplies()), 1)
|
||||||
self.assertEquals(len(talkback_comment1_1.getReplies()), 0)
|
self.assertEqual(len(talkback_comment1_1.getReplies()), 0)
|
||||||
|
|
||||||
def deny_comments(reply):
|
def deny_comments(reply):
|
||||||
return False
|
return False
|
||||||
@ -203,9 +203,9 @@ class MigrationTest(PloneTestCase):
|
|||||||
|
|
||||||
# Check migration
|
# Check migration
|
||||||
conversation = IConversation(self.doc)
|
conversation = IConversation(self.doc)
|
||||||
self.assertEquals(conversation.total_comments, 0)
|
self.assertEqual(conversation.total_comments, 0)
|
||||||
talkback = self.discussion.getDiscussionFor(self.doc)
|
talkback = self.discussion.getDiscussionFor(self.doc)
|
||||||
self.assertEquals(len(talkback.getReplies()), 0)
|
self.assertEqual(len(talkback.getReplies()), 0)
|
||||||
|
|
||||||
def test_migrate_no_comment(self):
|
def test_migrate_no_comment(self):
|
||||||
|
|
||||||
@ -213,7 +213,7 @@ class MigrationTest(PloneTestCase):
|
|||||||
self.view()
|
self.view()
|
||||||
|
|
||||||
# Make sure no conversation has been created
|
# Make sure no conversation has been created
|
||||||
self.assert_('plone.app.discussion:conversation' not in
|
self.assertTrue('plone.app.discussion:conversation' not in
|
||||||
IAnnotations(self.doc))
|
IAnnotations(self.doc))
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,11 +72,11 @@ class ModerationViewTest(PloneTestCase):
|
|||||||
# The one_state_workflow does not have a 'pending' state
|
# The one_state_workflow does not have a 'pending' state
|
||||||
self.wf_tool.setChainForPortalTypes(('Discussion Item',),
|
self.wf_tool.setChainForPortalTypes(('Discussion Item',),
|
||||||
('one_state_workflow,'))
|
('one_state_workflow,'))
|
||||||
self.assertEquals(self.view.moderation_enabled(), False)
|
self.assertEqual(self.view.moderation_enabled(), False)
|
||||||
# The comment_review_workflow does have a 'pending' state
|
# The comment_review_workflow does have a 'pending' state
|
||||||
self.wf_tool.setChainForPortalTypes(('Discussion Item',),
|
self.wf_tool.setChainForPortalTypes(('Discussion Item',),
|
||||||
('comment_review_workflow,'))
|
('comment_review_workflow,'))
|
||||||
self.assertEquals(self.view.moderation_enabled(), True)
|
self.assertEqual(self.view.moderation_enabled(), True)
|
||||||
|
|
||||||
def test_old_comments_not_shown_in_moderation_view(self):
|
def test_old_comments_not_shown_in_moderation_view(self):
|
||||||
# Create an old comment and make sure it is not shown
|
# Create an old comment and make sure it is not shown
|
||||||
@ -91,15 +91,15 @@ class ModerationViewTest(PloneTestCase):
|
|||||||
reply.setReplyTo(self.portal.doc1)
|
reply.setReplyTo(self.portal.doc1)
|
||||||
reply.creation_date = DateTime(2003, 3, 11, 9, 28, 6)
|
reply.creation_date = DateTime(2003, 3, 11, 9, 28, 6)
|
||||||
reply.modification_date = DateTime(2009, 7, 12, 19, 38, 7)
|
reply.modification_date = DateTime(2009, 7, 12, 19, 38, 7)
|
||||||
self.assertEquals(reply.Title(), 'My Title')
|
self.assertEqual(reply.Title(), 'My Title')
|
||||||
self.assertEquals(reply.EditableBody(), 'My Text')
|
self.assertEqual(reply.EditableBody(), 'My Text')
|
||||||
self.failUnless('Jim' in reply.listCreators())
|
self.assertTrue('Jim' in reply.listCreators())
|
||||||
self.assertEquals(talkback.replyCount(self.portal.doc1), 1)
|
self.assertEqual(talkback.replyCount(self.portal.doc1), 1)
|
||||||
self.assertEquals(reply.inReplyTo(), self.portal.doc1)
|
self.assertEqual(reply.inReplyTo(), self.portal.doc1)
|
||||||
|
|
||||||
# Make sure only the two new comments are shown
|
# Make sure only the two new comments are shown
|
||||||
self.view()
|
self.view()
|
||||||
self.assertEquals(len(self.view.comments), 3)
|
self.assertEqual(len(self.view.comments), 3)
|
||||||
|
|
||||||
|
|
||||||
class ModerationBulkActionsViewTest(PloneTestCase):
|
class ModerationBulkActionsViewTest(PloneTestCase):
|
||||||
@ -157,7 +157,7 @@ class ModerationBulkActionsViewTest(PloneTestCase):
|
|||||||
self.request.set('form.select.BulkAction', '-1')
|
self.request.set('form.select.BulkAction', '-1')
|
||||||
self.request.set('paths', ['/'.join(self.comment1.getPhysicalPath())])
|
self.request.set('paths', ['/'.join(self.comment1.getPhysicalPath())])
|
||||||
view = BulkActionsView(self.context, self.request)
|
view = BulkActionsView(self.context, self.request)
|
||||||
self.failIf(view())
|
self.assertFalse(view())
|
||||||
|
|
||||||
def test_retract(self):
|
def test_retract(self):
|
||||||
self.request = self.app.REQUEST
|
self.request = self.app.REQUEST
|
||||||
@ -186,7 +186,7 @@ class ModerationBulkActionsViewTest(PloneTestCase):
|
|||||||
published_comments += 1
|
published_comments += 1
|
||||||
|
|
||||||
# Make sure the comment has been published
|
# Make sure the comment has been published
|
||||||
self.assertEquals(published_comments, 1)
|
self.assertEqual(published_comments, 1)
|
||||||
|
|
||||||
def test_mark_as_spam(self):
|
def test_mark_as_spam(self):
|
||||||
self.request = self.app.REQUEST
|
self.request = self.app.REQUEST
|
||||||
@ -203,7 +203,7 @@ class ModerationBulkActionsViewTest(PloneTestCase):
|
|||||||
self.context = self.app
|
self.context = self.app
|
||||||
|
|
||||||
# Initially we have three comments
|
# Initially we have three comments
|
||||||
self.assertEquals(self.conversation.total_comments, 3)
|
self.assertEqual(self.conversation.total_comments, 3)
|
||||||
|
|
||||||
# Delete two comments with bulk actions
|
# Delete two comments with bulk actions
|
||||||
self.request.set('form.select.BulkAction', 'delete')
|
self.request.set('form.select.BulkAction', 'delete')
|
||||||
@ -213,10 +213,10 @@ class ModerationBulkActionsViewTest(PloneTestCase):
|
|||||||
view()
|
view()
|
||||||
|
|
||||||
# Make sure that the two comments have been deleted
|
# Make sure that the two comments have been deleted
|
||||||
self.assertEquals(self.conversation.total_comments, 1)
|
self.assertEqual(self.conversation.total_comments, 1)
|
||||||
comment = self.conversation.getComments().next()
|
comment = self.conversation.getComments().next()
|
||||||
self.failUnless(comment)
|
self.assertTrue(comment)
|
||||||
self.assertEquals(comment, self.comment2)
|
self.assertEqual(comment, self.comment2)
|
||||||
|
|
||||||
def test_suite():
|
def test_suite():
|
||||||
return unittest.defaultTestLoader.loadTestsFromName(__name__)
|
return unittest.defaultTestLoader.loadTestsFromName(__name__)
|
||||||
|
@ -68,11 +68,11 @@ class TestUserNotificationUnit(PloneTestCase):
|
|||||||
comment = createObject('plone.Comment')
|
comment = createObject('plone.Comment')
|
||||||
comment.text = 'Comment text'
|
comment.text = 'Comment text'
|
||||||
self.conversation.addComment(comment)
|
self.conversation.addComment(comment)
|
||||||
self.assertEquals(len(self.mailhost.messages), 1)
|
self.assertEqual(len(self.mailhost.messages), 1)
|
||||||
self.failUnless(self.mailhost.messages[0])
|
self.assertTrue(self.mailhost.messages[0])
|
||||||
msg = str(self.mailhost.messages[0])
|
msg = str(self.mailhost.messages[0])
|
||||||
self.failUnless('To: john@plone.test' in msg)
|
self.assertTrue('To: john@plone.test' in msg)
|
||||||
self.failUnless('From: portal@plone.test' in msg)
|
self.assertTrue('From: portal@plone.test' in msg)
|
||||||
|
|
||||||
# We expect the headers to be properly header encoded (7-bit):
|
# We expect the headers to be properly header encoded (7-bit):
|
||||||
#>>> 'Subject: =?utf-8?q?Some_t=C3=A4st_subject=2E?=' in msg
|
#>>> 'Subject: =?utf-8?q?Some_t=C3=A4st_subject=2E?=' in msg
|
||||||
@ -100,7 +100,7 @@ class TestUserNotificationUnit(PloneTestCase):
|
|||||||
comment.text = 'Comment text'
|
comment.text = 'Comment text'
|
||||||
self.conversation.addComment(comment)
|
self.conversation.addComment(comment)
|
||||||
|
|
||||||
self.assertEquals(len(self.mailhost.messages), 0)
|
self.assertEqual(len(self.mailhost.messages), 0)
|
||||||
|
|
||||||
def test_do_not_notify_user_when_email_address_is_given(self):
|
def test_do_not_notify_user_when_email_address_is_given(self):
|
||||||
comment = createObject('plone.Comment')
|
comment = createObject('plone.Comment')
|
||||||
@ -112,7 +112,7 @@ class TestUserNotificationUnit(PloneTestCase):
|
|||||||
comment.text = 'Comment text'
|
comment.text = 'Comment text'
|
||||||
self.conversation.addComment(comment)
|
self.conversation.addComment(comment)
|
||||||
|
|
||||||
self.assertEquals(len(self.mailhost.messages), 0)
|
self.assertEqual(len(self.mailhost.messages), 0)
|
||||||
|
|
||||||
def test_do_not_notify_user_when_no_sender_is_available(self):
|
def test_do_not_notify_user_when_no_sender_is_available(self):
|
||||||
# Set sender mail address to none and make sure no email is send to
|
# Set sender mail address to none and make sure no email is send to
|
||||||
@ -129,7 +129,7 @@ class TestUserNotificationUnit(PloneTestCase):
|
|||||||
comment.text = 'Comment text'
|
comment.text = 'Comment text'
|
||||||
self.conversation.addComment(comment)
|
self.conversation.addComment(comment)
|
||||||
|
|
||||||
self.assertEquals(len(self.mailhost.messages), 0)
|
self.assertEqual(len(self.mailhost.messages), 0)
|
||||||
|
|
||||||
def test_notify_only_once(self):
|
def test_notify_only_once(self):
|
||||||
# When a user has added two comments in a conversation and has
|
# When a user has added two comments in a conversation and has
|
||||||
@ -151,19 +151,19 @@ class TestUserNotificationUnit(PloneTestCase):
|
|||||||
self.conversation.addComment(comment)
|
self.conversation.addComment(comment)
|
||||||
# Note that we might want to get rid of this message, as the
|
# Note that we might want to get rid of this message, as the
|
||||||
# new comment is added by the same user.
|
# new comment is added by the same user.
|
||||||
self.assertEquals(len(self.mailhost.messages), 1)
|
self.assertEqual(len(self.mailhost.messages), 1)
|
||||||
self.mailhost.reset()
|
self.mailhost.reset()
|
||||||
self.assertEquals(len(self.mailhost.messages), 0)
|
self.assertEqual(len(self.mailhost.messages), 0)
|
||||||
|
|
||||||
# Comment 3
|
# Comment 3
|
||||||
comment = createObject('plone.Comment')
|
comment = createObject('plone.Comment')
|
||||||
comment.text = 'Comment text'
|
comment.text = 'Comment text'
|
||||||
self.conversation.addComment(comment)
|
self.conversation.addComment(comment)
|
||||||
self.assertEquals(len(self.mailhost.messages), 1)
|
self.assertEqual(len(self.mailhost.messages), 1)
|
||||||
self.failUnless(self.mailhost.messages[0])
|
self.assertTrue(self.mailhost.messages[0])
|
||||||
msg = str(self.mailhost.messages[0])
|
msg = str(self.mailhost.messages[0])
|
||||||
self.failUnless('To: john@plone.test' in msg)
|
self.assertTrue('To: john@plone.test' in msg)
|
||||||
self.failUnless('From: portal@plone.test' in msg)
|
self.assertTrue('From: portal@plone.test' in msg)
|
||||||
|
|
||||||
|
|
||||||
class TestModeratorNotificationUnit(PloneTestCase):
|
class TestModeratorNotificationUnit(PloneTestCase):
|
||||||
@ -215,12 +215,12 @@ class TestModeratorNotificationUnit(PloneTestCase):
|
|||||||
comment.text = 'Comment text'
|
comment.text = 'Comment text'
|
||||||
self.conversation.addComment(comment)
|
self.conversation.addComment(comment)
|
||||||
|
|
||||||
self.assertEquals(len(self.mailhost.messages), 1)
|
self.assertEqual(len(self.mailhost.messages), 1)
|
||||||
self.failUnless(self.mailhost.messages[0])
|
self.assertTrue(self.mailhost.messages[0])
|
||||||
msg = self.mailhost.messages[0]
|
msg = self.mailhost.messages[0]
|
||||||
|
|
||||||
self.failUnless('To: portal@plone.test' in msg)
|
self.assertTrue('To: portal@plone.test' in msg)
|
||||||
self.failUnless('From: portal@plone.test' in msg)
|
self.assertTrue('From: portal@plone.test' in msg)
|
||||||
|
|
||||||
#We expect the headers to be properly header encoded (7-bit):
|
#We expect the headers to be properly header encoded (7-bit):
|
||||||
#>>> 'Subject: =?utf-8?q?Some_t=C3=A4st_subject=2E?=' in msg
|
#>>> 'Subject: =?utf-8?q?Some_t=C3=A4st_subject=2E?=' in msg
|
||||||
@ -243,12 +243,12 @@ class TestModeratorNotificationUnit(PloneTestCase):
|
|||||||
comment.text = 'Comment text'
|
comment.text = 'Comment text'
|
||||||
self.conversation.addComment(comment)
|
self.conversation.addComment(comment)
|
||||||
|
|
||||||
self.assertEquals(len(self.mailhost.messages), 1)
|
self.assertEqual(len(self.mailhost.messages), 1)
|
||||||
msg = self.mailhost.messages[0]
|
msg = self.mailhost.messages[0]
|
||||||
if not isinstance(msg, str):
|
if not isinstance(msg, str):
|
||||||
self.failUnless('test@example.com' in msg.mto)
|
self.assertTrue('test@example.com' in msg.mto)
|
||||||
else:
|
else:
|
||||||
self.failUnless('To: test@example.com' in msg)
|
self.assertTrue('To: test@example.com' in msg)
|
||||||
|
|
||||||
def test_do_not_notify_moderator_when_no_sender_is_available(self):
|
def test_do_not_notify_moderator_when_no_sender_is_available(self):
|
||||||
# Set sender mail address to nonw and make sure no email is send to the
|
# Set sender mail address to nonw and make sure no email is send to the
|
||||||
@ -258,7 +258,7 @@ class TestModeratorNotificationUnit(PloneTestCase):
|
|||||||
comment = createObject('plone.Comment')
|
comment = createObject('plone.Comment')
|
||||||
comment.text = 'Comment text'
|
comment.text = 'Comment text'
|
||||||
self.conversation.addComment(comment)
|
self.conversation.addComment(comment)
|
||||||
self.assertEquals(len(self.mailhost.messages), 0)
|
self.assertEqual(len(self.mailhost.messages), 0)
|
||||||
|
|
||||||
def test_do_not_notify_moderator_when_notification_is_disabled(self):
|
def test_do_not_notify_moderator_when_notification_is_disabled(self):
|
||||||
# Disable moderator notification setting and make sure no email is send
|
# Disable moderator notification setting and make sure no email is send
|
||||||
@ -270,7 +270,7 @@ class TestModeratorNotificationUnit(PloneTestCase):
|
|||||||
comment = createObject('plone.Comment')
|
comment = createObject('plone.Comment')
|
||||||
comment.text = 'Comment text'
|
comment.text = 'Comment text'
|
||||||
self.conversation.addComment(comment)
|
self.conversation.addComment(comment)
|
||||||
self.assertEquals(len(self.mailhost.messages), 0)
|
self.assertEqual(len(self.mailhost.messages), 0)
|
||||||
|
|
||||||
def test_suite():
|
def test_suite():
|
||||||
return unittest.defaultTestLoader.loadTestsFromName(__name__)
|
return unittest.defaultTestLoader.loadTestsFromName(__name__)
|
||||||
|
@ -33,9 +33,9 @@ class ToolTest(PloneTestCase):
|
|||||||
# Check that the comment got indexed in the tool:
|
# Check that the comment got indexed in the tool:
|
||||||
tool = queryUtility(ICommentingTool)
|
tool = queryUtility(ICommentingTool)
|
||||||
comment = list(tool.searchResults())
|
comment = list(tool.searchResults())
|
||||||
self.assert_(len(comment) == 1, "There is only one comment, but we got"
|
self.assertTrue(len(comment) == 1, "There is only one comment, but we got"
|
||||||
" %s results in the search" % len(comment))
|
" %s results in the search" % len(comment))
|
||||||
self.assertEquals(comment[0].Title, 'Jim on Document 1')
|
self.assertEqual(comment[0].Title, 'Jim on Document 1')
|
||||||
|
|
||||||
def test_unindexing(self):
|
def test_unindexing(self):
|
||||||
pass
|
pass
|
||||||
|
@ -35,15 +35,15 @@ class WorkflowSetupTest(PloneTestCase):
|
|||||||
def test_workflows_installed(self):
|
def test_workflows_installed(self):
|
||||||
"""Make sure both comment workflows have been installed properly.
|
"""Make sure both comment workflows have been installed properly.
|
||||||
"""
|
"""
|
||||||
self.failUnless('one_state_workflow' in
|
self.assertTrue('one_state_workflow' in
|
||||||
self.portal.portal_workflow.objectIds())
|
self.portal.portal_workflow.objectIds())
|
||||||
self.failUnless('comment_review_workflow' in
|
self.assertTrue('comment_review_workflow' in
|
||||||
self.portal.portal_workflow.objectIds())
|
self.portal.portal_workflow.objectIds())
|
||||||
|
|
||||||
def test_default_workflow(self):
|
def test_default_workflow(self):
|
||||||
"""Make sure one_state_workflow is the default workflow.
|
"""Make sure one_state_workflow is the default workflow.
|
||||||
"""
|
"""
|
||||||
self.assertEquals(('one_state_workflow',),
|
self.assertEqual(('one_state_workflow',),
|
||||||
self.portal.portal_workflow.getChainForPortalType(
|
self.portal.portal_workflow.getChainForPortalType(
|
||||||
'Discussion Item'))
|
'Discussion Item'))
|
||||||
|
|
||||||
@ -51,10 +51,10 @@ class WorkflowSetupTest(PloneTestCase):
|
|||||||
#'Review comments' in self.portal.permissionsOfRole('Admin')
|
#'Review comments' in self.portal.permissionsOfRole('Admin')
|
||||||
|
|
||||||
self.setRoles(('Reviewer',))
|
self.setRoles(('Reviewer',))
|
||||||
self.failUnless(self.portal.portal_membership.checkPermission(
|
self.assertTrue(self.portal.portal_membership.checkPermission(
|
||||||
'Review comments', self.folder), self.folder)
|
'Review comments', self.folder), self.folder)
|
||||||
self.setRoles(('Member',))
|
self.setRoles(('Member',))
|
||||||
self.failIf(self.portal.portal_membership.checkPermission(
|
self.assertFalse(self.portal.portal_membership.checkPermission(
|
||||||
'Review comments', self.folder), self.folder)
|
'Review comments', self.folder), self.folder)
|
||||||
|
|
||||||
def test_reply_to_item_permission(self):
|
def test_reply_to_item_permission(self):
|
||||||
@ -79,16 +79,16 @@ class PermissionsSetupTest(PloneTestCase):
|
|||||||
"""
|
"""
|
||||||
ReplyToItemPerm = "Reply to item"
|
ReplyToItemPerm = "Reply to item"
|
||||||
# should be allowed as Member
|
# should be allowed as Member
|
||||||
self.failUnless(self.checkPermission(ReplyToItemPerm, self.portal))
|
self.assertTrue(self.checkPermission(ReplyToItemPerm, self.portal))
|
||||||
# should be allowed as Authenticated
|
# should be allowed as Authenticated
|
||||||
self.setRoles(['Authenticated'])
|
self.setRoles(['Authenticated'])
|
||||||
self.failUnless(self.checkPermission(ReplyToItemPerm, self.portal))
|
self.assertTrue(self.checkPermission(ReplyToItemPerm, self.portal))
|
||||||
# should be allowed as Manager
|
# should be allowed as Manager
|
||||||
self.setRoles(['Manager'])
|
self.setRoles(['Manager'])
|
||||||
self.failUnless(self.checkPermission(ReplyToItemPerm, self.portal))
|
self.assertTrue(self.checkPermission(ReplyToItemPerm, self.portal))
|
||||||
# should not be allowed as anonymous
|
# should not be allowed as anonymous
|
||||||
self.logout()
|
self.logout()
|
||||||
self.failIf(self.checkPermission(ReplyToItemPerm, self.portal))
|
self.assertFalse(self.checkPermission(ReplyToItemPerm, self.portal))
|
||||||
|
|
||||||
|
|
||||||
class CommentOneStateWorkflowTest(PloneTestCase):
|
class CommentOneStateWorkflowTest(PloneTestCase):
|
||||||
@ -133,22 +133,22 @@ class CommentOneStateWorkflowTest(PloneTestCase):
|
|||||||
"""
|
"""
|
||||||
# Owner is allowed
|
# Owner is allowed
|
||||||
#self.login(default_user)
|
#self.login(default_user)
|
||||||
#self.failUnless(checkPerm(View, self.doc))
|
#self.assertTrue(checkPerm(View, self.doc))
|
||||||
# Member is allowed
|
# Member is allowed
|
||||||
self.login('member')
|
self.login('member')
|
||||||
self.failUnless(checkPerm(View, self.comment))
|
self.assertTrue(checkPerm(View, self.comment))
|
||||||
# Reviewer is allowed
|
# Reviewer is allowed
|
||||||
self.login('reviewer')
|
self.login('reviewer')
|
||||||
self.failUnless(checkPerm(View, self.comment))
|
self.assertTrue(checkPerm(View, self.comment))
|
||||||
# Anonymous is allowed
|
# Anonymous is allowed
|
||||||
self.logout()
|
self.logout()
|
||||||
self.failUnless(checkPerm(View, self.comment))
|
self.assertTrue(checkPerm(View, self.comment))
|
||||||
# Editor is allowed
|
# Editor is allowed
|
||||||
self.login('editor')
|
self.login('editor')
|
||||||
self.failUnless(checkPerm(View, self.comment))
|
self.assertTrue(checkPerm(View, self.comment))
|
||||||
# Reader is allowed
|
# Reader is allowed
|
||||||
self.login('reader')
|
self.login('reader')
|
||||||
self.failUnless(checkPerm(View, self.comment))
|
self.assertTrue(checkPerm(View, self.comment))
|
||||||
|
|
||||||
|
|
||||||
class CommentReviewWorkflowTest(PloneTestCase):
|
class CommentReviewWorkflowTest(PloneTestCase):
|
||||||
@ -193,7 +193,7 @@ class CommentReviewWorkflowTest(PloneTestCase):
|
|||||||
self.portal.REQUEST.form['comment_id'] = self.comment_id
|
self.portal.REQUEST.form['comment_id'] = self.comment_id
|
||||||
view = self.comment.restrictedTraverse('@@moderate-delete-comment')
|
view = self.comment.restrictedTraverse('@@moderate-delete-comment')
|
||||||
view()
|
view()
|
||||||
self.failIf(self.comment_id in self.conversation.objectIds())
|
self.assertFalse(self.comment_id in self.conversation.objectIds())
|
||||||
|
|
||||||
def test_delete_as_anonymous(self):
|
def test_delete_as_anonymous(self):
|
||||||
# Make sure that anonymous users can not delete comments
|
# Make sure that anonymous users can not delete comments
|
||||||
@ -202,7 +202,7 @@ class CommentReviewWorkflowTest(PloneTestCase):
|
|||||||
self.assertRaises(Unauthorized,
|
self.assertRaises(Unauthorized,
|
||||||
self.comment.restrictedTraverse,
|
self.comment.restrictedTraverse,
|
||||||
'@@moderate-delete-comment')
|
'@@moderate-delete-comment')
|
||||||
self.failUnless(self.comment_id in self.conversation.objectIds())
|
self.assertTrue(self.comment_id in self.conversation.objectIds())
|
||||||
|
|
||||||
def test_delete_as_user(self):
|
def test_delete_as_user(self):
|
||||||
# Make sure that members can not delete comments
|
# Make sure that members can not delete comments
|
||||||
@ -212,29 +212,29 @@ class CommentReviewWorkflowTest(PloneTestCase):
|
|||||||
self.assertRaises(Unauthorized,
|
self.assertRaises(Unauthorized,
|
||||||
self.comment.restrictedTraverse,
|
self.comment.restrictedTraverse,
|
||||||
'@@moderate-delete-comment')
|
'@@moderate-delete-comment')
|
||||||
self.failUnless(self.comment_id in self.conversation.objectIds())
|
self.assertTrue(self.comment_id in self.conversation.objectIds())
|
||||||
|
|
||||||
def test_publish(self):
|
def test_publish(self):
|
||||||
self.portal.REQUEST.form['comment_id'] = self.comment_id
|
self.portal.REQUEST.form['comment_id'] = self.comment_id
|
||||||
self.portal.REQUEST.form['workflow_action'] = 'publish'
|
self.portal.REQUEST.form['workflow_action'] = 'publish'
|
||||||
self.assertEquals('pending',
|
self.assertEqual('pending',
|
||||||
self.portal.portal_workflow.getInfoFor(
|
self.portal.portal_workflow.getInfoFor(
|
||||||
self.comment, 'review_state'))
|
self.comment, 'review_state'))
|
||||||
view = self.comment.restrictedTraverse('@@moderate-publish-comment')
|
view = self.comment.restrictedTraverse('@@moderate-publish-comment')
|
||||||
view()
|
view()
|
||||||
self.assertEquals('published', self.portal.portal_workflow.\
|
self.assertEqual('published', self.portal.portal_workflow.\
|
||||||
getInfoFor(self.comment, 'review_state'))
|
getInfoFor(self.comment, 'review_state'))
|
||||||
|
|
||||||
def test_publish_as_anonymous(self):
|
def test_publish_as_anonymous(self):
|
||||||
self.logout()
|
self.logout()
|
||||||
self.portal.REQUEST.form['comment_id'] = self.comment_id
|
self.portal.REQUEST.form['comment_id'] = self.comment_id
|
||||||
self.portal.REQUEST.form['workflow_action'] = 'publish'
|
self.portal.REQUEST.form['workflow_action'] = 'publish'
|
||||||
self.assertEquals('pending', self.portal.portal_workflow.\
|
self.assertEqual('pending', self.portal.portal_workflow.\
|
||||||
getInfoFor(self.comment, 'review_state'))
|
getInfoFor(self.comment, 'review_state'))
|
||||||
self.assertRaises(Unauthorized,
|
self.assertRaises(Unauthorized,
|
||||||
self.comment.restrictedTraverse,
|
self.comment.restrictedTraverse,
|
||||||
'@@moderate-publish-comment')
|
'@@moderate-publish-comment')
|
||||||
self.assertEquals('pending', self.portal.portal_workflow.\
|
self.assertEqual('pending', self.portal.portal_workflow.\
|
||||||
getInfoFor(self.comment, 'review_state'))
|
getInfoFor(self.comment, 'review_state'))
|
||||||
|
|
||||||
def test_suite():
|
def test_suite():
|
||||||
|
Loading…
Reference in New Issue
Block a user