Pep8
This commit is contained in:
parent
69b628c386
commit
a6afdf265c
@ -114,9 +114,11 @@ class CommentTest(unittest.TestCase):
|
||||
self.assertEqual("Anonymous on Document 1", comment1.Title())
|
||||
|
||||
def test_title_special_characters(self):
|
||||
self.portal.invokeFactory(id='doc_sp_chars',
|
||||
self.portal.invokeFactory(
|
||||
id='doc_sp_chars',
|
||||
title=u'Document äüö',
|
||||
type_name='Document')
|
||||
type_name='Document'
|
||||
)
|
||||
conversation = IConversation(self.portal.doc_sp_chars)
|
||||
comment1 = createObject('plone.Comment')
|
||||
comment1.author_name = u"Tarek Ziadé"
|
||||
@ -141,41 +143,53 @@ class CommentTest(unittest.TestCase):
|
||||
comment1.text = """First paragraph
|
||||
|
||||
Second paragraph"""
|
||||
self.assertEqual(comment1.getText(),
|
||||
"<p>First paragraph<br /><br /> Second paragraph</p>")
|
||||
self.assertEqual(
|
||||
comment1.getText(),
|
||||
"<p>First paragraph<br /><br /> Second paragraph</p>"
|
||||
)
|
||||
|
||||
def test_getText_escapes_HTML(self):
|
||||
comment1 = createObject('plone.Comment')
|
||||
comment1.text = """<b>Got HTML?</b>"""
|
||||
self.assertEqual(comment1.getText(),
|
||||
"<p><b>Got HTML?</b></p>")
|
||||
self.assertEqual(
|
||||
comment1.getText(),
|
||||
"<p><b>Got HTML?</b></p>"
|
||||
)
|
||||
|
||||
def test_getText_with_non_ascii_characters(self):
|
||||
comment1 = createObject('plone.Comment')
|
||||
comment1.text = u"""Umlaute sind ä, ö und ü."""
|
||||
self.assertEqual(comment1.getText(),
|
||||
'<p>Umlaute sind \xc3\xa4, \xc3\xb6 und \xc3\xbc.</p>')
|
||||
self.assertEqual(
|
||||
comment1.getText(),
|
||||
'<p>Umlaute sind \xc3\xa4, \xc3\xb6 und \xc3\xbc.</p>'
|
||||
)
|
||||
|
||||
def test_getText_doesnt_link(self):
|
||||
comment1 = createObject('plone.Comment')
|
||||
comment1.text = "Go to http://www.plone.org"
|
||||
self.assertEqual(comment1.getText(),
|
||||
"<p>Go to http://www.plone.org</p>")
|
||||
self.assertEqual(
|
||||
comment1.getText(),
|
||||
"<p>Go to http://www.plone.org</p>"
|
||||
)
|
||||
|
||||
def test_getText_uses_comment_mime_type(self):
|
||||
comment1 = createObject('plone.Comment')
|
||||
comment1.text = "Go to http://www.plone.org"
|
||||
comment1.mime_type = 'text/x-web-intelligent'
|
||||
self.assertEqual(comment1.getText(),
|
||||
self.assertEqual(
|
||||
comment1.getText(),
|
||||
'Go to <a href="http://www.plone.org" ' +
|
||||
'rel="nofollow">http://www.plone.org</a>')
|
||||
'rel="nofollow">http://www.plone.org</a>'
|
||||
)
|
||||
|
||||
def test_getText_uses_comment_mime_type_html(self):
|
||||
comment1 = createObject('plone.Comment')
|
||||
comment1.text = 'Go to <a href="http://www.plone.org">plone.org</a>'
|
||||
comment1.mime_type = 'text/html'
|
||||
self.assertEqual(comment1.getText(),
|
||||
'Go to <a href="http://www.plone.org">plone.org</a>')
|
||||
self.assertEqual(
|
||||
comment1.getText(),
|
||||
'Go to <a href="http://www.plone.org">plone.org</a>'
|
||||
)
|
||||
|
||||
def test_getText_w_custom_targetMimetype(self):
|
||||
comment1 = createObject('plone.Comment')
|
||||
@ -207,19 +221,28 @@ class CommentTest(unittest.TestCase):
|
||||
'++conversation++default/%s' % new_comment1_id)
|
||||
self.assertTrue(IComment.providedBy(comment))
|
||||
|
||||
self.assertEqual(('', 'plone', 'doc1', '++conversation++default',
|
||||
str(new_comment1_id)), comment.getPhysicalPath())
|
||||
self.assertEqual('http://nohost/plone/doc1/++conversation++default/' +
|
||||
str(new_comment1_id), comment.absolute_url())
|
||||
self.assertEqual(
|
||||
(
|
||||
'', 'plone', 'doc1', '++conversation++default',
|
||||
str(new_comment1_id)
|
||||
),
|
||||
comment.getPhysicalPath()
|
||||
)
|
||||
self.assertEqual(
|
||||
'http://nohost/plone/doc1/++conversation++default/' +
|
||||
str(new_comment1_id), comment.absolute_url()
|
||||
)
|
||||
|
||||
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.
|
||||
"""
|
||||
self.portal.invokeFactory(id='image1',
|
||||
self.portal.invokeFactory(
|
||||
id='image1',
|
||||
title='Image',
|
||||
type_name='Image')
|
||||
type_name='Image'
|
||||
)
|
||||
conversation = IConversation(self.portal.image1)
|
||||
|
||||
comment1 = createObject('plone.Comment')
|
||||
@ -251,18 +274,26 @@ class CommentTest(unittest.TestCase):
|
||||
self.assertEqual(('comment_review_workflow',), chain)
|
||||
|
||||
# Ensure the initial state was entered and recorded
|
||||
self.assertEqual(1,
|
||||
len(comment.workflow_history['comment_review_workflow']))
|
||||
self.assertEqual(None,
|
||||
comment.workflow_history['comment_review_workflow'][0]['action'])
|
||||
self.assertEqual('pending',
|
||||
self.portal.portal_workflow.getInfoFor(comment, 'review_state'))
|
||||
self.assertEqual(
|
||||
1,
|
||||
len(comment.workflow_history['comment_review_workflow'])
|
||||
)
|
||||
self.assertEqual(
|
||||
None,
|
||||
comment.workflow_history['comment_review_workflow'][0]['action']
|
||||
)
|
||||
self.assertEqual(
|
||||
'pending',
|
||||
self.portal.portal_workflow.getInfoFor(comment, 'review_state')
|
||||
)
|
||||
|
||||
def test_fti(self):
|
||||
# test that we can look up an FTI for Discussion Item
|
||||
|
||||
self.assertTrue("Discussion Item" in
|
||||
self.portal.portal_types.objectIds())
|
||||
self.assertTrue(
|
||||
"Discussion Item" in
|
||||
self.portal.portal_types.objectIds()
|
||||
)
|
||||
|
||||
comment1 = createObject('plone.Comment')
|
||||
|
||||
@ -307,9 +338,11 @@ class RepliesTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.portal = self.layer['portal']
|
||||
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
||||
self.portal.invokeFactory(id='doc1',
|
||||
self.portal.invokeFactory(
|
||||
id='doc1',
|
||||
title='Document 1',
|
||||
type_name='Document')
|
||||
type_name='Document'
|
||||
)
|
||||
|
||||
def test_add_comment(self):
|
||||
# Add comments to a CommentReplies adapter
|
||||
@ -404,7 +437,8 @@ class RepliesTest(unittest.TestCase):
|
||||
replies = IReplies(comment)
|
||||
new_re_id = replies.addComment(re_comment)
|
||||
re_comment = self.portal.doc1.restrictedTraverse(
|
||||
'++conversation++default/%s' % new_re_id)
|
||||
'++conversation++default/%s' % new_re_id
|
||||
)
|
||||
|
||||
# Add a reply to the reply
|
||||
re_re_comment = createObject('plone.Comment')
|
||||
@ -412,7 +446,8 @@ 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/%s' % new_re_re_id)
|
||||
'++conversation++default/%s' % new_re_re_id
|
||||
)
|
||||
|
||||
# Add a reply to the replies reply
|
||||
re_re_re_comment = createObject('plone.Comment')
|
||||
@ -422,24 +457,47 @@ class RepliesTest(unittest.TestCase):
|
||||
re_re_re_comment = self.portal.doc1.restrictedTraverse(
|
||||
'++conversation++default/%s' % new_re_re_re_id)
|
||||
|
||||
self.assertEqual(('', 'plone', 'doc1', '++conversation++default',
|
||||
str(new_id)), comment.getPhysicalPath())
|
||||
self.assertEqual('http://nohost/plone/doc1/++conversation++default/' +
|
||||
str(new_id), comment.absolute_url())
|
||||
self.assertEqual(('', 'plone', 'doc1', '++conversation++default',
|
||||
str(new_re_id)), re_comment.getPhysicalPath())
|
||||
self.assertEqual('http://nohost/plone/doc1/++conversation++default/' +
|
||||
str(new_re_id), re_comment.absolute_url())
|
||||
self.assertEqual(('', 'plone', 'doc1', '++conversation++default',
|
||||
str(new_re_re_id)), re_re_comment.getPhysicalPath())
|
||||
self.assertEqual('http://nohost/plone/doc1/++conversation++default/' +
|
||||
str(new_re_re_id), re_re_comment.absolute_url())
|
||||
self.assertEqual(('', 'plone', 'doc1', '++conversation++default',
|
||||
str(new_re_re_re_id)),
|
||||
re_re_re_comment.getPhysicalPath())
|
||||
self.assertEqual('http://nohost/plone/doc1/++conversation++default/' +
|
||||
self.assertEqual(
|
||||
('', 'plone', 'doc1', '++conversation++default', str(new_id)),
|
||||
comment.getPhysicalPath()
|
||||
)
|
||||
self.assertEqual(
|
||||
'http://nohost/plone/doc1/++conversation++default/' +
|
||||
str(new_id), comment.absolute_url()
|
||||
)
|
||||
self.assertEqual(
|
||||
('', 'plone', 'doc1', '++conversation++default', str(new_re_id)),
|
||||
re_comment.getPhysicalPath()
|
||||
)
|
||||
self.assertEqual(
|
||||
'http://nohost/plone/doc1/++conversation++default/' +
|
||||
str(new_re_id),
|
||||
re_comment.absolute_url()
|
||||
)
|
||||
self.assertEqual(
|
||||
(
|
||||
'', 'plone', 'doc1', '++conversation++default',
|
||||
str(new_re_re_id)
|
||||
),
|
||||
re_re_comment.getPhysicalPath()
|
||||
)
|
||||
self.assertEqual(
|
||||
'http://nohost/plone/doc1/++conversation++default/' +
|
||||
str(new_re_re_id),
|
||||
re_re_comment.absolute_url()
|
||||
)
|
||||
self.assertEqual(
|
||||
(
|
||||
'', 'plone', 'doc1', '++conversation++default',
|
||||
str(new_re_re_re_id)
|
||||
),
|
||||
re_re_re_comment.getPhysicalPath()
|
||||
)
|
||||
self.assertEqual(
|
||||
'http://nohost/plone/doc1/++conversation++default/' +
|
||||
str(new_re_re_re_id),
|
||||
re_re_re_comment.absolute_url())
|
||||
re_re_re_comment.absolute_url()
|
||||
)
|
||||
|
||||
|
||||
def test_suite():
|
||||
|
Loading…
Reference in New Issue
Block a user