find -name "*.py" -exec pyupgrade --py3-only --py37-plus {} +
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Test the plone.app.discussion catalog indexes
|
||||
"""
|
||||
from datetime import datetime
|
||||
@@ -98,7 +97,7 @@ class ConversationCatalogTest(unittest.TestCase):
|
||||
new_comment2_id = self.conversation.addComment(comment2)
|
||||
|
||||
comment2 = self.portal.doc1.restrictedTraverse(
|
||||
"++conversation++default/{0}".format(new_comment2_id),
|
||||
f"++conversation++default/{new_comment2_id}",
|
||||
)
|
||||
comment2.reindexObject()
|
||||
brains = self.catalog.searchResults(
|
||||
@@ -128,7 +127,7 @@ class ConversationCatalogTest(unittest.TestCase):
|
||||
new_comment2_id = self.conversation.addComment(comment2)
|
||||
|
||||
comment2 = self.portal.doc1.restrictedTraverse(
|
||||
"++conversation++default/{0}".format(new_comment2_id),
|
||||
f"++conversation++default/{new_comment2_id}",
|
||||
)
|
||||
comment2.reindexObject()
|
||||
brains = self.catalog.searchResults(
|
||||
@@ -188,7 +187,7 @@ class ConversationCatalogTest(unittest.TestCase):
|
||||
new_comment2_id = self.conversation.addComment(comment2)
|
||||
|
||||
comment2 = self.portal.doc1.restrictedTraverse(
|
||||
"++conversation++default/{0}".format(new_comment2_id),
|
||||
f"++conversation++default/{new_comment2_id}",
|
||||
)
|
||||
comment2.reindexObject()
|
||||
|
||||
@@ -283,7 +282,7 @@ class CommentCatalogTest(unittest.TestCase):
|
||||
|
||||
# Comment brain
|
||||
self.comment = self.portal.doc1.restrictedTraverse(
|
||||
"++conversation++default/{0}".format(new_comment1_id),
|
||||
f"++conversation++default/{new_comment1_id}",
|
||||
)
|
||||
brains = self.catalog.searchResults(
|
||||
dict(
|
||||
@@ -304,7 +303,7 @@ class CommentCatalogTest(unittest.TestCase):
|
||||
|
||||
# Comment brain
|
||||
comment = self.portal.doc1.restrictedTraverse(
|
||||
"++conversation++default/{0}".format(cid),
|
||||
f"++conversation++default/{cid}",
|
||||
)
|
||||
brains = self.catalog.searchResults(
|
||||
dict(
|
||||
@@ -503,7 +502,7 @@ class CommentCatalogTest(unittest.TestCase):
|
||||
brains = self.catalog.searchResults({"portal_type": "Discussion Item"})
|
||||
self.assertTrue(brains)
|
||||
comment_brain = brains[0]
|
||||
self.assertEqual(comment_brain.Title, u"Jim on Document 1")
|
||||
self.assertEqual(comment_brain.Title, "Jim on Document 1")
|
||||
self.assertEqual(
|
||||
comment_brain.getPath(),
|
||||
"/plone/doc1/++conversation++default/" + str(self.comment_id),
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from plone.app.discussion.browser.comment import View
|
||||
from plone.app.discussion.interfaces import IComment
|
||||
from plone.app.discussion.interfaces import IConversation
|
||||
@@ -64,7 +63,7 @@ class CommentTest(unittest.TestCase):
|
||||
comment1.comment_id = 123
|
||||
self.assertEqual("123", comment1.id)
|
||||
self.assertEqual("123", comment1.getId())
|
||||
self.assertEqual(u"123", comment1.__name__)
|
||||
self.assertEqual("123", comment1.__name__)
|
||||
|
||||
def test_uid(self):
|
||||
conversation = IConversation(self.portal.doc1)
|
||||
@@ -111,14 +110,14 @@ class CommentTest(unittest.TestCase):
|
||||
def test_title_special_characters(self):
|
||||
self.portal.invokeFactory(
|
||||
id="doc_sp_chars",
|
||||
title=u"Document äüö",
|
||||
title="Document äüö",
|
||||
type_name="Document",
|
||||
)
|
||||
conversation = IConversation(self.portal.doc_sp_chars)
|
||||
comment1 = createObject("plone.Comment")
|
||||
comment1.author_name = u"Tarek Ziadé"
|
||||
comment1.author_name = "Tarek Ziadé"
|
||||
conversation.addComment(comment1)
|
||||
self.assertEqual(u"Tarek Ziadé on Document äüö", comment1.Title())
|
||||
self.assertEqual("Tarek Ziadé on Document äüö", comment1.Title())
|
||||
|
||||
def test_title_special_characters_utf8(self):
|
||||
self.portal.invokeFactory(
|
||||
@@ -130,7 +129,7 @@ class CommentTest(unittest.TestCase):
|
||||
comment1 = createObject("plone.Comment")
|
||||
comment1.author_name = "Hüüb Bôûmä"
|
||||
conversation.addComment(comment1)
|
||||
self.assertEqual(u"Hüüb Bôûmä on Document ëïû", comment1.Title())
|
||||
self.assertEqual("Hüüb Bôûmä on Document ëïû", comment1.Title())
|
||||
|
||||
def test_creator(self):
|
||||
comment1 = createObject("plone.Comment")
|
||||
@@ -174,12 +173,9 @@ class CommentTest(unittest.TestCase):
|
||||
|
||||
def test_getText_with_non_ascii_characters(self):
|
||||
comment1 = createObject("plone.Comment")
|
||||
comment1.text = u"Umlaute sind ä, ö und ü."
|
||||
comment1.text = "Umlaute sind ä, ö und ü."
|
||||
out = b"<p>Umlaute sind \xc3\xa4, \xc3\xb6 und \xc3\xbc.</p>"
|
||||
if six.PY2:
|
||||
self.assertEqual(comment1.getText(), out)
|
||||
else:
|
||||
self.assertEqual(comment1.getText(), out.decode("utf8"))
|
||||
self.assertEqual(comment1.getText(), out.decode("utf8"))
|
||||
|
||||
def test_getText_doesnt_link(self):
|
||||
comment1 = createObject("plone.Comment")
|
||||
@@ -233,7 +229,7 @@ class CommentTest(unittest.TestCase):
|
||||
new_comment1_id = conversation.addComment(comment1)
|
||||
|
||||
comment = self.portal.doc1.restrictedTraverse(
|
||||
"++conversation++default/{0}".format(new_comment1_id),
|
||||
f"++conversation++default/{new_comment1_id}",
|
||||
)
|
||||
self.assertTrue(IComment.providedBy(comment))
|
||||
|
||||
@@ -268,7 +264,7 @@ class CommentTest(unittest.TestCase):
|
||||
comment1.text = "Comment text"
|
||||
new_comment1_id = conversation.addComment(comment1)
|
||||
comment = self.portal.image1.restrictedTraverse(
|
||||
"++conversation++default/{0}".format(new_comment1_id),
|
||||
f"++conversation++default/{new_comment1_id}",
|
||||
)
|
||||
|
||||
view = View(comment, self.request)
|
||||
@@ -336,7 +332,7 @@ class CommentTest(unittest.TestCase):
|
||||
new_comment1_id = conversation.addComment(comment1)
|
||||
|
||||
comment = self.portal.doc1.restrictedTraverse(
|
||||
"++conversation++default/{0}".format(new_comment1_id),
|
||||
f"++conversation++default/{new_comment1_id}",
|
||||
)
|
||||
|
||||
# make sure the view is there
|
||||
@@ -381,7 +377,7 @@ class RepliesTest(unittest.TestCase):
|
||||
comment.text = "Comment text"
|
||||
new_id = replies.addComment(comment)
|
||||
comment = self.portal.doc1.restrictedTraverse(
|
||||
"++conversation++default/{0}".format(new_id),
|
||||
f"++conversation++default/{new_id}",
|
||||
)
|
||||
|
||||
# Add a reply to the CommentReplies adapter of the first comment
|
||||
@@ -418,7 +414,7 @@ class RepliesTest(unittest.TestCase):
|
||||
comment.text = "Comment text"
|
||||
new_id = replies.addComment(comment)
|
||||
comment = self.portal.doc1.restrictedTraverse(
|
||||
"++conversation++default/{0}".format(new_id),
|
||||
f"++conversation++default/{new_id}",
|
||||
)
|
||||
|
||||
# Add a reply to the CommentReplies adapter of the first comment
|
||||
@@ -454,7 +450,7 @@ class RepliesTest(unittest.TestCase):
|
||||
comment.text = "Comment text"
|
||||
new_id = conversation.addComment(comment)
|
||||
comment = self.portal.doc1.restrictedTraverse(
|
||||
"++conversation++default/{0}".format(new_id),
|
||||
f"++conversation++default/{new_id}",
|
||||
)
|
||||
|
||||
# Add a reply to the CommentReplies adapter of the first comment
|
||||
@@ -463,7 +459,7 @@ class RepliesTest(unittest.TestCase):
|
||||
replies = IReplies(comment)
|
||||
new_re_id = replies.addComment(re_comment)
|
||||
re_comment = self.portal.doc1.restrictedTraverse(
|
||||
"++conversation++default/{0}".format(new_re_id),
|
||||
f"++conversation++default/{new_re_id}",
|
||||
)
|
||||
|
||||
# Add a reply to the reply
|
||||
@@ -472,7 +468,7 @@ class RepliesTest(unittest.TestCase):
|
||||
replies = IReplies(re_comment)
|
||||
new_re_re_id = replies.addComment(re_re_comment)
|
||||
re_re_comment = self.portal.doc1.restrictedTraverse(
|
||||
"++conversation++default/{0}".format(new_re_re_id),
|
||||
f"++conversation++default/{new_re_re_id}",
|
||||
)
|
||||
|
||||
# Add a reply to the replies reply
|
||||
@@ -481,7 +477,7 @@ class RepliesTest(unittest.TestCase):
|
||||
replies = IReplies(re_re_comment)
|
||||
new_re_re_re_id = replies.addComment(re_re_re_comment)
|
||||
re_re_re_comment = self.portal.doc1.restrictedTraverse(
|
||||
"++conversation++default/{0}".format(new_re_re_re_id),
|
||||
f"++conversation++default/{new_re_re_re_id}",
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from AccessControl import Unauthorized
|
||||
from datetime import datetime
|
||||
from OFS.Image import Image
|
||||
@@ -81,7 +80,7 @@ class TestCommentForm(unittest.TestCase):
|
||||
adapts=(Interface, IBrowserRequest),
|
||||
provides=Interface,
|
||||
factory=CommentForm,
|
||||
name=u"comment-form",
|
||||
name="comment-form",
|
||||
)
|
||||
|
||||
# The form should return an error if the comment text field is empty
|
||||
@@ -89,7 +88,7 @@ class TestCommentForm(unittest.TestCase):
|
||||
|
||||
commentForm = getMultiAdapter(
|
||||
(self.context, request),
|
||||
name=u"comment-form",
|
||||
name="comment-form",
|
||||
)
|
||||
commentForm.update()
|
||||
data, errors = commentForm.extractData() # pylint: disable-msg=W0612
|
||||
@@ -99,11 +98,11 @@ class TestCommentForm(unittest.TestCase):
|
||||
|
||||
# The form is submitted successfully, if the required text field is
|
||||
# filled out
|
||||
request = make_request(form={"form.widgets.text": u"bar"})
|
||||
request = make_request(form={"form.widgets.text": "bar"})
|
||||
|
||||
commentForm = getMultiAdapter(
|
||||
(self.context, request),
|
||||
name=u"comment-form",
|
||||
name="comment-form",
|
||||
)
|
||||
commentForm.update()
|
||||
data, errors = commentForm.extractData() # pylint: disable-msg=W0612
|
||||
@@ -116,7 +115,7 @@ class TestCommentForm(unittest.TestCase):
|
||||
self.assertEqual(len(comments), 1)
|
||||
|
||||
for comment in comments:
|
||||
self.assertEqual(comment.text, u"bar")
|
||||
self.assertEqual(comment.text, "bar")
|
||||
self.assertEqual(comment.creator, "test_user_1_")
|
||||
self.assertEqual(comment.getOwner().getUserName(), "test-user")
|
||||
local_roles = comment.get_local_roles()
|
||||
@@ -144,23 +143,23 @@ class TestCommentForm(unittest.TestCase):
|
||||
adapts=(Interface, IBrowserRequest),
|
||||
provides=Interface,
|
||||
factory=CommentForm,
|
||||
name=u"comment-form",
|
||||
name="comment-form",
|
||||
)
|
||||
|
||||
provideAdapter(
|
||||
adapts=(Interface, IBrowserRequest),
|
||||
provides=Interface,
|
||||
factory=EditCommentForm,
|
||||
name=u"edit-comment-form",
|
||||
name="edit-comment-form",
|
||||
)
|
||||
|
||||
# The form is submitted successfully, if the required text field is
|
||||
# filled out
|
||||
request = make_request(form={"form.widgets.text": u"bar"})
|
||||
request = make_request(form={"form.widgets.text": "bar"})
|
||||
|
||||
commentForm = getMultiAdapter(
|
||||
(self.context, request),
|
||||
name=u"comment-form",
|
||||
name="comment-form",
|
||||
)
|
||||
commentForm.update()
|
||||
data, errors = commentForm.extractData() # pylint: disable-msg=W0612
|
||||
@@ -171,10 +170,10 @@ class TestCommentForm(unittest.TestCase):
|
||||
# Edit the last comment
|
||||
conversation = IConversation(self.context)
|
||||
comment = [x for x in conversation.getComments()][-1]
|
||||
request = make_request(form={"form.widgets.text": u"foobar"})
|
||||
request = make_request(form={"form.widgets.text": "foobar"})
|
||||
editForm = getMultiAdapter(
|
||||
(comment, request),
|
||||
name=u"edit-comment-form",
|
||||
name="edit-comment-form",
|
||||
)
|
||||
editForm.update()
|
||||
data, errors = editForm.extractData() # pylint: disable-msg=W0612
|
||||
@@ -182,14 +181,14 @@ class TestCommentForm(unittest.TestCase):
|
||||
self.assertEqual(len(errors), 0)
|
||||
self.assertFalse(editForm.handleComment(editForm, "foo"))
|
||||
comment = [x for x in conversation.getComments()][-1]
|
||||
self.assertEqual(comment.text, u"foobar")
|
||||
self.assertEqual(comment.text, "foobar")
|
||||
|
||||
comments = IConversation(commentForm.context).getComments()
|
||||
comments = [c for c in comments] # consume iterator
|
||||
self.assertEqual(len(comments), 1)
|
||||
|
||||
for comment in comments:
|
||||
self.assertEqual(comment.text, u"foobar")
|
||||
self.assertEqual(comment.text, "foobar")
|
||||
self.assertEqual(comment.creator, "test_user_1_")
|
||||
|
||||
self.assertEqual(comment.getOwner().getUserName(), "test-user")
|
||||
@@ -218,16 +217,16 @@ class TestCommentForm(unittest.TestCase):
|
||||
adapts=(Interface, IBrowserRequest),
|
||||
provides=Interface,
|
||||
factory=CommentForm,
|
||||
name=u"comment-form",
|
||||
name="comment-form",
|
||||
)
|
||||
|
||||
# The form is submitted successfully, if the required text field is
|
||||
# filled out
|
||||
form_request = make_request(form={"form.widgets.text": u"bar"})
|
||||
form_request = make_request(form={"form.widgets.text": "bar"})
|
||||
|
||||
commentForm = getMultiAdapter(
|
||||
(self.context, form_request),
|
||||
name=u"comment-form",
|
||||
name="comment-form",
|
||||
)
|
||||
|
||||
commentForm.update()
|
||||
@@ -240,7 +239,7 @@ class TestCommentForm(unittest.TestCase):
|
||||
comment = [x for x in conversation.getComments()][-1]
|
||||
deleteView = getMultiAdapter(
|
||||
(comment, self.request),
|
||||
name=u"moderate-delete-comment",
|
||||
name="moderate-delete-comment",
|
||||
)
|
||||
# try to delete last comment without 'Delete comments' permission
|
||||
setRoles(self.portal, TEST_USER_ID, ["Member"])
|
||||
@@ -275,16 +274,16 @@ class TestCommentForm(unittest.TestCase):
|
||||
adapts=(Interface, IBrowserRequest),
|
||||
provides=Interface,
|
||||
factory=CommentForm,
|
||||
name=u"comment-form",
|
||||
name="comment-form",
|
||||
)
|
||||
|
||||
# The form is submitted successfully, if the required text field is
|
||||
# filled out
|
||||
form_request = make_request(form={"form.widgets.text": u"bar"})
|
||||
form_request = make_request(form={"form.widgets.text": "bar"})
|
||||
|
||||
commentForm = getMultiAdapter(
|
||||
(self.context, form_request),
|
||||
name=u"comment-form",
|
||||
name="comment-form",
|
||||
)
|
||||
|
||||
commentForm.update()
|
||||
@@ -297,7 +296,7 @@ class TestCommentForm(unittest.TestCase):
|
||||
comment = [x for x in conversation.getComments()][-1]
|
||||
deleteView = getMultiAdapter(
|
||||
(comment, self.request),
|
||||
name=u"delete-own-comment",
|
||||
name="delete-own-comment",
|
||||
)
|
||||
# try to delete last comment with johndoe
|
||||
setRoles(self.portal, "johndoe", ["Member"])
|
||||
@@ -337,20 +336,20 @@ class TestCommentForm(unittest.TestCase):
|
||||
adapts=(Interface, IBrowserRequest),
|
||||
provides=Interface,
|
||||
factory=CommentForm,
|
||||
name=u"comment-form",
|
||||
name="comment-form",
|
||||
)
|
||||
|
||||
# Post an anonymous comment and provide a name
|
||||
request = make_request(
|
||||
form={
|
||||
"form.widgets.name": u"john doe",
|
||||
"form.widgets.text": u"bar",
|
||||
"form.widgets.name": "john doe",
|
||||
"form.widgets.text": "bar",
|
||||
}
|
||||
)
|
||||
|
||||
commentForm = getMultiAdapter(
|
||||
(self.context, request),
|
||||
name=u"comment-form",
|
||||
name="comment-form",
|
||||
)
|
||||
commentForm.update()
|
||||
data, errors = commentForm.extractData() # pylint: disable-msg=W0612
|
||||
@@ -363,7 +362,7 @@ class TestCommentForm(unittest.TestCase):
|
||||
self.assertEqual(len(comments), 1)
|
||||
|
||||
for comment in IConversation(commentForm.context).getComments():
|
||||
self.assertEqual(comment.text, u"bar")
|
||||
self.assertEqual(comment.text, "bar")
|
||||
self.assertIsNone(comment.creator)
|
||||
roles = comment.get_local_roles()
|
||||
self.assertEqual(len(roles), 0)
|
||||
@@ -387,14 +386,14 @@ class TestCommentForm(unittest.TestCase):
|
||||
adapts=(Interface, IBrowserRequest),
|
||||
provides=Interface,
|
||||
factory=CommentForm,
|
||||
name=u"comment-form",
|
||||
name="comment-form",
|
||||
)
|
||||
|
||||
request = make_request(form={"form.widgets.text": u"bar"})
|
||||
request = make_request(form={"form.widgets.text": "bar"})
|
||||
|
||||
commentForm = getMultiAdapter(
|
||||
(self.context, request),
|
||||
name=u"comment-form",
|
||||
name="comment-form",
|
||||
)
|
||||
commentForm.update()
|
||||
data, errors = commentForm.extractData() # pylint: disable-msg=W0612
|
||||
@@ -425,12 +424,12 @@ class TestCommentForm(unittest.TestCase):
|
||||
adapts=(Interface, IBrowserRequest),
|
||||
provides=Interface,
|
||||
factory=CommentForm,
|
||||
name=u"comment-form",
|
||||
name="comment-form",
|
||||
)
|
||||
|
||||
request = make_request(form={"form.widgets.text": u"bar"})
|
||||
request = make_request(form={"form.widgets.text": "bar"})
|
||||
|
||||
commentForm = getMultiAdapter((self.context, request), name=u"comment-form")
|
||||
commentForm = getMultiAdapter((self.context, request), name="comment-form")
|
||||
commentForm.update()
|
||||
data, errors = commentForm.extractData() # pylint: disable-msg=W0612
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from plone.app.discussion.interfaces import ICommentAddedEvent
|
||||
from plone.app.discussion.interfaces import ICommentRemovedEvent
|
||||
from plone.app.discussion.interfaces import IConversation
|
||||
@@ -56,32 +55,32 @@ class CommentContentRulesTest(unittest.TestCase):
|
||||
self.assertTrue(IRuleEventType.providedBy(IReplyRemovedEvent))
|
||||
|
||||
def testCommentIdStringSubstitution(self):
|
||||
comment_id = getAdapter(self.document, IStringSubstitution, name=u"comment_id")
|
||||
comment_id = getAdapter(self.document, IStringSubstitution, name="comment_id")
|
||||
self.assertIsInstance(comment_id(), int)
|
||||
|
||||
def testCommentTextStringSubstitution(self):
|
||||
comment_text = getAdapter(
|
||||
self.document, IStringSubstitution, name=u"comment_text"
|
||||
self.document, IStringSubstitution, name="comment_text"
|
||||
)
|
||||
self.assertEqual(comment_text(), u"This is a comment")
|
||||
self.assertEqual(comment_text(), "This is a comment")
|
||||
|
||||
def testCommentUserIdStringSubstitution(self):
|
||||
comment_user_id = getAdapter(
|
||||
self.document, IStringSubstitution, name=u"comment_user_id"
|
||||
self.document, IStringSubstitution, name="comment_user_id"
|
||||
)
|
||||
self.assertEqual(comment_user_id(), u"jim")
|
||||
self.assertEqual(comment_user_id(), "jim")
|
||||
|
||||
def testCommentUserFullNameStringSubstitution(self):
|
||||
comment_user_fullname = getAdapter(
|
||||
self.document, IStringSubstitution, name=u"comment_user_fullname"
|
||||
self.document, IStringSubstitution, name="comment_user_fullname"
|
||||
)
|
||||
self.assertEqual(comment_user_fullname(), u"Jim")
|
||||
self.assertEqual(comment_user_fullname(), "Jim")
|
||||
|
||||
def testCommentUserEmailStringSubstitution(self):
|
||||
comment_user_email = getAdapter(
|
||||
self.document, IStringSubstitution, name=u"comment_user_email"
|
||||
self.document, IStringSubstitution, name="comment_user_email"
|
||||
)
|
||||
self.assertEqual(comment_user_email(), u"jim@example.com")
|
||||
self.assertEqual(comment_user_email(), "jim@example.com")
|
||||
|
||||
|
||||
class ReplyContentRulesTest(unittest.TestCase):
|
||||
@@ -103,7 +102,7 @@ class ReplyContentRulesTest(unittest.TestCase):
|
||||
comment.text = "This is a comment"
|
||||
new_id = replies.addComment(comment)
|
||||
comment = self.document.restrictedTraverse(
|
||||
"++conversation++default/{0}".format(new_id),
|
||||
f"++conversation++default/{new_id}",
|
||||
)
|
||||
|
||||
re_comment = createObject("plone.Comment")
|
||||
@@ -119,7 +118,7 @@ class ReplyContentRulesTest(unittest.TestCase):
|
||||
reply_id = getAdapter(
|
||||
self.document,
|
||||
IStringSubstitution,
|
||||
name=u"comment_id",
|
||||
name="comment_id",
|
||||
)
|
||||
self.assertIsInstance(reply_id(), int)
|
||||
|
||||
@@ -127,30 +126,30 @@ class ReplyContentRulesTest(unittest.TestCase):
|
||||
reply_text = getAdapter(
|
||||
self.document,
|
||||
IStringSubstitution,
|
||||
name=u"comment_text",
|
||||
name="comment_text",
|
||||
)
|
||||
self.assertEqual(reply_text(), u"This is a reply")
|
||||
self.assertEqual(reply_text(), "This is a reply")
|
||||
|
||||
def testReplyUserIdStringSubstitution(self):
|
||||
reply_user_id = getAdapter(
|
||||
self.document,
|
||||
IStringSubstitution,
|
||||
name=u"comment_user_id",
|
||||
name="comment_user_id",
|
||||
)
|
||||
self.assertEqual(reply_user_id(), u"julia")
|
||||
self.assertEqual(reply_user_id(), "julia")
|
||||
|
||||
def testReplyUserFullNameStringSubstitution(self):
|
||||
reply_user_fullname = getAdapter(
|
||||
self.document,
|
||||
IStringSubstitution,
|
||||
name=u"comment_user_fullname",
|
||||
name="comment_user_fullname",
|
||||
)
|
||||
self.assertEqual(reply_user_fullname(), u"Juliana")
|
||||
self.assertEqual(reply_user_fullname(), "Juliana")
|
||||
|
||||
def testReplyUserEmailStringSubstitution(self):
|
||||
reply_user_email = getAdapter(
|
||||
self.document,
|
||||
IStringSubstitution,
|
||||
name=u"comment_user_email",
|
||||
name="comment_user_email",
|
||||
)
|
||||
self.assertEqual(reply_user_email(), u"julia@example.com")
|
||||
self.assertEqual(reply_user_email(), "julia@example.com")
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from plone.app.discussion.interfaces import IDiscussionSettings
|
||||
from plone.app.discussion.testing import ( # noqa
|
||||
PLONE_APP_DISCUSSION_INTEGRATION_TESTING,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from Acquisition import aq_base
|
||||
from Acquisition import aq_parent
|
||||
from datetime import datetime
|
||||
@@ -387,17 +386,17 @@ class ConversationTest(unittest.TestCase):
|
||||
self.assertTrue(comment2 in conversation.values())
|
||||
|
||||
# check if comment ids are in iterkeys
|
||||
self.assertTrue(new_id1 in six.iterkeys(conversation))
|
||||
self.assertTrue(new_id2 in six.iterkeys(conversation))
|
||||
self.assertFalse(123 in six.iterkeys(conversation))
|
||||
self.assertTrue(new_id1 in conversation.keys())
|
||||
self.assertTrue(new_id2 in conversation.keys())
|
||||
self.assertFalse(123 in conversation.keys())
|
||||
|
||||
# check if comment objects are in itervalues
|
||||
self.assertTrue(comment1 in six.itervalues(conversation))
|
||||
self.assertTrue(comment2 in six.itervalues(conversation))
|
||||
self.assertTrue(comment1 in conversation.values())
|
||||
self.assertTrue(comment2 in conversation.values())
|
||||
|
||||
# check if iteritems returns (key, comment object) pairs
|
||||
self.assertTrue((new_id1, comment1) in six.iteritems(conversation))
|
||||
self.assertTrue((new_id2, comment2) in six.iteritems(conversation))
|
||||
self.assertTrue((new_id1, comment1) in conversation.items())
|
||||
self.assertTrue((new_id2, comment2) in conversation.items())
|
||||
|
||||
# TODO test acquisition wrapping # noqa T000
|
||||
# self.assertTrue(aq_base(aq_parent(comment1)) is conversation)
|
||||
@@ -852,18 +851,18 @@ class RepliesTest(unittest.TestCase):
|
||||
# Create the nested comment structure
|
||||
new_id_1 = replies.addComment(comment1)
|
||||
comment1 = self.portal.doc1.restrictedTraverse(
|
||||
"++conversation++default/{0}".format(new_id_1),
|
||||
f"++conversation++default/{new_id_1}",
|
||||
)
|
||||
replies_to_comment1 = IReplies(comment1)
|
||||
new_id_2 = replies.addComment(comment2)
|
||||
comment2 = self.portal.doc1.restrictedTraverse(
|
||||
"++conversation++default/{0}".format(new_id_2),
|
||||
f"++conversation++default/{new_id_2}",
|
||||
)
|
||||
replies_to_comment2 = IReplies(comment2)
|
||||
|
||||
new_id_1_1 = replies_to_comment1.addComment(comment1_1)
|
||||
comment1_1 = self.portal.doc1.restrictedTraverse(
|
||||
"++conversation++default/{0}".format(new_id_1_1),
|
||||
f"++conversation++default/{new_id_1_1}",
|
||||
)
|
||||
replies_to_comment1_1 = IReplies(comment1_1)
|
||||
replies_to_comment1_1.addComment(comment1_1_1)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from plone.app.discussion.interfaces import IConversation
|
||||
from plone.app.discussion.interfaces import IReplies
|
||||
from plone.app.discussion.testing import ( # noqa
|
||||
@@ -20,7 +19,7 @@ import unittest
|
||||
#
|
||||
|
||||
|
||||
class EventsRegistry(object):
|
||||
class EventsRegistry:
|
||||
"""Fake registry to be used while testing discussion events"""
|
||||
|
||||
commentAdded = False
|
||||
@@ -123,7 +122,7 @@ class CommentEventsTest(unittest.TestCase):
|
||||
conversation = IConversation(self.document)
|
||||
new_id = conversation.addComment(comment)
|
||||
comment = self.document.restrictedTraverse(
|
||||
"++conversation++default/{0}".format(new_id),
|
||||
f"++conversation++default/{new_id}",
|
||||
)
|
||||
comment.text = "foo"
|
||||
notify(ObjectModifiedEvent(comment))
|
||||
@@ -191,7 +190,7 @@ class RepliesEventsTest(unittest.TestCase):
|
||||
comment.text = "Comment text"
|
||||
new_id = replies.addComment(comment)
|
||||
comment = self.document.restrictedTraverse(
|
||||
"++conversation++default/{0}".format(new_id),
|
||||
f"++conversation++default/{new_id}",
|
||||
)
|
||||
|
||||
re_comment = createObject("plone.Comment")
|
||||
@@ -211,7 +210,7 @@ class RepliesEventsTest(unittest.TestCase):
|
||||
comment.text = "Comment text"
|
||||
comment_id = replies.addComment(comment)
|
||||
comment = self.document.restrictedTraverse(
|
||||
"++conversation++default/{0}".format(comment_id),
|
||||
f"++conversation++default/{comment_id}",
|
||||
)
|
||||
re_comment = createObject("plone.Comment")
|
||||
re_comment.text = "Comment text"
|
||||
@@ -232,7 +231,7 @@ class RepliesEventsTest(unittest.TestCase):
|
||||
comment.text = "Comment text"
|
||||
new_id = replies.addComment(comment)
|
||||
comment = self.portal.doc1.restrictedTraverse(
|
||||
"++conversation++default/{0}".format(new_id),
|
||||
f"++conversation++default/{new_id}",
|
||||
)
|
||||
|
||||
re_comment = createObject("plone.Comment")
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Functional Doctests for plone.app.discussion.
|
||||
|
||||
These test are only triggered when Plone 4 (and plone.testing) is installed.
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Test for the plone.app.discussion indexers
|
||||
"""
|
||||
from datetime import datetime
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from plone.app.discussion.browser.moderation import BulkActionsView
|
||||
from plone.app.discussion.browser.moderation import CommentTransition
|
||||
from plone.app.discussion.browser.moderation import DeleteComment
|
||||
@@ -42,7 +41,7 @@ class ModerationBulkActionsViewTest(unittest.TestCase):
|
||||
comment1.Creator = "Jim"
|
||||
new_id_1 = conversation.addComment(comment1)
|
||||
self.comment1 = self.portal.doc1.restrictedTraverse(
|
||||
"++conversation++default/{0}".format(new_id_1),
|
||||
f"++conversation++default/{new_id_1}",
|
||||
)
|
||||
comment2 = createObject("plone.Comment")
|
||||
comment2.title = "Comment 2"
|
||||
@@ -50,7 +49,7 @@ class ModerationBulkActionsViewTest(unittest.TestCase):
|
||||
comment2.Creator = "Joe"
|
||||
new_id_2 = conversation.addComment(comment2)
|
||||
self.comment2 = self.portal.doc1.restrictedTraverse(
|
||||
"++conversation++default/{0}".format(new_id_2),
|
||||
f"++conversation++default/{new_id_2}",
|
||||
)
|
||||
comment3 = createObject("plone.Comment")
|
||||
comment3.title = "Comment 3"
|
||||
@@ -58,7 +57,7 @@ class ModerationBulkActionsViewTest(unittest.TestCase):
|
||||
comment3.Creator = "Emma"
|
||||
new_id_3 = conversation.addComment(comment3)
|
||||
self.comment3 = self.portal.doc1.restrictedTraverse(
|
||||
"++conversation++default/{0}".format(new_id_3),
|
||||
f"++conversation++default/{new_id_3}",
|
||||
)
|
||||
self.conversation = conversation
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from plone.app.discussion.browser.moderation import BulkActionsView
|
||||
from plone.app.discussion.browser.moderation import CommentTransition
|
||||
from plone.app.discussion.browser.moderation import DeleteComment
|
||||
@@ -81,7 +80,7 @@ class ModerationBulkActionsViewTest(unittest.TestCase):
|
||||
comment1.Creator = "Jim"
|
||||
new_id_1 = conversation.addComment(comment1)
|
||||
self.comment1 = self.portal.doc1.restrictedTraverse(
|
||||
"++conversation++default/{0}".format(new_id_1),
|
||||
f"++conversation++default/{new_id_1}",
|
||||
)
|
||||
comment2 = createObject("plone.Comment")
|
||||
comment2.title = "Comment 2"
|
||||
@@ -89,7 +88,7 @@ class ModerationBulkActionsViewTest(unittest.TestCase):
|
||||
comment2.Creator = "Joe"
|
||||
new_id_2 = conversation.addComment(comment2)
|
||||
self.comment2 = self.portal.doc1.restrictedTraverse(
|
||||
"++conversation++default/{0}".format(new_id_2),
|
||||
f"++conversation++default/{new_id_2}",
|
||||
)
|
||||
comment3 = createObject("plone.Comment")
|
||||
comment3.title = "Comment 3"
|
||||
@@ -97,7 +96,7 @@ class ModerationBulkActionsViewTest(unittest.TestCase):
|
||||
comment3.Creator = "Emma"
|
||||
new_id_3 = conversation.addComment(comment3)
|
||||
self.comment3 = self.portal.doc1.restrictedTraverse(
|
||||
"++conversation++default/{0}".format(new_id_3),
|
||||
f"++conversation++default/{new_id_3}",
|
||||
)
|
||||
self.conversation = conversation
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from Acquisition import aq_base
|
||||
from plone.app.discussion.interfaces import IConversation
|
||||
from plone.app.discussion.testing import ( # noqa
|
||||
@@ -80,7 +79,7 @@ class TestUserNotificationUnit(unittest.TestCase):
|
||||
# you may get lines separated by '\n' or '\r\n' in here.
|
||||
msg = msg.replace("\r\n", "\n")
|
||||
self.assertIn('A comment on "K=C3=B6lle Alaaf" has been posted here:', msg)
|
||||
self.assertIn("http://nohost/plone/d=\noc1/view#{0}".format(comment_id), msg)
|
||||
self.assertIn(f"http://nohost/plone/d=\noc1/view#{comment_id}", msg)
|
||||
self.assertIn("Comment text", msg)
|
||||
self.assertNotIn("Approve comment", msg)
|
||||
self.assertNotIn("Delete comment", msg)
|
||||
@@ -215,7 +214,7 @@ class TestModeratorNotificationUnit(unittest.TestCase):
|
||||
# The output should be encoded in a reasonable manner
|
||||
# (in this case quoted-printable):
|
||||
self.assertTrue('A comment on "K=C3=B6lle Alaaf" has been posted' in msg)
|
||||
self.assertIn("http://nohost/plone/doc1/view#{0}".format(comment_id), msg)
|
||||
self.assertIn(f"http://nohost/plone/doc1/view#{comment_id}", msg)
|
||||
self.assertIn(comment.author_email, msg)
|
||||
self.assertIn(comment.text, msg)
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from plone.app.discussion.testing import PLONE_APP_DISCUSSION_ROBOT_TESTING
|
||||
from plone.app.testing import ROBOT_TEST_LEVEL
|
||||
from plone.testing import layered
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Test plone.app.discussion workflow and permissions.
|
||||
"""
|
||||
from AccessControl import Unauthorized
|
||||
@@ -128,7 +127,7 @@ class CommentOneStateWorkflowTest(unittest.TestCase):
|
||||
cid = conversation.addComment(comment)
|
||||
|
||||
self.comment = self.folder.doc1.restrictedTraverse(
|
||||
"++conversation++default/{0}".format(cid),
|
||||
f"++conversation++default/{cid}",
|
||||
)
|
||||
|
||||
self.portal.acl_users._doAddUser("member", "secret", ["Member"], [])
|
||||
@@ -223,7 +222,7 @@ class CommentReviewWorkflowTest(unittest.TestCase):
|
||||
comment.text = "Comment text"
|
||||
comment_id = conversation.addComment(comment)
|
||||
comment = self.portal.doc1.restrictedTraverse(
|
||||
"++conversation++default/{0}".format(comment_id),
|
||||
f"++conversation++default/{comment_id}",
|
||||
)
|
||||
|
||||
self.conversation = conversation
|
||||
|
||||
Reference in New Issue
Block a user