2015-05-03 08:16:39 +02:00
|
|
|
from plone.app.discussion.browser.comment import View
|
|
|
|
from plone.app.discussion.interfaces import IComment
|
|
|
|
from plone.app.discussion.interfaces import IConversation
|
|
|
|
from plone.app.discussion.interfaces import IReplies
|
2022-05-01 23:27:37 +02:00
|
|
|
from plone.app.discussion.testing import PLONE_APP_DISCUSSION_INTEGRATION_TESTING
|
2015-05-03 08:16:39 +02:00
|
|
|
from plone.app.testing import setRoles
|
|
|
|
from plone.app.testing import TEST_USER_ID
|
2016-02-05 01:39:53 +01:00
|
|
|
from Products.CMFCore.utils import getToolByName
|
2009-05-18 17:15:36 +02:00
|
|
|
from zope.component import createObject
|
2010-11-28 11:00:31 +01:00
|
|
|
from zope.component import getMultiAdapter
|
2010-11-28 10:51:35 +01:00
|
|
|
|
2015-05-03 08:16:39 +02:00
|
|
|
import datetime
|
|
|
|
import logging
|
2017-05-08 09:24:38 +02:00
|
|
|
import unittest
|
2010-09-03 23:23:44 +02:00
|
|
|
|
2010-09-02 22:00:43 +02:00
|
|
|
|
2022-05-01 23:14:09 +02:00
|
|
|
logger = logging.getLogger("plone.app.discussion.tests")
|
2010-09-07 14:02:55 +02:00
|
|
|
logger.addHandler(logging.StreamHandler())
|
|
|
|
|
2012-01-09 16:43:54 +01:00
|
|
|
|
Test-only fix: normalize white space when comparing output of comment.getText().
Needed to not fail with newer `plone.outputfilters` from this PR: https://github.com/plone/plone.outputfilters/pull/49
Comments go through the outputfilters, and the new branch calls `soup.prettify()` from `Beautifulsoup`, leading to more white space.
Sample test failures on Jenkins, see https://jenkins.plone.org/job/plip-plip-image-srcsets-3.8/5/#showFailuresLink
```
'<p>\n Go to http://www.plone.org\n</p>' != '<p>Go to http://www.plone.org</p>'
- <p>
- Go to http://www.plone.org
? ^ ^
+ <p>Go to http://www.plone.org</p>? ^^^ ^^^^
- </p>
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 60, in testPartExecutor
yield
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 676, in run
self._callTestMethod(testMethod)
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 633, in _callTestMethod
method()
File "/home/jenkins/.buildout/eggs/cp38/plone.app.discussion-4.0.0a7-py3.8.egg/plone/app/discussion/tests/test_comment.py", line 180, in test_getText_doesnt_link
self.assertEqual(
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 912, in assertEqual
assertion_func(first, second, msg=msg)
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 1292, in assertMultiLineEqual
self.fail(self._formatMessage(msg, standardMsg))
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 753, in fail
raise self.failureException(msg)
```
2022-06-10 13:50:16 +02:00
|
|
|
def normalize(value):
|
|
|
|
# Strip all white spaces of every line, then join on one line.
|
|
|
|
# But try to avoid getting 'Go to<a href' instead of 'Go to <a href'.
|
|
|
|
lines = []
|
|
|
|
for line in value.splitlines():
|
|
|
|
line = line.strip()
|
|
|
|
if (
|
|
|
|
line.startswith("<")
|
|
|
|
and not line.startswith("</")
|
|
|
|
and not line.startswith("<br")
|
|
|
|
):
|
|
|
|
line = " " + line
|
|
|
|
lines.append(line)
|
|
|
|
return "".join(lines).strip()
|
|
|
|
|
|
|
|
|
2011-04-16 11:16:18 +02:00
|
|
|
class CommentTest(unittest.TestCase):
|
2009-05-25 09:02:11 +02:00
|
|
|
|
2011-04-16 11:16:18 +02:00
|
|
|
layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING
|
2009-05-25 09:02:11 +02:00
|
|
|
|
2011-04-16 11:16:18 +02:00
|
|
|
def setUp(self):
|
2022-05-01 23:14:09 +02:00
|
|
|
self.portal = self.layer["portal"]
|
|
|
|
self.request = self.layer["request"]
|
2011-04-16 11:16:18 +02:00
|
|
|
|
2017-01-10 18:09:01 +01:00
|
|
|
workflow = self.portal.portal_workflow
|
2022-05-01 23:14:09 +02:00
|
|
|
workflow.doActionFor(self.portal.doc1, "publish")
|
2017-01-10 18:09:01 +01:00
|
|
|
|
2022-05-01 23:14:09 +02:00
|
|
|
setRoles(self.portal, TEST_USER_ID, ["Manager"])
|
|
|
|
self.catalog = getToolByName(self.portal, "portal_catalog")
|
|
|
|
self.document_brain = self.catalog.searchResults(portal_type="Document")[0]
|
2010-12-16 00:52:56 +01:00
|
|
|
|
2009-05-18 17:15:36 +02:00
|
|
|
def test_factory(self):
|
2022-05-01 23:14:09 +02:00
|
|
|
comment1 = createObject("plone.Comment")
|
2011-04-15 18:23:38 +02:00
|
|
|
self.assertTrue(IComment.providedBy(comment1))
|
2009-05-25 09:02:11 +02:00
|
|
|
|
2010-09-07 14:02:55 +02:00
|
|
|
def test_UTCDates(self):
|
2022-05-01 23:14:09 +02:00
|
|
|
utc_to_local_diff = datetime.datetime.now() - datetime.datetime.utcnow()
|
2010-09-07 14:02:55 +02:00
|
|
|
utc_to_local_diff = abs(utc_to_local_diff.seconds)
|
|
|
|
if utc_to_local_diff < 60:
|
2022-05-01 23:14:09 +02:00
|
|
|
logger.warning(
|
|
|
|
"Your computer is living in a timezone where local "
|
|
|
|
"time equals utc time. Some potential errors can "
|
|
|
|
"get hidden by that"
|
|
|
|
)
|
|
|
|
comment1 = createObject("plone.Comment")
|
2022-10-18 16:33:08 +02:00
|
|
|
local_utc = datetime.datetime.now().astimezone(datetime.timezone.utc)
|
2010-09-07 14:02:55 +02:00
|
|
|
for date in (comment1.creation_date, comment1.modification_date):
|
|
|
|
difference = abs(date - local_utc)
|
|
|
|
difference = difference.seconds
|
|
|
|
# We hope that between comment1 and local_utc happen less than
|
|
|
|
# 10 seconds
|
2018-06-14 20:14:02 +02:00
|
|
|
self.assertFalse(difference // 10)
|
2010-09-07 14:02:55 +02:00
|
|
|
|
2009-05-18 17:15:36 +02:00
|
|
|
def test_id(self):
|
2022-05-01 23:14:09 +02:00
|
|
|
comment1 = createObject("plone.Comment")
|
2009-05-23 13:52:57 +02:00
|
|
|
comment1.comment_id = 123
|
2022-05-01 23:14:09 +02:00
|
|
|
self.assertEqual("123", comment1.id)
|
|
|
|
self.assertEqual("123", comment1.getId())
|
2022-05-01 23:14:41 +02:00
|
|
|
self.assertEqual("123", comment1.__name__)
|
2009-05-25 09:02:11 +02:00
|
|
|
|
2010-11-28 12:39:19 +01:00
|
|
|
def test_uid(self):
|
|
|
|
conversation = IConversation(self.portal.doc1)
|
2022-05-01 23:14:09 +02:00
|
|
|
comment1 = createObject("plone.Comment")
|
2010-11-28 12:39:19 +01:00
|
|
|
conversation.addComment(comment1)
|
|
|
|
comment_brain = self.catalog.searchResults(
|
2022-05-01 23:14:09 +02:00
|
|
|
portal_type="Discussion Item",
|
2013-01-10 18:33:46 +01:00
|
|
|
)[0]
|
2011-04-15 18:23:38 +02:00
|
|
|
self.assertTrue(comment_brain.UID)
|
2010-12-16 00:52:56 +01:00
|
|
|
|
2010-11-28 12:39:19 +01:00
|
|
|
def test_uid_is_unique(self):
|
2010-12-15 21:39:55 +01:00
|
|
|
conversation = IConversation(self.portal.doc1)
|
2022-05-01 23:14:09 +02:00
|
|
|
comment1 = createObject("plone.Comment")
|
2010-11-28 12:39:19 +01:00
|
|
|
conversation.addComment(comment1)
|
2022-05-01 23:14:09 +02:00
|
|
|
comment2 = createObject("plone.Comment")
|
2010-11-28 12:39:19 +01:00
|
|
|
conversation.addComment(comment2)
|
|
|
|
brains = self.catalog.searchResults(
|
2022-05-01 23:14:09 +02:00
|
|
|
portal_type="Discussion Item",
|
2013-01-10 18:33:46 +01:00
|
|
|
)
|
2011-04-15 18:23:38 +02:00
|
|
|
self.assertNotEqual(brains[0].UID, brains[1].UID)
|
2010-12-16 00:52:56 +01:00
|
|
|
|
2010-11-28 12:39:19 +01:00
|
|
|
def test_comment_uid_differs_from_content_uid(self):
|
2010-12-15 21:39:55 +01:00
|
|
|
conversation = IConversation(self.portal.doc1)
|
2022-05-01 23:14:09 +02:00
|
|
|
comment1 = createObject("plone.Comment")
|
2010-11-28 12:39:19 +01:00
|
|
|
conversation.addComment(comment1)
|
|
|
|
comment_brain = self.catalog.searchResults(
|
2022-05-01 23:14:09 +02:00
|
|
|
portal_type="Discussion Item",
|
2013-01-10 18:33:46 +01:00
|
|
|
)[0]
|
2011-04-15 18:23:38 +02:00
|
|
|
self.assertNotEqual(self.document_brain.UID, comment_brain.UID)
|
2010-11-28 12:39:19 +01:00
|
|
|
|
2009-05-18 17:15:36 +02:00
|
|
|
def test_title(self):
|
2010-10-22 11:57:55 +02:00
|
|
|
conversation = IConversation(self.portal.doc1)
|
2022-05-01 23:14:09 +02:00
|
|
|
comment1 = createObject("plone.Comment")
|
|
|
|
comment1.author_name = "Jim Fulton"
|
2010-09-29 09:56:36 +02:00
|
|
|
conversation.addComment(comment1)
|
2022-05-01 23:14:09 +02:00
|
|
|
self.assertEqual("Jim Fulton on Document 1", comment1.Title())
|
2010-09-29 12:52:11 +02:00
|
|
|
|
|
|
|
def test_no_name_title(self):
|
2010-10-22 11:57:55 +02:00
|
|
|
conversation = IConversation(self.portal.doc1)
|
2022-05-01 23:14:09 +02:00
|
|
|
comment1 = createObject("plone.Comment")
|
2010-09-29 12:52:11 +02:00
|
|
|
conversation.addComment(comment1)
|
2022-05-01 23:14:09 +02:00
|
|
|
self.assertEqual("Anonymous on Document 1", comment1.Title())
|
2010-09-29 12:52:11 +02:00
|
|
|
|
2010-10-02 20:16:49 +02:00
|
|
|
def test_title_special_characters(self):
|
2013-01-10 18:40:04 +01:00
|
|
|
self.portal.invokeFactory(
|
2022-05-01 23:14:09 +02:00
|
|
|
id="doc_sp_chars",
|
2022-05-01 23:14:41 +02:00
|
|
|
title="Document äüö",
|
2022-05-01 23:14:09 +02:00
|
|
|
type_name="Document",
|
2013-01-10 18:40:04 +01:00
|
|
|
)
|
2010-10-22 11:57:55 +02:00
|
|
|
conversation = IConversation(self.portal.doc_sp_chars)
|
2022-05-01 23:14:09 +02:00
|
|
|
comment1 = createObject("plone.Comment")
|
2022-05-01 23:14:41 +02:00
|
|
|
comment1.author_name = "Tarek Ziadé"
|
2010-10-02 20:16:49 +02:00
|
|
|
conversation.addComment(comment1)
|
2022-05-01 23:14:41 +02:00
|
|
|
self.assertEqual("Tarek Ziadé on Document äüö", comment1.Title())
|
2010-10-22 11:57:55 +02:00
|
|
|
|
2013-09-20 16:28:05 +02:00
|
|
|
def test_title_special_characters_utf8(self):
|
|
|
|
self.portal.invokeFactory(
|
2022-05-01 23:14:09 +02:00
|
|
|
id="doc_sp_chars_utf8",
|
|
|
|
title="Document ëïû",
|
|
|
|
type_name="Document",
|
2013-09-20 16:28:05 +02:00
|
|
|
)
|
|
|
|
conversation = IConversation(self.portal.doc_sp_chars_utf8)
|
2022-05-01 23:14:09 +02:00
|
|
|
comment1 = createObject("plone.Comment")
|
|
|
|
comment1.author_name = "Hüüb Bôûmä"
|
2013-09-20 16:28:05 +02:00
|
|
|
conversation.addComment(comment1)
|
2022-05-01 23:14:41 +02:00
|
|
|
self.assertEqual("Hüüb Bôûmä on Document ëïû", comment1.Title())
|
2013-09-20 16:28:05 +02:00
|
|
|
|
2009-05-18 17:15:36 +02:00
|
|
|
def test_creator(self):
|
2022-05-01 23:14:09 +02:00
|
|
|
comment1 = createObject("plone.Comment")
|
|
|
|
comment1.creator = "jim"
|
|
|
|
self.assertEqual("jim", comment1.Creator())
|
2009-05-25 09:02:11 +02:00
|
|
|
|
2013-09-17 14:03:46 +02:00
|
|
|
def test_creator_author_name(self):
|
2022-05-01 23:14:09 +02:00
|
|
|
comment1 = createObject("plone.Comment")
|
|
|
|
comment1.author_name = "joey"
|
|
|
|
self.assertEqual("joey", comment1.Creator())
|
2013-09-17 14:03:46 +02:00
|
|
|
|
|
|
|
def test_owner(self):
|
2022-05-01 23:14:09 +02:00
|
|
|
comment1 = createObject("plone.Comment")
|
|
|
|
self.assertEqual(
|
|
|
|
(["plone", "acl_users"], TEST_USER_ID), comment1.getOwnerTuple()
|
|
|
|
)
|
2013-09-17 14:03:46 +02:00
|
|
|
|
2009-06-22 14:23:19 +02:00
|
|
|
def test_type(self):
|
2022-05-01 23:14:09 +02:00
|
|
|
comment1 = createObject("plone.Comment")
|
|
|
|
self.assertEqual(comment1.Type(), "Comment")
|
2009-06-22 14:23:19 +02:00
|
|
|
|
2012-06-17 12:09:25 +02:00
|
|
|
def test_mime_type(self):
|
2022-05-01 23:14:09 +02:00
|
|
|
comment1 = createObject("plone.Comment")
|
|
|
|
self.assertEqual(comment1.mime_type, "text/plain")
|
2012-06-17 12:09:25 +02:00
|
|
|
|
2011-04-02 21:51:37 +02:00
|
|
|
def test_getText(self):
|
2022-05-01 23:14:09 +02:00
|
|
|
comment1 = createObject("plone.Comment")
|
|
|
|
comment1.text = "First paragraph\n\nSecond_paragraph"
|
2013-01-10 18:40:04 +01:00
|
|
|
self.assertEqual(
|
Test-only fix: normalize white space when comparing output of comment.getText().
Needed to not fail with newer `plone.outputfilters` from this PR: https://github.com/plone/plone.outputfilters/pull/49
Comments go through the outputfilters, and the new branch calls `soup.prettify()` from `Beautifulsoup`, leading to more white space.
Sample test failures on Jenkins, see https://jenkins.plone.org/job/plip-plip-image-srcsets-3.8/5/#showFailuresLink
```
'<p>\n Go to http://www.plone.org\n</p>' != '<p>Go to http://www.plone.org</p>'
- <p>
- Go to http://www.plone.org
? ^ ^
+ <p>Go to http://www.plone.org</p>? ^^^ ^^^^
- </p>
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 60, in testPartExecutor
yield
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 676, in run
self._callTestMethod(testMethod)
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 633, in _callTestMethod
method()
File "/home/jenkins/.buildout/eggs/cp38/plone.app.discussion-4.0.0a7-py3.8.egg/plone/app/discussion/tests/test_comment.py", line 180, in test_getText_doesnt_link
self.assertEqual(
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 912, in assertEqual
assertion_func(first, second, msg=msg)
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 1292, in assertMultiLineEqual
self.fail(self._formatMessage(msg, standardMsg))
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 753, in fail
raise self.failureException(msg)
```
2022-06-10 13:50:16 +02:00
|
|
|
normalize(comment1.getText()),
|
|
|
|
"<p>First paragraph<br><br>Second_paragraph</p>",
|
2013-01-10 18:40:04 +01:00
|
|
|
)
|
2012-01-09 16:43:54 +01:00
|
|
|
|
2011-04-02 21:51:37 +02:00
|
|
|
def test_getText_escapes_HTML(self):
|
2022-05-01 23:14:09 +02:00
|
|
|
comment1 = createObject("plone.Comment")
|
|
|
|
comment1.text = "<b>Got HTML?</b>"
|
2013-01-10 18:40:04 +01:00
|
|
|
self.assertEqual(
|
Test-only fix: normalize white space when comparing output of comment.getText().
Needed to not fail with newer `plone.outputfilters` from this PR: https://github.com/plone/plone.outputfilters/pull/49
Comments go through the outputfilters, and the new branch calls `soup.prettify()` from `Beautifulsoup`, leading to more white space.
Sample test failures on Jenkins, see https://jenkins.plone.org/job/plip-plip-image-srcsets-3.8/5/#showFailuresLink
```
'<p>\n Go to http://www.plone.org\n</p>' != '<p>Go to http://www.plone.org</p>'
- <p>
- Go to http://www.plone.org
? ^ ^
+ <p>Go to http://www.plone.org</p>? ^^^ ^^^^
- </p>
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 60, in testPartExecutor
yield
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 676, in run
self._callTestMethod(testMethod)
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 633, in _callTestMethod
method()
File "/home/jenkins/.buildout/eggs/cp38/plone.app.discussion-4.0.0a7-py3.8.egg/plone/app/discussion/tests/test_comment.py", line 180, in test_getText_doesnt_link
self.assertEqual(
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 912, in assertEqual
assertion_func(first, second, msg=msg)
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 1292, in assertMultiLineEqual
self.fail(self._formatMessage(msg, standardMsg))
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 753, in fail
raise self.failureException(msg)
```
2022-06-10 13:50:16 +02:00
|
|
|
normalize(comment1.getText()),
|
2022-05-01 23:14:09 +02:00
|
|
|
"<p><b>Got HTML?</b></p>",
|
2013-01-10 18:40:04 +01:00
|
|
|
)
|
2012-01-09 16:43:54 +01:00
|
|
|
|
2011-04-02 21:51:37 +02:00
|
|
|
def test_getText_with_non_ascii_characters(self):
|
2022-05-01 23:14:09 +02:00
|
|
|
comment1 = createObject("plone.Comment")
|
2022-05-01 23:14:41 +02:00
|
|
|
comment1.text = "Umlaute sind ä, ö und ü."
|
2022-05-01 23:14:09 +02:00
|
|
|
out = b"<p>Umlaute sind \xc3\xa4, \xc3\xb6 und \xc3\xbc.</p>"
|
Test-only fix: normalize white space when comparing output of comment.getText().
Needed to not fail with newer `plone.outputfilters` from this PR: https://github.com/plone/plone.outputfilters/pull/49
Comments go through the outputfilters, and the new branch calls `soup.prettify()` from `Beautifulsoup`, leading to more white space.
Sample test failures on Jenkins, see https://jenkins.plone.org/job/plip-plip-image-srcsets-3.8/5/#showFailuresLink
```
'<p>\n Go to http://www.plone.org\n</p>' != '<p>Go to http://www.plone.org</p>'
- <p>
- Go to http://www.plone.org
? ^ ^
+ <p>Go to http://www.plone.org</p>? ^^^ ^^^^
- </p>
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 60, in testPartExecutor
yield
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 676, in run
self._callTestMethod(testMethod)
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 633, in _callTestMethod
method()
File "/home/jenkins/.buildout/eggs/cp38/plone.app.discussion-4.0.0a7-py3.8.egg/plone/app/discussion/tests/test_comment.py", line 180, in test_getText_doesnt_link
self.assertEqual(
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 912, in assertEqual
assertion_func(first, second, msg=msg)
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 1292, in assertMultiLineEqual
self.fail(self._formatMessage(msg, standardMsg))
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 753, in fail
raise self.failureException(msg)
```
2022-06-10 13:50:16 +02:00
|
|
|
self.assertEqual(normalize(comment1.getText()), out.decode("utf8"))
|
2011-04-02 21:51:37 +02:00
|
|
|
|
|
|
|
def test_getText_doesnt_link(self):
|
2022-05-01 23:14:09 +02:00
|
|
|
comment1 = createObject("plone.Comment")
|
|
|
|
comment1.text = "Go to http://www.plone.org"
|
2013-01-10 18:40:04 +01:00
|
|
|
self.assertEqual(
|
Test-only fix: normalize white space when comparing output of comment.getText().
Needed to not fail with newer `plone.outputfilters` from this PR: https://github.com/plone/plone.outputfilters/pull/49
Comments go through the outputfilters, and the new branch calls `soup.prettify()` from `Beautifulsoup`, leading to more white space.
Sample test failures on Jenkins, see https://jenkins.plone.org/job/plip-plip-image-srcsets-3.8/5/#showFailuresLink
```
'<p>\n Go to http://www.plone.org\n</p>' != '<p>Go to http://www.plone.org</p>'
- <p>
- Go to http://www.plone.org
? ^ ^
+ <p>Go to http://www.plone.org</p>? ^^^ ^^^^
- </p>
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 60, in testPartExecutor
yield
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 676, in run
self._callTestMethod(testMethod)
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 633, in _callTestMethod
method()
File "/home/jenkins/.buildout/eggs/cp38/plone.app.discussion-4.0.0a7-py3.8.egg/plone/app/discussion/tests/test_comment.py", line 180, in test_getText_doesnt_link
self.assertEqual(
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 912, in assertEqual
assertion_func(first, second, msg=msg)
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 1292, in assertMultiLineEqual
self.fail(self._formatMessage(msg, standardMsg))
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 753, in fail
raise self.failureException(msg)
```
2022-06-10 13:50:16 +02:00
|
|
|
normalize(comment1.getText()),
|
2022-05-01 23:14:09 +02:00
|
|
|
"<p>Go to http://www.plone.org</p>",
|
2013-01-10 18:40:04 +01:00
|
|
|
)
|
2012-01-09 16:43:54 +01:00
|
|
|
|
2011-04-02 21:51:37 +02:00
|
|
|
def test_getText_uses_comment_mime_type(self):
|
2022-05-01 23:14:09 +02:00
|
|
|
comment1 = createObject("plone.Comment")
|
|
|
|
comment1.text = "Go to http://www.plone.org"
|
|
|
|
comment1.mime_type = "text/x-web-intelligent"
|
2013-01-10 18:40:04 +01:00
|
|
|
self.assertEqual(
|
Test-only fix: normalize white space when comparing output of comment.getText().
Needed to not fail with newer `plone.outputfilters` from this PR: https://github.com/plone/plone.outputfilters/pull/49
Comments go through the outputfilters, and the new branch calls `soup.prettify()` from `Beautifulsoup`, leading to more white space.
Sample test failures on Jenkins, see https://jenkins.plone.org/job/plip-plip-image-srcsets-3.8/5/#showFailuresLink
```
'<p>\n Go to http://www.plone.org\n</p>' != '<p>Go to http://www.plone.org</p>'
- <p>
- Go to http://www.plone.org
? ^ ^
+ <p>Go to http://www.plone.org</p>? ^^^ ^^^^
- </p>
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 60, in testPartExecutor
yield
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 676, in run
self._callTestMethod(testMethod)
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 633, in _callTestMethod
method()
File "/home/jenkins/.buildout/eggs/cp38/plone.app.discussion-4.0.0a7-py3.8.egg/plone/app/discussion/tests/test_comment.py", line 180, in test_getText_doesnt_link
self.assertEqual(
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 912, in assertEqual
assertion_func(first, second, msg=msg)
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 1292, in assertMultiLineEqual
self.fail(self._formatMessage(msg, standardMsg))
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 753, in fail
raise self.failureException(msg)
```
2022-06-10 13:50:16 +02:00
|
|
|
normalize(comment1.getText()),
|
2022-05-01 23:14:09 +02:00
|
|
|
'Go to <a href="http://www.plone.org" '
|
|
|
|
+ 'rel="nofollow">http://www.plone.org</a>',
|
2013-01-10 18:40:04 +01:00
|
|
|
)
|
2011-04-02 21:51:37 +02:00
|
|
|
|
2012-06-15 21:15:02 +02:00
|
|
|
def test_getText_uses_comment_mime_type_html(self):
|
2022-05-01 23:14:09 +02:00
|
|
|
comment1 = createObject("plone.Comment")
|
2012-06-15 21:15:02 +02:00
|
|
|
comment1.text = 'Go to <a href="http://www.plone.org">plone.org</a>'
|
2022-05-01 23:14:09 +02:00
|
|
|
comment1.mime_type = "text/html"
|
2013-01-10 18:40:04 +01:00
|
|
|
self.assertEqual(
|
Test-only fix: normalize white space when comparing output of comment.getText().
Needed to not fail with newer `plone.outputfilters` from this PR: https://github.com/plone/plone.outputfilters/pull/49
Comments go through the outputfilters, and the new branch calls `soup.prettify()` from `Beautifulsoup`, leading to more white space.
Sample test failures on Jenkins, see https://jenkins.plone.org/job/plip-plip-image-srcsets-3.8/5/#showFailuresLink
```
'<p>\n Go to http://www.plone.org\n</p>' != '<p>Go to http://www.plone.org</p>'
- <p>
- Go to http://www.plone.org
? ^ ^
+ <p>Go to http://www.plone.org</p>? ^^^ ^^^^
- </p>
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 60, in testPartExecutor
yield
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 676, in run
self._callTestMethod(testMethod)
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 633, in _callTestMethod
method()
File "/home/jenkins/.buildout/eggs/cp38/plone.app.discussion-4.0.0a7-py3.8.egg/plone/app/discussion/tests/test_comment.py", line 180, in test_getText_doesnt_link
self.assertEqual(
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 912, in assertEqual
assertion_func(first, second, msg=msg)
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 1292, in assertMultiLineEqual
self.fail(self._formatMessage(msg, standardMsg))
File "/srv/python3.8/lib/python3.8/unittest/case.py", line 753, in fail
raise self.failureException(msg)
```
2022-06-10 13:50:16 +02:00
|
|
|
normalize(comment1.getText()),
|
2018-06-18 17:04:41 +02:00
|
|
|
'Go to <a href="http://www.plone.org">plone.org</a>',
|
2013-01-10 18:40:04 +01:00
|
|
|
)
|
2012-06-15 21:15:02 +02:00
|
|
|
|
2011-04-02 21:51:37 +02:00
|
|
|
def test_getText_w_custom_targetMimetype(self):
|
2022-05-01 23:14:09 +02:00
|
|
|
comment1 = createObject("plone.Comment")
|
|
|
|
comment1.text = "para"
|
|
|
|
self.assertEqual(comment1.getText(targetMimetype="text/plain"), "para")
|
2011-04-02 21:51:37 +02:00
|
|
|
|
2012-07-12 10:26:39 +02:00
|
|
|
def test_getText_invalid_transformation_raises_error(self):
|
|
|
|
conversation = IConversation(self.portal.doc1)
|
2022-05-01 23:14:09 +02:00
|
|
|
comment1 = createObject("plone.Comment")
|
|
|
|
comment1.mime_type = "text/x-html-safe"
|
|
|
|
comment1.text = "para"
|
2012-07-12 10:26:39 +02:00
|
|
|
conversation.addComment(comment1)
|
2022-05-01 23:14:09 +02:00
|
|
|
self.assertEqual(comment1.getText(targetMimetype="text/html"), "para")
|
2012-07-12 10:26:39 +02:00
|
|
|
|
2009-05-18 17:15:36 +02:00
|
|
|
def test_traversal(self):
|
2010-10-22 11:57:55 +02:00
|
|
|
# make sure comments are traversable, have an id, absolute_url and
|
2010-08-28 19:06:53 +02:00
|
|
|
# physical path
|
2009-05-25 09:02:11 +02:00
|
|
|
|
2009-06-18 22:57:47 +02:00
|
|
|
conversation = IConversation(self.portal.doc1)
|
2009-05-25 09:02:11 +02:00
|
|
|
|
2022-05-01 23:14:09 +02:00
|
|
|
comment1 = createObject("plone.Comment")
|
|
|
|
comment1.text = "Comment text"
|
2009-05-23 13:52:57 +02:00
|
|
|
|
|
|
|
new_comment1_id = conversation.addComment(comment1)
|
2009-05-25 09:02:11 +02:00
|
|
|
|
2010-08-28 19:06:53 +02:00
|
|
|
comment = self.portal.doc1.restrictedTraverse(
|
2022-05-01 23:14:41 +02:00
|
|
|
f"++conversation++default/{new_comment1_id}",
|
2016-02-05 01:39:53 +01:00
|
|
|
)
|
2011-04-15 18:23:38 +02:00
|
|
|
self.assertTrue(IComment.providedBy(comment))
|
2009-05-25 09:02:11 +02:00
|
|
|
|
2013-01-10 18:40:04 +01:00
|
|
|
self.assertEqual(
|
|
|
|
(
|
2022-05-01 23:14:09 +02:00
|
|
|
"",
|
|
|
|
"plone",
|
|
|
|
"doc1",
|
|
|
|
"++conversation++default",
|
2018-06-18 17:04:41 +02:00
|
|
|
str(new_comment1_id),
|
2013-01-10 18:40:04 +01:00
|
|
|
),
|
2018-06-18 17:04:41 +02:00
|
|
|
comment.getPhysicalPath(),
|
2013-01-10 18:40:04 +01:00
|
|
|
)
|
|
|
|
self.assertEqual(
|
2022-05-01 23:14:09 +02:00
|
|
|
"http://nohost/plone/doc1/++conversation++default/" + str(new_comment1_id),
|
|
|
|
comment.absolute_url(),
|
2013-01-10 18:40:04 +01:00
|
|
|
)
|
2009-05-25 09:02:11 +02:00
|
|
|
|
2012-03-14 23:01:17 +01:00
|
|
|
def test_view_blob_types(self):
|
|
|
|
"""
|
|
|
|
Make sure that traversal to images/files redirects to the
|
|
|
|
version of the url with a /view in it.
|
|
|
|
"""
|
2013-01-10 18:40:04 +01:00
|
|
|
self.portal.invokeFactory(
|
2022-05-01 23:14:09 +02:00
|
|
|
id="image1",
|
|
|
|
title="Image",
|
|
|
|
type_name="Image",
|
2013-01-10 18:40:04 +01:00
|
|
|
)
|
2012-03-14 23:01:17 +01:00
|
|
|
conversation = IConversation(self.portal.image1)
|
|
|
|
|
2022-05-01 23:14:09 +02:00
|
|
|
comment1 = createObject("plone.Comment")
|
|
|
|
comment1.text = "Comment text"
|
2012-03-14 23:01:17 +01:00
|
|
|
new_comment1_id = conversation.addComment(comment1)
|
|
|
|
comment = self.portal.image1.restrictedTraverse(
|
2022-05-01 23:14:41 +02:00
|
|
|
f"++conversation++default/{new_comment1_id}",
|
2016-02-05 01:39:53 +01:00
|
|
|
)
|
2012-03-14 23:01:17 +01:00
|
|
|
|
|
|
|
view = View(comment, self.request)
|
|
|
|
View.__call__(view)
|
|
|
|
response = self.request.response
|
2022-05-01 23:14:09 +02:00
|
|
|
self.assertIn("/view", response.headers["location"])
|
2012-03-14 23:01:17 +01:00
|
|
|
|
2009-05-18 17:15:36 +02:00
|
|
|
def test_workflow(self):
|
2022-05-01 23:14:09 +02:00
|
|
|
"""Basic test for the 'comment_review_workflow'"""
|
2010-08-28 19:06:53 +02:00
|
|
|
self.portal.portal_workflow.setChainForPortalTypes(
|
2022-05-01 23:14:09 +02:00
|
|
|
("Discussion Item",),
|
|
|
|
("comment_review_workflow,"),
|
2018-06-18 17:04:41 +02:00
|
|
|
)
|
2009-05-25 09:02:11 +02:00
|
|
|
|
2009-06-18 22:57:47 +02:00
|
|
|
conversation = IConversation(self.portal.doc1)
|
2022-05-01 23:14:09 +02:00
|
|
|
comment1 = createObject("plone.Comment")
|
2009-05-23 18:37:10 +02:00
|
|
|
new_comment1_id = conversation.addComment(comment1)
|
2009-05-25 09:02:11 +02:00
|
|
|
|
2009-05-23 18:37:10 +02:00
|
|
|
comment = conversation[new_comment1_id]
|
2009-05-25 09:02:11 +02:00
|
|
|
|
2010-10-08 13:03:14 +02:00
|
|
|
# Make sure comments use the 'comment_review_workflow'
|
2009-05-23 18:37:10 +02:00
|
|
|
chain = self.portal.portal_workflow.getChainFor(comment)
|
2022-05-01 23:14:09 +02:00
|
|
|
self.assertEqual(("comment_review_workflow",), chain)
|
2009-05-25 09:02:11 +02:00
|
|
|
|
2010-10-08 13:03:14 +02:00
|
|
|
# Ensure the initial state was entered and recorded
|
2013-01-10 18:40:04 +01:00
|
|
|
self.assertEqual(
|
|
|
|
1,
|
2022-05-01 23:14:09 +02:00
|
|
|
len(comment.workflow_history["comment_review_workflow"]),
|
2013-01-10 18:40:04 +01:00
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
None,
|
2022-05-01 23:14:09 +02:00
|
|
|
comment.workflow_history["comment_review_workflow"][0]["action"],
|
2013-01-10 18:40:04 +01:00
|
|
|
)
|
|
|
|
self.assertEqual(
|
2022-05-01 23:14:09 +02:00
|
|
|
"pending",
|
|
|
|
self.portal.portal_workflow.getInfoFor(comment, "review_state"),
|
2013-01-10 18:40:04 +01:00
|
|
|
)
|
2009-05-25 09:02:11 +02:00
|
|
|
|
2009-05-18 17:15:36 +02:00
|
|
|
def test_fti(self):
|
|
|
|
# test that we can look up an FTI for Discussion Item
|
2009-05-25 09:02:11 +02:00
|
|
|
|
2016-02-05 01:39:53 +01:00
|
|
|
self.assertIn(
|
2022-05-01 23:14:09 +02:00
|
|
|
"Discussion Item",
|
2018-06-18 17:04:41 +02:00
|
|
|
self.portal.portal_types.objectIds(),
|
2013-01-10 18:40:04 +01:00
|
|
|
)
|
2009-05-25 09:02:11 +02:00
|
|
|
|
2022-05-01 23:14:09 +02:00
|
|
|
comment1 = createObject("plone.Comment")
|
2009-05-25 09:02:11 +02:00
|
|
|
|
2009-05-23 18:12:45 +02:00
|
|
|
fti = self.portal.portal_types.getTypeInfo(comment1)
|
2022-05-01 23:14:09 +02:00
|
|
|
self.assertEqual("Discussion Item", fti.getTypeInfo(comment1).getId())
|
2009-05-18 17:15:36 +02:00
|
|
|
|
2009-05-27 19:05:12 +02:00
|
|
|
def test_view(self):
|
2010-10-22 11:57:55 +02:00
|
|
|
# make sure that the comment view is there and redirects to the right
|
2010-08-28 19:06:53 +02:00
|
|
|
# URL
|
2009-05-27 19:05:12 +02:00
|
|
|
|
|
|
|
# Create a conversation. In this case we doesn't assign it to an
|
|
|
|
# object, as we just want to check the Conversation object API.
|
|
|
|
conversation = IConversation(self.portal.doc1)
|
|
|
|
|
|
|
|
# Create a comment
|
2022-05-01 23:14:09 +02:00
|
|
|
comment1 = createObject("plone.Comment")
|
|
|
|
comment1.text = "Comment text"
|
2009-05-27 19:05:12 +02:00
|
|
|
|
|
|
|
# Add comment to the conversation
|
|
|
|
new_comment1_id = conversation.addComment(comment1)
|
|
|
|
|
2010-08-28 19:06:53 +02:00
|
|
|
comment = self.portal.doc1.restrictedTraverse(
|
2022-05-01 23:14:41 +02:00
|
|
|
f"++conversation++default/{new_comment1_id}",
|
2016-02-05 01:39:53 +01:00
|
|
|
)
|
2009-05-27 19:05:12 +02:00
|
|
|
|
|
|
|
# make sure the view is there
|
2018-06-18 17:04:41 +02:00
|
|
|
self.assertTrue(
|
|
|
|
getMultiAdapter(
|
|
|
|
(comment, self.request),
|
2022-05-01 23:14:09 +02:00
|
|
|
name="view",
|
2018-06-18 17:04:41 +02:00
|
|
|
),
|
|
|
|
)
|
2009-05-27 19:05:12 +02:00
|
|
|
|
2010-09-03 23:23:44 +02:00
|
|
|
# make sure the HTTP redirect (status code 302) works when a comment
|
|
|
|
# is called directly
|
2011-04-16 11:16:18 +02:00
|
|
|
view = View(comment, self.request)
|
2010-09-03 23:23:44 +02:00
|
|
|
View.__call__(view)
|
2011-04-16 11:16:18 +02:00
|
|
|
self.assertEqual(self.request.response.status, 302)
|
2009-05-27 19:05:12 +02:00
|
|
|
|
2010-09-02 22:00:43 +02:00
|
|
|
|
2011-04-16 11:16:18 +02:00
|
|
|
class RepliesTest(unittest.TestCase):
|
2009-05-25 09:02:11 +02:00
|
|
|
|
2009-05-18 17:15:36 +02:00
|
|
|
# test the IReplies adapter on a comment
|
2009-05-25 09:02:11 +02:00
|
|
|
|
2011-04-16 11:16:18 +02:00
|
|
|
layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING
|
2009-05-25 09:02:11 +02:00
|
|
|
|
2011-04-16 11:16:18 +02:00
|
|
|
def setUp(self):
|
2022-05-01 23:14:09 +02:00
|
|
|
self.portal = self.layer["portal"]
|
|
|
|
setRoles(self.portal, TEST_USER_ID, ["Manager"])
|
2009-05-25 09:02:11 +02:00
|
|
|
|
2017-01-10 18:09:01 +01:00
|
|
|
workflow = self.portal.portal_workflow
|
2022-05-01 23:14:09 +02:00
|
|
|
workflow.doActionFor(self.portal.doc1, "publish")
|
2017-01-10 18:09:01 +01:00
|
|
|
|
2009-05-18 17:15:36 +02:00
|
|
|
def test_add_comment(self):
|
2009-05-25 09:02:11 +02:00
|
|
|
# Add comments to a CommentReplies adapter
|
|
|
|
|
|
|
|
# Create a conversation. In this case we doesn't assign it to an
|
|
|
|
# object, as we just want to check the Conversation object API.
|
|
|
|
conversation = IConversation(self.portal.doc1)
|
|
|
|
|
|
|
|
# Add a comment to the conversation
|
|
|
|
replies = IReplies(conversation)
|
|
|
|
|
2022-05-01 23:14:09 +02:00
|
|
|
comment = createObject("plone.Comment")
|
|
|
|
comment.text = "Comment text"
|
2009-05-25 09:02:11 +02:00
|
|
|
new_id = replies.addComment(comment)
|
2010-08-28 19:06:53 +02:00
|
|
|
comment = self.portal.doc1.restrictedTraverse(
|
2022-05-01 23:14:41 +02:00
|
|
|
f"++conversation++default/{new_id}",
|
2016-02-05 01:39:53 +01:00
|
|
|
)
|
2009-05-25 09:02:11 +02:00
|
|
|
|
|
|
|
# Add a reply to the CommentReplies adapter of the first comment
|
2022-05-01 23:14:09 +02:00
|
|
|
re_comment = createObject("plone.Comment")
|
|
|
|
re_comment.text = "Comment text"
|
2009-05-25 09:02:11 +02:00
|
|
|
|
|
|
|
replies = IReplies(comment)
|
|
|
|
|
|
|
|
new_re_id = replies.addComment(re_comment)
|
|
|
|
|
|
|
|
# check that replies provides the IReplies interface
|
2011-04-15 18:23:38 +02:00
|
|
|
self.assertTrue(IReplies.providedBy(replies))
|
2009-05-25 09:02:11 +02:00
|
|
|
|
|
|
|
# Make sure our comment was added
|
2011-04-15 18:23:38 +02:00
|
|
|
self.assertTrue(new_re_id in replies)
|
2009-05-25 09:02:11 +02:00
|
|
|
|
|
|
|
# Make sure it is also reflected in the conversation
|
2011-04-15 18:23:38 +02:00
|
|
|
self.assertTrue(new_re_id in conversation)
|
2009-05-25 09:02:11 +02:00
|
|
|
|
|
|
|
# Make sure the conversation has the correct comment id
|
2011-04-15 18:23:38 +02:00
|
|
|
self.assertEqual(conversation[new_re_id].comment_id, new_re_id)
|
2009-05-25 09:02:11 +02:00
|
|
|
|
2009-05-18 17:15:36 +02:00
|
|
|
def test_delete_comment(self):
|
2009-05-25 09:08:26 +02:00
|
|
|
# Add and remove a comment to a CommentReplies adapter
|
|
|
|
|
|
|
|
# Create a conversation. In this case we doesn't assign it to an
|
|
|
|
# object, as we just want to check the Conversation object API.
|
|
|
|
conversation = IConversation(self.portal.doc1)
|
|
|
|
|
|
|
|
# Add a comment to the conversation
|
|
|
|
replies = IReplies(conversation)
|
|
|
|
|
2022-05-01 23:14:09 +02:00
|
|
|
comment = createObject("plone.Comment")
|
|
|
|
comment.text = "Comment text"
|
2009-05-25 09:08:26 +02:00
|
|
|
new_id = replies.addComment(comment)
|
2010-08-28 19:06:53 +02:00
|
|
|
comment = self.portal.doc1.restrictedTraverse(
|
2022-05-01 23:14:41 +02:00
|
|
|
f"++conversation++default/{new_id}",
|
2016-02-05 01:39:53 +01:00
|
|
|
)
|
2009-05-25 09:08:26 +02:00
|
|
|
|
|
|
|
# Add a reply to the CommentReplies adapter of the first comment
|
2022-05-01 23:14:09 +02:00
|
|
|
re_comment = createObject("plone.Comment")
|
|
|
|
re_comment.text = "Comment text"
|
2009-05-25 09:08:26 +02:00
|
|
|
|
|
|
|
replies = IReplies(comment)
|
|
|
|
|
|
|
|
new_re_id = replies.addComment(re_comment)
|
|
|
|
|
|
|
|
# Remove the reply to the CommentReplies adapter
|
|
|
|
del replies[new_re_id]
|
|
|
|
|
|
|
|
# Make sure there is no comment left in CommentReplies
|
2011-04-15 18:23:38 +02:00
|
|
|
self.assertEqual(len(replies), 0)
|
2009-05-25 09:08:26 +02:00
|
|
|
|
|
|
|
# Make sure the first comment is still in the conversation
|
2015-02-16 16:35:43 +01:00
|
|
|
self.assertEqual(conversation.total_comments(), 1)
|
2009-05-25 09:02:11 +02:00
|
|
|
|
2009-06-15 11:06:47 +02:00
|
|
|
def test_traversal(self):
|
|
|
|
# Create a nested structure of comment replies and check the traversal
|
|
|
|
|
2010-10-22 11:57:55 +02:00
|
|
|
# make sure comments are traversable, have an id, absolute_url and
|
2010-08-28 19:06:53 +02:00
|
|
|
# physical path
|
2009-06-18 22:57:47 +02:00
|
|
|
conversation = IConversation(self.portal.doc1)
|
2009-06-15 11:06:47 +02:00
|
|
|
|
2022-05-01 23:14:09 +02:00
|
|
|
comment1 = createObject("plone.Comment")
|
|
|
|
comment1.text = "Comment text"
|
2009-06-15 11:06:47 +02:00
|
|
|
|
2010-07-13 12:45:53 +02:00
|
|
|
conversation.addComment(comment1)
|
2009-06-15 11:06:47 +02:00
|
|
|
|
2022-05-01 23:14:09 +02:00
|
|
|
comment = createObject("plone.Comment")
|
|
|
|
comment.text = "Comment text"
|
2009-06-15 11:06:47 +02:00
|
|
|
new_id = conversation.addComment(comment)
|
2010-08-28 19:06:53 +02:00
|
|
|
comment = self.portal.doc1.restrictedTraverse(
|
2022-05-01 23:14:41 +02:00
|
|
|
f"++conversation++default/{new_id}",
|
2016-02-05 01:39:53 +01:00
|
|
|
)
|
2009-06-15 11:06:47 +02:00
|
|
|
|
|
|
|
# Add a reply to the CommentReplies adapter of the first comment
|
2022-05-01 23:14:09 +02:00
|
|
|
re_comment = createObject("plone.Comment")
|
|
|
|
re_comment.text = "Comment text"
|
2009-06-15 11:06:47 +02:00
|
|
|
replies = IReplies(comment)
|
|
|
|
new_re_id = replies.addComment(re_comment)
|
2010-08-28 19:06:53 +02:00
|
|
|
re_comment = self.portal.doc1.restrictedTraverse(
|
2022-05-01 23:14:41 +02:00
|
|
|
f"++conversation++default/{new_re_id}",
|
2013-01-10 18:40:04 +01:00
|
|
|
)
|
2009-06-15 11:06:47 +02:00
|
|
|
|
|
|
|
# Add a reply to the reply
|
2022-05-01 23:14:09 +02:00
|
|
|
re_re_comment = createObject("plone.Comment")
|
|
|
|
re_re_comment.text = "Comment text"
|
2009-06-15 11:06:47 +02:00
|
|
|
replies = IReplies(re_comment)
|
|
|
|
new_re_re_id = replies.addComment(re_re_comment)
|
2010-08-28 19:06:53 +02:00
|
|
|
re_re_comment = self.portal.doc1.restrictedTraverse(
|
2022-05-01 23:14:41 +02:00
|
|
|
f"++conversation++default/{new_re_re_id}",
|
2013-01-10 18:40:04 +01:00
|
|
|
)
|
2009-06-15 11:06:47 +02:00
|
|
|
|
|
|
|
# Add a reply to the replies reply
|
2022-05-01 23:14:09 +02:00
|
|
|
re_re_re_comment = createObject("plone.Comment")
|
|
|
|
re_re_re_comment.text = "Comment text"
|
2009-06-15 11:06:47 +02:00
|
|
|
replies = IReplies(re_re_comment)
|
|
|
|
new_re_re_re_id = replies.addComment(re_re_re_comment)
|
2010-08-28 19:06:53 +02:00
|
|
|
re_re_re_comment = self.portal.doc1.restrictedTraverse(
|
2022-05-01 23:14:41 +02:00
|
|
|
f"++conversation++default/{new_re_re_re_id}",
|
2016-02-05 01:39:53 +01:00
|
|
|
)
|
2010-08-28 19:06:53 +02:00
|
|
|
|
2013-01-10 18:40:04 +01:00
|
|
|
self.assertEqual(
|
2022-05-01 23:14:09 +02:00
|
|
|
("", "plone", "doc1", "++conversation++default", str(new_id)),
|
2018-06-18 17:04:41 +02:00
|
|
|
comment.getPhysicalPath(),
|
2013-01-10 18:40:04 +01:00
|
|
|
)
|
|
|
|
self.assertEqual(
|
2022-05-01 23:14:09 +02:00
|
|
|
"http://nohost/plone/doc1/++conversation++default/" + str(new_id),
|
|
|
|
comment.absolute_url(),
|
2013-01-10 18:40:04 +01:00
|
|
|
)
|
|
|
|
self.assertEqual(
|
2022-05-01 23:14:09 +02:00
|
|
|
("", "plone", "doc1", "++conversation++default", str(new_re_id)),
|
2018-06-18 17:04:41 +02:00
|
|
|
re_comment.getPhysicalPath(),
|
2013-01-10 18:40:04 +01:00
|
|
|
)
|
|
|
|
self.assertEqual(
|
2022-05-01 23:14:09 +02:00
|
|
|
"http://nohost/plone/doc1/++conversation++default/" + str(new_re_id),
|
2018-06-18 17:04:41 +02:00
|
|
|
re_comment.absolute_url(),
|
2013-01-10 18:40:04 +01:00
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
(
|
2022-05-01 23:14:09 +02:00
|
|
|
"",
|
|
|
|
"plone",
|
|
|
|
"doc1",
|
|
|
|
"++conversation++default",
|
2018-06-18 17:04:41 +02:00
|
|
|
str(new_re_re_id),
|
2013-01-10 18:40:04 +01:00
|
|
|
),
|
2018-06-18 17:04:41 +02:00
|
|
|
re_re_comment.getPhysicalPath(),
|
2013-01-10 18:40:04 +01:00
|
|
|
)
|
|
|
|
self.assertEqual(
|
2022-05-01 23:14:09 +02:00
|
|
|
"http://nohost/plone/doc1/++conversation++default/" + str(new_re_re_id),
|
2018-06-18 17:04:41 +02:00
|
|
|
re_re_comment.absolute_url(),
|
2013-01-10 18:40:04 +01:00
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
(
|
2022-05-01 23:14:09 +02:00
|
|
|
"",
|
|
|
|
"plone",
|
|
|
|
"doc1",
|
|
|
|
"++conversation++default",
|
2018-06-18 17:04:41 +02:00
|
|
|
str(new_re_re_re_id),
|
2013-01-10 18:40:04 +01:00
|
|
|
),
|
2018-06-18 17:04:41 +02:00
|
|
|
re_re_re_comment.getPhysicalPath(),
|
2013-01-10 18:40:04 +01:00
|
|
|
)
|
|
|
|
self.assertEqual(
|
2022-05-01 23:14:09 +02:00
|
|
|
"http://nohost/plone/doc1/++conversation++default/" + str(new_re_re_re_id),
|
2018-06-18 17:04:41 +02:00
|
|
|
re_re_re_comment.absolute_url(),
|
2013-01-10 18:40:04 +01:00
|
|
|
)
|