Fix whitespace/Pep8/Pyflakes in tests.

This commit is contained in:
Timo Stollenwerk 2012-01-09 16:43:54 +01:00
parent 1f01a71aac
commit e17cfa68a1
10 changed files with 221 additions and 209 deletions

View File

@ -16,4 +16,3 @@ plugin:
- name: "coverage" - name: "coverage"
jar: "../../../../parts/jstestdriver/coverage.jar" jar: "../../../../parts/jstestdriver/coverage.jar"
module: "com.google.jstestdriver.coverage.CoverageModule" module: "com.google.jstestdriver.coverage.CoverageModule"

View File

@ -13,7 +13,8 @@ from Products.CMFCore.utils import getToolByName
from plone.app.testing import TEST_USER_ID, setRoles 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 from plone.app.discussion.interfaces import IConversation
@ -69,10 +70,10 @@ class ConversationCatalogTest(unittest.TestCase):
self.comment_id = new_comment1_id self.comment_id = new_comment1_id
brains = self.catalog.searchResults(dict( brains = self.catalog.searchResults(dict(
path={'query': path={'query':
'/'.join(self.portal.doc1.getPhysicalPath()) }, '/'.join(self.portal.doc1.getPhysicalPath()) },
portal_type="Document" portal_type="Document"
)) ))
self.conversation = conversation self.conversation = conversation
self.brains = brains self.brains = brains
self.doc1_brain = brains[0] self.doc1_brain = brains[0]
@ -313,14 +314,16 @@ class CommentCatalogTest(unittest.TestCase):
# Make sure no old comment brains are # Make sure no old comment brains are
brains = self.catalog.searchResults(dict( brains = self.catalog.searchResults(dict(
portal_type="Discussion Item", portal_type="Discussion Item",
path={'query': '/'.join(self.portal.folder1.getPhysicalPath())} path={'query': '/'.join(self.portal.folder1.getPhysicalPath())}
)) ))
self.assertEquals(len(brains), 0) self.assertEquals(len(brains), 0)
brains = self.catalog.searchResults(dict( brains = self.catalog.searchResults(dict(
portal_type="Discussion Item", 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(len(brains), 1)
self.assertEquals(brains[0].getPath(), self.assertEquals(brains[0].getPath(),
@ -333,7 +336,8 @@ class CommentCatalogTest(unittest.TestCase):
self.portal.manage_renameObject("doc1", "doc2") 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(len(brains), 1)
self.assertEquals(brains[0].getPath(), self.assertEquals(brains[0].getPath(),
'/plone/doc2/++conversation++default/' + '/plone/doc2/++conversation++default/' +

View File

@ -13,7 +13,8 @@ from Products.CMFCore.utils import getToolByName
from plone.app.testing import TEST_USER_ID, setRoles 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 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 = logging.getLogger('plone.app.discussion.tests')
logger.addHandler(logging.StreamHandler()) logger.addHandler(logging.StreamHandler())
class CommentTest(unittest.TestCase): class CommentTest(unittest.TestCase):
layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING
@ -37,14 +39,15 @@ class CommentTest(unittest.TestCase):
type_name='Document') type_name='Document')
self.catalog = getToolByName(self.portal, 'portal_catalog') self.catalog = getToolByName(self.portal, 'portal_catalog')
self.document_brain = self.catalog.searchResults( self.document_brain = self.catalog.searchResults(
portal_type = 'Document')[0] portal_type='Document')[0]
def test_factory(self): def test_factory(self):
comment1 = createObject('plone.Comment') comment1 = createObject('plone.Comment')
self.assertTrue(IComment.providedBy(comment1)) self.assertTrue(IComment.providedBy(comment1))
def test_UTCDates(self): def test_UTCDates(self):
utc_to_local_diff = datetime.datetime.now() - datetime.datetime.utcnow() utc_to_local_diff = \
datetime.datetime.now() - datetime.datetime.utcnow()
utc_to_local_diff = abs(utc_to_local_diff.seconds) utc_to_local_diff = abs(utc_to_local_diff.seconds)
if utc_to_local_diff < 60: if utc_to_local_diff < 60:
logger.warning("Your computer is living in a timezone where local " logger.warning("Your computer is living in a timezone where local "
@ -71,7 +74,7 @@ class CommentTest(unittest.TestCase):
comment1 = createObject('plone.Comment') comment1 = createObject('plone.Comment')
conversation.addComment(comment1) conversation.addComment(comment1)
comment_brain = self.catalog.searchResults( comment_brain = self.catalog.searchResults(
portal_type = 'Discussion Item')[0] portal_type='Discussion Item')[0]
self.assertTrue(comment_brain.UID) self.assertTrue(comment_brain.UID)
def test_uid_is_unique(self): def test_uid_is_unique(self):
@ -81,7 +84,7 @@ class CommentTest(unittest.TestCase):
comment2 = createObject('plone.Comment') comment2 = createObject('plone.Comment')
conversation.addComment(comment2) conversation.addComment(comment2)
brains = self.catalog.searchResults( brains = self.catalog.searchResults(
portal_type = 'Discussion Item') portal_type='Discussion Item')
self.assertNotEqual(brains[0].UID, brains[1].UID) self.assertNotEqual(brains[0].UID, brains[1].UID)
def test_comment_uid_differs_from_content_uid(self): def test_comment_uid_differs_from_content_uid(self):
@ -89,7 +92,7 @@ class CommentTest(unittest.TestCase):
comment1 = createObject('plone.Comment') comment1 = createObject('plone.Comment')
conversation.addComment(comment1) conversation.addComment(comment1)
comment_brain = self.catalog.searchResults( comment_brain = self.catalog.searchResults(
portal_type = 'Discussion Item')[0] portal_type='Discussion Item')[0]
self.assertNotEqual(self.document_brain.UID, comment_brain.UID) self.assertNotEqual(self.document_brain.UID, comment_brain.UID)
def test_title(self): def test_title(self):
@ -155,7 +158,7 @@ class CommentTest(unittest.TestCase):
comment1.text = "Go to http://www.plone.org" comment1.text = "Go to http://www.plone.org"
comment1.mime_type = 'text/x-web-intelligent' comment1.mime_type = 'text/x-web-intelligent'
self.assertEqual(comment1.getText(), self.assertEqual(comment1.getText(),
'Go to <a href="http://www.plone.org" rel="nofollow">http://www.plone.org</a>') 'Go to <a href="http://www.plone.org" rel="nofollow">http://www.plone.org</a>')
def test_getText_w_custom_targetMimetype(self): def test_getText_w_custom_targetMimetype(self):
comment1 = createObject('plone.Comment') comment1 = createObject('plone.Comment')

View File

@ -35,7 +35,8 @@ from plone.app.discussion.browser.comments import CommentsViewlet
from plone.app.discussion.browser.comments import CommentForm from plone.app.discussion.browser.comments import CommentForm
from plone.app.discussion import interfaces from plone.app.discussion import interfaces
from plone.app.discussion.interfaces import IConversation 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 from plone.app.discussion.interfaces import IDiscussionSettings

View File

@ -8,14 +8,15 @@ from zope.annotation.interfaces import IAnnotations
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from plone.app.testing import TEST_USER_ID, setRoles 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.browser.migration import View
from plone.app.discussion.interfaces import IConversation, IComment from plone.app.discussion.interfaces import IConversation, IComment
class MigrationTest(unittest.TestCase): class MigrationTest(unittest.TestCase):
layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING
@ -37,7 +38,6 @@ class MigrationTest(unittest.TestCase):
self.workflowTool.doActionFor(self.portal.doc, 'publish') self.workflowTool.doActionFor(self.portal.doc, 'publish')
self.request.set("test", True) self.request.set("test", True)
context = getattr(self.portal, 'doc')
self.view = View(self.portal, self.request) self.view = View(self.portal, self.request)
self.workflowTool.setChainForPortalTypes(('Discussion Item',), self.workflowTool.setChainForPortalTypes(('Discussion Item',),
'comment_review_workflow') 'comment_review_workflow')
@ -80,9 +80,9 @@ class MigrationTest(unittest.TestCase):
datetime(2003, 3, 11, 9, 28, 6)) datetime(2003, 3, 11, 9, 28, 6))
self.assertEqual(comment1.modification_date, self.assertEqual(comment1.modification_date,
datetime(2009, 7, 12, 19, 38, 7)) datetime(2009, 7, 12, 19, 38, 7))
self.assertEqual( self.assertEqual([
[{'comment': comment1, 'depth': 0, 'id': long(comment1.id)},] {'comment': comment1, 'depth': 0, 'id': long(comment1.id)}
, list(conversation.getThreads())) ], list(conversation.getThreads()))
self.assertFalse(self.doc.talkback) self.assertFalse(self.doc.talkback)
def test_migrate_nested_comments(self): def test_migrate_nested_comments(self):

View File

@ -47,7 +47,7 @@ class ModerationViewTest(unittest.TestCase):
workflow implements a 'pending' state. workflow implements a 'pending' state.
""" """
# If workflow is not set, enabled must return False # 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) self.assertEqual(self.view.moderation_enabled(), False)
# The one_state_workflow does not have a 'pending' state # The one_state_workflow does not have a 'pending' state
self.wf_tool.setChainForPortalTypes(('Discussion Item',), self.wf_tool.setChainForPortalTypes(('Discussion Item',),
@ -63,7 +63,9 @@ class ModerationViewTest(unittest.TestCase):
discussion = getToolByName(self.portal, 'portal_discussion', None) discussion = getToolByName(self.portal, 'portal_discussion', None)
discussion.overrideDiscussionFor(self.portal.doc1, 1) discussion.overrideDiscussionFor(self.portal.doc1, 1)
talkback = discussion.getDiscussionFor(self.portal.doc1) 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 = talkback.getReplies()[0]
reply.setReplyTo(self.portal.doc1) reply.setReplyTo(self.portal.doc1)
reply.creation_date = DateTime(2003, 3, 11, 9, 28, 6) reply.creation_date = DateTime(2003, 3, 11, 9, 28, 6)
@ -79,6 +81,7 @@ class ModerationViewTest(unittest.TestCase):
self.assertTrue('No comments to moderate' in view) self.assertTrue('No comments to moderate' in view)
self.assertEqual(len(self.view.comments), 0) self.assertEqual(len(self.view.comments), 0)
class ModerationBulkActionsViewTest(unittest.TestCase): class ModerationBulkActionsViewTest(unittest.TestCase):
layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING
@ -183,5 +186,6 @@ class ModerationBulkActionsViewTest(unittest.TestCase):
self.assertTrue(comment) self.assertTrue(comment)
self.assertEqual(comment, self.comment2) self.assertEqual(comment, self.comment2)
def test_suite(): def test_suite():
return unittest.defaultTestLoader.loadTestsFromName(__name__) return unittest.defaultTestLoader.loadTestsFromName(__name__)

View File

@ -46,7 +46,7 @@ class TestUserNotificationUnit(unittest.TestCase):
self.portal_discussion = self.portal.portal_discussion self.portal_discussion = self.portal.portal_discussion
# Archetypes content types store data as utf-8 encoded strings # Archetypes content types store data as utf-8 encoded strings
# The missing u in front of a string is therefor not missing # 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) self.conversation = IConversation(self.portal.doc1)
def beforeTearDown(self): def beforeTearDown(self):
@ -188,7 +188,7 @@ class TestModeratorNotificationUnit(unittest.TestCase):
self.portal_discussion = self.portal.portal_discussion self.portal_discussion = self.portal.portal_discussion
# Archetypes content types store data as utf-8 encoded strings # Archetypes content types store data as utf-8 encoded strings
# The missing u in front of a string is therefor not missing # 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) self.conversation = IConversation(self.portal.doc1)
def beforeTearDown(self): def beforeTearDown(self):
@ -272,5 +272,6 @@ class TestModeratorNotificationUnit(unittest.TestCase):
self.assertEqual(len(self.mailhost.messages), 0) self.assertEqual(len(self.mailhost.messages), 0)
def test_suite(): def test_suite():
return unittest.defaultTestLoader.loadTestsFromName(__name__) return unittest.defaultTestLoader.loadTestsFromName(__name__)

View File

@ -15,7 +15,8 @@ from Products.CMFCore.permissions import View
from plone.app.testing import TEST_USER_ID, setRoles from plone.app.testing import TEST_USER_ID, setRoles
from plone.app.testing import logout, login 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 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('member', 'secret', ['Member'], [])
self.portal.acl_users._doAddUser('reviewer', 'secret', ['Reviewer'], []) self.portal.acl_users._doAddUser('reviewer', 'secret', ['Reviewer'], [])
self.portal.acl_users._doAddUser('manager', 'secret', ['Manager'], []) 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'], []) self.portal.acl_users._doAddUser('reader', 'secret', ['Reader'], [])
def test_initial_workflow_state(self): def test_initial_workflow_state(self):
@ -163,7 +164,6 @@ class CommentReviewWorkflowTest(unittest.TestCase):
layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING
def setUp(self): def setUp(self):
self.portal = self.layer['portal'] self.portal = self.layer['portal']
setRoles(self.portal, TEST_USER_ID, ['Manager']) setRoles(self.portal, TEST_USER_ID, ['Manager'])