Fix whitespace/Pep8/Pyflakes in tests.
This commit is contained in:
parent
1f01a71aac
commit
e17cfa68a1
@ -16,4 +16,3 @@ plugin:
|
||||
- name: "coverage"
|
||||
jar: "../../../../parts/jstestdriver/coverage.jar"
|
||||
module: "com.google.jstestdriver.coverage.CoverageModule"
|
||||
|
@ -13,7 +13,8 @@ from Products.CMFCore.utils import getToolByName
|
||||
|
||||
from plone.app.testing import TEST_USER_ID, setRoles
|
||||
|
||||
from plone.app.discussion.testing import PLONE_APP_DISCUSSION_INTEGRATION_TESTING
|
||||
from plone.app.discussion.testing import \
|
||||
PLONE_APP_DISCUSSION_INTEGRATION_TESTING
|
||||
|
||||
from plone.app.discussion.interfaces import IConversation
|
||||
|
||||
@ -69,10 +70,10 @@ class ConversationCatalogTest(unittest.TestCase):
|
||||
self.comment_id = new_comment1_id
|
||||
|
||||
brains = self.catalog.searchResults(dict(
|
||||
path={'query':
|
||||
'/'.join(self.portal.doc1.getPhysicalPath()) },
|
||||
portal_type="Document"
|
||||
))
|
||||
path={'query':
|
||||
'/'.join(self.portal.doc1.getPhysicalPath()) },
|
||||
portal_type="Document"
|
||||
))
|
||||
self.conversation = conversation
|
||||
self.brains = brains
|
||||
self.doc1_brain = brains[0]
|
||||
@ -313,14 +314,16 @@ class CommentCatalogTest(unittest.TestCase):
|
||||
|
||||
# Make sure no old comment brains are
|
||||
brains = self.catalog.searchResults(dict(
|
||||
portal_type="Discussion Item",
|
||||
path={'query': '/'.join(self.portal.folder1.getPhysicalPath())}
|
||||
))
|
||||
portal_type="Discussion Item",
|
||||
path={'query': '/'.join(self.portal.folder1.getPhysicalPath())}
|
||||
))
|
||||
self.assertEquals(len(brains), 0)
|
||||
|
||||
brains = self.catalog.searchResults(dict(
|
||||
portal_type="Discussion Item",
|
||||
path={'query': '/'.join(self.portal.folder2.getPhysicalPath())}
|
||||
path={
|
||||
'query': '/'.join(self.portal.folder2.getPhysicalPath())
|
||||
}
|
||||
))
|
||||
self.assertEquals(len(brains), 1)
|
||||
self.assertEquals(brains[0].getPath(),
|
||||
@ -333,7 +336,8 @@ class CommentCatalogTest(unittest.TestCase):
|
||||
|
||||
self.portal.manage_renameObject("doc1", "doc2")
|
||||
|
||||
brains = self.catalog.searchResults(portal_type = 'Discussion Item')
|
||||
brains = self.catalog.searchResults(
|
||||
portal_type='Discussion Item')
|
||||
self.assertEquals(len(brains), 1)
|
||||
self.assertEquals(brains[0].getPath(),
|
||||
'/plone/doc2/++conversation++default/' +
|
||||
|
@ -13,7 +13,8 @@ from Products.CMFCore.utils import getToolByName
|
||||
|
||||
from plone.app.testing import TEST_USER_ID, setRoles
|
||||
|
||||
from plone.app.discussion.testing import PLONE_APP_DISCUSSION_INTEGRATION_TESTING
|
||||
from plone.app.discussion.testing import \
|
||||
PLONE_APP_DISCUSSION_INTEGRATION_TESTING
|
||||
|
||||
from plone.app.discussion.interfaces import IComment, IConversation, IReplies
|
||||
|
||||
@ -23,6 +24,7 @@ from plone.app.discussion.browser.comment import View
|
||||
logger = logging.getLogger('plone.app.discussion.tests')
|
||||
logger.addHandler(logging.StreamHandler())
|
||||
|
||||
|
||||
class CommentTest(unittest.TestCase):
|
||||
|
||||
layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING
|
||||
@ -37,14 +39,15 @@ class CommentTest(unittest.TestCase):
|
||||
type_name='Document')
|
||||
self.catalog = getToolByName(self.portal, 'portal_catalog')
|
||||
self.document_brain = self.catalog.searchResults(
|
||||
portal_type = 'Document')[0]
|
||||
portal_type='Document')[0]
|
||||
|
||||
def test_factory(self):
|
||||
comment1 = createObject('plone.Comment')
|
||||
self.assertTrue(IComment.providedBy(comment1))
|
||||
|
||||
def test_UTCDates(self):
|
||||
utc_to_local_diff = datetime.datetime.now() - datetime.datetime.utcnow()
|
||||
utc_to_local_diff = \
|
||||
datetime.datetime.now() - datetime.datetime.utcnow()
|
||||
utc_to_local_diff = abs(utc_to_local_diff.seconds)
|
||||
if utc_to_local_diff < 60:
|
||||
logger.warning("Your computer is living in a timezone where local "
|
||||
@ -71,7 +74,7 @@ class CommentTest(unittest.TestCase):
|
||||
comment1 = createObject('plone.Comment')
|
||||
conversation.addComment(comment1)
|
||||
comment_brain = self.catalog.searchResults(
|
||||
portal_type = 'Discussion Item')[0]
|
||||
portal_type='Discussion Item')[0]
|
||||
self.assertTrue(comment_brain.UID)
|
||||
|
||||
def test_uid_is_unique(self):
|
||||
@ -81,7 +84,7 @@ class CommentTest(unittest.TestCase):
|
||||
comment2 = createObject('plone.Comment')
|
||||
conversation.addComment(comment2)
|
||||
brains = self.catalog.searchResults(
|
||||
portal_type = 'Discussion Item')
|
||||
portal_type='Discussion Item')
|
||||
self.assertNotEqual(brains[0].UID, brains[1].UID)
|
||||
|
||||
def test_comment_uid_differs_from_content_uid(self):
|
||||
@ -89,7 +92,7 @@ class CommentTest(unittest.TestCase):
|
||||
comment1 = createObject('plone.Comment')
|
||||
conversation.addComment(comment1)
|
||||
comment_brain = self.catalog.searchResults(
|
||||
portal_type = 'Discussion Item')[0]
|
||||
portal_type='Discussion Item')[0]
|
||||
self.assertNotEqual(self.document_brain.UID, comment_brain.UID)
|
||||
|
||||
def test_title(self):
|
||||
@ -155,7 +158,7 @@ class CommentTest(unittest.TestCase):
|
||||
comment1.text = "Go to http://www.plone.org"
|
||||
comment1.mime_type = 'text/x-web-intelligent'
|
||||
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):
|
||||
comment1 = createObject('plone.Comment')
|
||||
|
@ -35,7 +35,8 @@ from plone.app.discussion.browser.comments import CommentsViewlet
|
||||
from plone.app.discussion.browser.comments import CommentForm
|
||||
from plone.app.discussion import interfaces
|
||||
from plone.app.discussion.interfaces import IConversation
|
||||
from plone.app.discussion.testing import PLONE_APP_DISCUSSION_INTEGRATION_TESTING
|
||||
from plone.app.discussion.testing import \
|
||||
PLONE_APP_DISCUSSION_INTEGRATION_TESTING
|
||||
from plone.app.discussion.interfaces import IDiscussionSettings
|
||||
|
||||
|
||||
|
@ -8,14 +8,15 @@ from zope.annotation.interfaces import IAnnotations
|
||||
from Products.CMFCore.utils import getToolByName
|
||||
|
||||
from plone.app.testing import TEST_USER_ID, setRoles
|
||||
from plone.app.testing import logout, login
|
||||
|
||||
from plone.app.discussion.testing import PLONE_APP_DISCUSSION_INTEGRATION_TESTING
|
||||
from plone.app.discussion.testing import \
|
||||
PLONE_APP_DISCUSSION_INTEGRATION_TESTING
|
||||
|
||||
from plone.app.discussion.browser.migration import View
|
||||
|
||||
from plone.app.discussion.interfaces import IConversation, IComment
|
||||
|
||||
|
||||
class MigrationTest(unittest.TestCase):
|
||||
|
||||
layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING
|
||||
@ -37,7 +38,6 @@ class MigrationTest(unittest.TestCase):
|
||||
self.workflowTool.doActionFor(self.portal.doc, 'publish')
|
||||
|
||||
self.request.set("test", True)
|
||||
context = getattr(self.portal, 'doc')
|
||||
self.view = View(self.portal, self.request)
|
||||
self.workflowTool.setChainForPortalTypes(('Discussion Item',),
|
||||
'comment_review_workflow')
|
||||
@ -80,9 +80,9 @@ class MigrationTest(unittest.TestCase):
|
||||
datetime(2003, 3, 11, 9, 28, 6))
|
||||
self.assertEqual(comment1.modification_date,
|
||||
datetime(2009, 7, 12, 19, 38, 7))
|
||||
self.assertEqual(
|
||||
[{'comment': comment1, 'depth': 0, 'id': long(comment1.id)},]
|
||||
, list(conversation.getThreads()))
|
||||
self.assertEqual([
|
||||
{'comment': comment1, 'depth': 0, 'id': long(comment1.id)}
|
||||
], list(conversation.getThreads()))
|
||||
self.assertFalse(self.doc.talkback)
|
||||
|
||||
def test_migrate_nested_comments(self):
|
||||
|
@ -47,7 +47,7 @@ class ModerationViewTest(unittest.TestCase):
|
||||
workflow implements a 'pending' state.
|
||||
"""
|
||||
# If workflow is not set, enabled must return False
|
||||
self.wf_tool.setChainForPortalTypes(('Discussion Item',),())
|
||||
self.wf_tool.setChainForPortalTypes(('Discussion Item',), ())
|
||||
self.assertEqual(self.view.moderation_enabled(), False)
|
||||
# The one_state_workflow does not have a 'pending' state
|
||||
self.wf_tool.setChainForPortalTypes(('Discussion Item',),
|
||||
@ -63,7 +63,9 @@ class ModerationViewTest(unittest.TestCase):
|
||||
discussion = getToolByName(self.portal, 'portal_discussion', None)
|
||||
discussion.overrideDiscussionFor(self.portal.doc1, 1)
|
||||
talkback = discussion.getDiscussionFor(self.portal.doc1)
|
||||
self.portal.doc1.talkback.createReply('My Title', 'My Text', Creator='Jim')
|
||||
self.portal.doc1.talkback.createReply('My Title',
|
||||
'My Text',
|
||||
Creator='Jim')
|
||||
reply = talkback.getReplies()[0]
|
||||
reply.setReplyTo(self.portal.doc1)
|
||||
reply.creation_date = DateTime(2003, 3, 11, 9, 28, 6)
|
||||
@ -79,6 +81,7 @@ class ModerationViewTest(unittest.TestCase):
|
||||
self.assertTrue('No comments to moderate' in view)
|
||||
self.assertEqual(len(self.view.comments), 0)
|
||||
|
||||
|
||||
class ModerationBulkActionsViewTest(unittest.TestCase):
|
||||
|
||||
layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING
|
||||
@ -183,5 +186,6 @@ class ModerationBulkActionsViewTest(unittest.TestCase):
|
||||
self.assertTrue(comment)
|
||||
self.assertEqual(comment, self.comment2)
|
||||
|
||||
|
||||
def test_suite():
|
||||
return unittest.defaultTestLoader.loadTestsFromName(__name__)
|
||||
|
@ -46,7 +46,7 @@ class TestUserNotificationUnit(unittest.TestCase):
|
||||
self.portal_discussion = self.portal.portal_discussion
|
||||
# Archetypes content types store data as utf-8 encoded strings
|
||||
# The missing u in front of a string is therefor not missing
|
||||
self.portal.doc1.title = 'Kölle Alaaf' # What is "Fasching"?
|
||||
self.portal.doc1.title = 'Kölle Alaaf' # What is "Fasching"?
|
||||
self.conversation = IConversation(self.portal.doc1)
|
||||
|
||||
def beforeTearDown(self):
|
||||
@ -188,7 +188,7 @@ class TestModeratorNotificationUnit(unittest.TestCase):
|
||||
self.portal_discussion = self.portal.portal_discussion
|
||||
# Archetypes content types store data as utf-8 encoded strings
|
||||
# The missing u in front of a string is therefor not missing
|
||||
self.portal.doc1.title = 'Kölle Alaaf' # What is "Fasching"?
|
||||
self.portal.doc1.title = 'Kölle Alaaf' # What is "Fasching"?
|
||||
self.conversation = IConversation(self.portal.doc1)
|
||||
|
||||
def beforeTearDown(self):
|
||||
@ -272,5 +272,6 @@ class TestModeratorNotificationUnit(unittest.TestCase):
|
||||
|
||||
self.assertEqual(len(self.mailhost.messages), 0)
|
||||
|
||||
|
||||
def test_suite():
|
||||
return unittest.defaultTestLoader.loadTestsFromName(__name__)
|
||||
|
@ -15,7 +15,8 @@ from Products.CMFCore.permissions import View
|
||||
from plone.app.testing import TEST_USER_ID, setRoles
|
||||
from plone.app.testing import logout, login
|
||||
|
||||
from plone.app.discussion.testing import PLONE_APP_DISCUSSION_INTEGRATION_TESTING
|
||||
from plone.app.discussion.testing import \
|
||||
PLONE_APP_DISCUSSION_INTEGRATION_TESTING
|
||||
from plone.app.discussion.interfaces import IConversation, IDiscussionLayer
|
||||
|
||||
|
||||
@ -125,7 +126,7 @@ class CommentOneStateWorkflowTest(unittest.TestCase):
|
||||
self.portal.acl_users._doAddUser('member', 'secret', ['Member'], [])
|
||||
self.portal.acl_users._doAddUser('reviewer', 'secret', ['Reviewer'], [])
|
||||
self.portal.acl_users._doAddUser('manager', 'secret', ['Manager'], [])
|
||||
self.portal.acl_users._doAddUser('editor' , ' secret', ['Editor'],[])
|
||||
self.portal.acl_users._doAddUser('editor', ' secret', ['Editor'], [])
|
||||
self.portal.acl_users._doAddUser('reader', 'secret', ['Reader'], [])
|
||||
|
||||
def test_initial_workflow_state(self):
|
||||
@ -163,7 +164,6 @@ class CommentReviewWorkflowTest(unittest.TestCase):
|
||||
|
||||
layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING
|
||||
|
||||
|
||||
def setUp(self):
|
||||
self.portal = self.layer['portal']
|
||||
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
||||
|
Loading…
Reference in New Issue
Block a user