From 4bc77a283181db47b28f759860ee27a6ff183bcb Mon Sep 17 00:00:00 2001 From: Gil Forcada Date: Sun, 3 May 2015 08:16:39 +0200 Subject: [PATCH] Sort imports Remove unused ones as well. --- plone/app/discussion/__init__.py | 3 +- plone/app/discussion/browser/captcha.py | 34 ++++------ plone/app/discussion/browser/comment.py | 15 +++-- plone/app/discussion/browser/comments.py | 58 +++++++---------- plone/app/discussion/browser/controlpanel.py | 24 +++---- plone/app/discussion/browser/conversation.py | 13 ++-- plone/app/discussion/browser/migration.py | 24 +++---- plone/app/discussion/browser/moderation.py | 15 ++--- plone/app/discussion/browser/traversal.py | 14 ++--- plone/app/discussion/browser/validator.py | 27 ++++---- plone/app/discussion/catalog.py | 10 +-- plone/app/discussion/comment.py | 62 +++++++------------ plone/app/discussion/events.py | 6 +- plone/app/discussion/interfaces.py | 8 +-- plone/app/discussion/patches.py | 9 +-- plone/app/discussion/testing.py | 2 +- plone/app/discussion/tests/test_catalog.py | 25 +++----- plone/app/discussion/tests/test_comment.py | 28 ++++----- .../discussion/tests/test_comments_viewlet.py | 62 ++++++++----------- .../app/discussion/tests/test_contentrules.py | 22 +++---- .../app/discussion/tests/test_controlpanel.py | 20 +++--- .../app/discussion/tests/test_conversation.py | 40 ++++++------ plone/app/discussion/tests/test_events.py | 20 +++--- plone/app/discussion/tests/test_functional.py | 11 ++-- plone/app/discussion/tests/test_indexers.py | 24 +++---- .../discussion/tests/test_moderation_view.py | 20 +++--- .../discussion/tests/test_notifications.py | 26 +++----- plone/app/discussion/tests/test_robot.py | 3 +- plone/app/discussion/tests/test_workflow.py | 25 ++++---- plone/app/discussion/tool.py | 11 ++-- plone/app/discussion/upgrades.py | 5 +- plone/app/discussion/vocabularies.py | 6 +- 32 files changed, 273 insertions(+), 399 deletions(-) diff --git a/plone/app/discussion/__init__.py b/plone/app/discussion/__init__.py index 508015d..182a1d5 100644 --- a/plone/app/discussion/__init__.py +++ b/plone/app/discussion/__init__.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- - from zope.i18nmessageid import MessageFactory + + PloneAppDiscussionMessageFactory = MessageFactory('plone.app.discussion') diff --git a/plone/app/discussion/browser/captcha.py b/plone/app/discussion/browser/captcha.py index 8dd149a..0d03da3 100644 --- a/plone/app/discussion/browser/captcha.py +++ b/plone/app/discussion/browser/captcha.py @@ -1,30 +1,20 @@ # -*- coding: utf-8 -*- - # Captcha validator, see captcha.txt for design notes. - from persistent import Persistent - -from Products.CMFCore.utils import getToolByName - -from z3c.form import interfaces -from z3c.form.field import Fields - -from zope import interface - -from zope.annotation import factory - -from zope.component import adapts, queryUtility -from zope.publisher.interfaces.browser import IDefaultBrowserLayer - -from zope.interface import Interface - -from plone.registry.interfaces import IRegistry - -from plone.z3cform.fieldsets import extensible - from plone.app.discussion.browser.comments import CommentForm from plone.app.discussion.comment import Comment -from plone.app.discussion.interfaces import IDiscussionSettings, ICaptcha +from plone.app.discussion.interfaces import ICaptcha +from plone.app.discussion.interfaces import IDiscussionSettings +from plone.registry.interfaces import IRegistry +from plone.z3cform.fieldsets import extensible +from Products.CMFCore.utils import getToolByName +from z3c.form import interfaces +from z3c.form.field import Fields +from zope import interface +from zope.annotation import factory +from zope.component import adapts, queryUtility +from zope.interface import Interface +from zope.publisher.interfaces.browser import IDefaultBrowserLayer class Captcha(Persistent): diff --git a/plone/app/discussion/browser/comment.py b/plone/app/discussion/browser/comment.py index 03e0732..d17b666 100644 --- a/plone/app/discussion/browser/comment.py +++ b/plone/app/discussion/browser/comment.py @@ -1,15 +1,14 @@ -from Acquisition import aq_inner, aq_parent from AccessControl import getSecurityManager - -from zope.component import getMultiAdapter -from Products.statusmessages.interfaces import IStatusMessage -from Products.Five.browser import BrowserView +from Acquisition import aq_inner +from Acquisition import aq_parent from Products.CMFCore.utils import getToolByName - -from plone.app.discussion import PloneAppDiscussionMessageFactory as _ +from Products.Five.browser import BrowserView +from Products.statusmessages.interfaces import IStatusMessage from comments import CommentForm -from z3c.form import button +from plone.app.discussion import PloneAppDiscussionMessageFactory as _ from plone.z3cform.layout import wrap_form +from z3c.form import button +from zope.component import getMultiAdapter class View(BrowserView): diff --git a/plone/app/discussion/browser/comments.py b/plone/app/discussion/browser/comments.py index fc4a46a..3140b5e 100644 --- a/plone/app/discussion/browser/comments.py +++ b/plone/app/discussion/browser/comments.py @@ -1,47 +1,37 @@ # -*- coding: utf-8 -*- -from Acquisition import aq_inner - -from AccessControl import Unauthorized from AccessControl import getSecurityManager - -from datetime import datetime +from AccessControl import Unauthorized +from Acquisition import aq_inner from DateTime import DateTime - -from urllib import quote as url_quote - -from zope.i18n import translate -from zope.i18nmessageid import Message - -from zope.component import createObject, queryUtility - -from zope.interface import alsoProvides - -from z3c.form import form, field, button, interfaces -from z3c.form.interfaces import IFormLayer -from z3c.form.browser.checkbox import SingleCheckBoxFieldWidget - -from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile from Products.CMFCore.utils import getToolByName +from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile from Products.statusmessages.interfaces import IStatusMessage - -from plone.registry.interfaces import IRegistry - -from plone.app.layout.viewlets.common import ViewletBase - +from datetime import datetime from plone.app.discussion import PloneAppDiscussionMessageFactory as _ -from plone.app.discussion.interfaces import IConversation -from plone.app.discussion.interfaces import IComment -from plone.app.discussion.interfaces import IReplies -from plone.app.discussion.interfaces import IDiscussionSettings -from plone.app.discussion.interfaces import ICaptcha - from plone.app.discussion.browser.validator import CaptchaValidator - +from plone.app.discussion.interfaces import ICaptcha +from plone.app.discussion.interfaces import IComment +from plone.app.discussion.interfaces import IConversation +from plone.app.discussion.interfaces import IDiscussionSettings +from plone.app.discussion.interfaces import IReplies +from plone.app.layout.viewlets.common import ViewletBase +from plone.registry.interfaces import IRegistry from plone.z3cform import z2 from plone.z3cform.fieldsets import extensible - - from plone.z3cform.interfaces import IWrappedForm +from urllib import quote as url_quote +from z3c.form import button +from z3c.form import field +from z3c.form import form +from z3c.form import interfaces +from z3c.form.browser.checkbox import SingleCheckBoxFieldWidget +from z3c.form.interfaces import IFormLayer +from zope.component import createObject +from zope.component import queryUtility +from zope.i18n import translate +from zope.i18nmessageid import Message +from zope.interface import alsoProvides + COMMENT_DESCRIPTION_PLAIN_TEXT = _( u"comment_description_plain_text", diff --git a/plone/app/discussion/browser/controlpanel.py b/plone/app/discussion/browser/controlpanel.py index 9ad0bca..5317569 100644 --- a/plone/app/discussion/browser/controlpanel.py +++ b/plone/app/discussion/browser/controlpanel.py @@ -1,28 +1,22 @@ # -*- coding: utf-8 -*- -from zope.component import getUtility -from Products.CMFCore.utils import getToolByName from Products.CMFCore.interfaces._content import IDiscussionResponse +from Products.CMFCore.utils import getToolByName from Products.CMFPlone.interfaces.controlpanel import IMailSchema - from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile - from Products.statusmessages.interfaces import IStatusMessage - from plone.app.controlpanel.interfaces import IConfigurationChangedEvent - +from plone.app.discussion.interfaces import _ +from plone.app.discussion.interfaces import IDiscussionSettings +from plone.app.discussion.upgrades import update_registry from plone.app.registry.browser import controlpanel - -from plone.registry.interfaces import IRegistry from plone.registry.interfaces import IRecordModifiedEvent - -from zope.component.hooks import getSite -from zope.component import getMultiAdapter, queryUtility - +from plone.registry.interfaces import IRegistry from z3c.form import button from z3c.form.browser.checkbox import SingleCheckBoxFieldWidget - -from plone.app.discussion.interfaces import IDiscussionSettings, _ -from plone.app.discussion.upgrades import update_registry +from zope.component import getMultiAdapter +from zope.component import getUtility +from zope.component import queryUtility +from zope.component.hooks import getSite class DiscussionSettingsEditForm(controlpanel.RegistryEditForm): diff --git a/plone/app/discussion/browser/conversation.py b/plone/app/discussion/browser/conversation.py index 3e05416..e4bcecb 100644 --- a/plone/app/discussion/browser/conversation.py +++ b/plone/app/discussion/browser/conversation.py @@ -1,18 +1,13 @@ -from zope.component import queryUtility - -from plone.registry.interfaces import IRegistry - from Acquisition import aq_base from Acquisition import aq_chain from Acquisition import aq_inner - -from Products.CMFCore.utils import getToolByName from Products.CMFCore.interfaces import IFolderish - -from Products.CMFPlone.interfaces import IPloneSiteRoot +from Products.CMFCore.utils import getToolByName from Products.CMFPlone.interfaces import INonStructuralFolder - +from Products.CMFPlone.interfaces import IPloneSiteRoot from plone.app.discussion.interfaces import IDiscussionSettings +from plone.registry.interfaces import IRegistry +from zope.component import queryUtility try: from plone.dexterity.interfaces import IDexterityContent diff --git a/plone/app/discussion/browser/migration.py b/plone/app/discussion/browser/migration.py index cf615ce..2e43f4d 100644 --- a/plone/app/discussion/browser/migration.py +++ b/plone/app/discussion/browser/migration.py @@ -1,22 +1,16 @@ -from datetime import datetime - -from Acquisition import aq_inner, aq_parent - -from Products.Five.browser import BrowserView - -from Products.CMFCore.utils import getToolByName - +from Acquisition import aq_inner +from Acquisition import aq_parent +from DateTime import DateTime from Products.CMFCore.interfaces._content import IDiscussionResponse +from Products.CMFCore.utils import getToolByName +from Products.Five.browser import BrowserView +from datetime import datetime +from plone.app.discussion.comment import CommentFactory +from plone.app.discussion.interfaces import IConversation, IReplies, IComment +from types import TupleType import transaction -from plone.app.discussion.comment import CommentFactory - -from plone.app.discussion.interfaces import IConversation, IReplies, IComment - -from types import TupleType -from DateTime import DateTime - def DT2dt(DT): """Convert a Zope DateTime (with timezone) into a Python datetime (GMT).""" diff --git a/plone/app/discussion/browser/moderation.py b/plone/app/discussion/browser/moderation.py index ebdb97a..6a3a9e9 100644 --- a/plone/app/discussion/browser/moderation.py +++ b/plone/app/discussion/browser/moderation.py @@ -1,19 +1,12 @@ # -*- coding: utf-8 -*- -from Acquisition import aq_inner, aq_parent +from AccessControl import Unauthorized from AccessControl import getSecurityManager -from zope.component import queryUtility - -from AccessControl import Unauthorized, getSecurityManager - +from Acquisition import aq_inner +from Acquisition import aq_parent +from Products.CMFCore.utils import getToolByName from Products.Five.browser import BrowserView from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile - -from Products.CMFCore.utils import getToolByName - from Products.statusmessages.interfaces import IStatusMessage - -from plone.registry.interfaces import IRegistry -from plone.app.discussion.interfaces import IDiscussionSettings from plone.app.discussion.interfaces import _ from plone.app.discussion.interfaces import IComment from plone.app.discussion.interfaces import IReplies diff --git a/plone/app/discussion/browser/traversal.py b/plone/app/discussion/browser/traversal.py index e4702aa..63dcc51 100644 --- a/plone/app/discussion/browser/traversal.py +++ b/plone/app/discussion/browser/traversal.py @@ -2,14 +2,14 @@ IDiscussion container for the context, from which traversal will continue into an actual comment object. """ - -from zope.interface import Interface, implements -from zope.component import adapts, queryAdapter - -from zope.traversing.interfaces import ITraversable, TraversalError -from zope.publisher.interfaces.browser import IBrowserRequest - from plone.app.discussion.interfaces import IConversation +from zope.component import adapts +from zope.component import queryAdapter +from zope.interface import implements +from zope.interface import Interface +from zope.publisher.interfaces.browser import IBrowserRequest +from zope.traversing.interfaces import ITraversable +from zope.traversing.interfaces import TraversalError class ConversationNamespace(object): diff --git a/plone/app/discussion/browser/validator.py b/plone/app/discussion/browser/validator.py index 9c5b5dd..822dee0 100644 --- a/plone/app/discussion/browser/validator.py +++ b/plone/app/discussion/browser/validator.py @@ -1,25 +1,20 @@ # -*- coding: utf-8 -*- """Captcha validator, see captcha.txt for design notes. """ - from Acquisition import aq_inner - -from z3c.form import validator - -from z3c.form.interfaces import IValidator - -from zope.component import getMultiAdapter, queryUtility - -from zope.interface import implements, Interface - -from zope.schema.interfaces import IField -from zope.component import adapts - -from plone.registry.interfaces import IRegistry - from plone.app.discussion.interfaces import ICaptcha -from plone.app.discussion.interfaces import IDiscussionSettings from plone.app.discussion.interfaces import IDiscussionLayer +from plone.app.discussion.interfaces import IDiscussionSettings +from plone.registry.interfaces import IRegistry +from z3c.form import validator +from z3c.form.interfaces import IValidator +from zope.component import adapts +from zope.component import getMultiAdapter +from zope.component import queryUtility +from zope.interface import implements +from zope.interface import Interface +from zope.schema.interfaces import IField + try: from collective.z3cform.norobots.validator import WrongNorobotsAnswer diff --git a/plone/app/discussion/catalog.py b/plone/app/discussion/catalog.py index 5034928..3a9a4d2 100644 --- a/plone/app/discussion/catalog.py +++ b/plone/app/discussion/catalog.py @@ -3,22 +3,14 @@ indexes with values based on the IComment interface. Also provide event handlers to actually catalog the comments. """ - -from string import join - from DateTime import DateTime - from Products.CMFCore.interfaces import IContentish - from Products.CMFPlone.utils import safe_unicode - from Products.ZCatalog.interfaces import IZCatalog - from plone.app.discussion.interfaces import IConversation, IComment - from plone.indexer import indexer - from plone.uuid.interfaces import IUUID +from string import join MAX_DESCRIPTION = 25 diff --git a/plone/app/discussion/comment.py b/plone/app/discussion/comment.py index fb9c30e..97f2b17 100644 --- a/plone/app/discussion/comment.py +++ b/plone/app/discussion/comment.py @@ -1,57 +1,43 @@ # -*- coding: utf-8 -*- """The default comment class and factory. """ - -import logging - -from datetime import datetime - -from smtplib import SMTPException - -from zope.annotation.interfaces import IAnnotatable -from zope.component import getUtility - -from zope.event import notify -from zope.component.factory import Factory -from zope.component import queryUtility - -from zope.i18n import translate -from zope.i18nmessageid import Message -from zope.interface import implements - -from Acquisition import aq_parent, aq_base, Implicit - -from OFS.owner import Owned - -from persistent import Persistent - +from AccessControl import ClassSecurityInfo +from AccessControl.SecurityManagement import getSecurityManager +from Acquisition import Implicit +from Acquisition import aq_base +from Acquisition import aq_parent +from Products.CMFCore import permissions +from Products.CMFCore.CMFCatalogAware import CatalogAware +from Products.CMFCore.CMFCatalogAware import WorkflowAware from Products.CMFCore.DynamicType import DynamicType from Products.CMFCore.utils import getToolByName - +from Products.CMFPlone.interfaces.controlpanel import IMailSchema from Products.CMFPlone.utils import safe_unicode - +from datetime import datetime +from OFS.owner import Owned +from OFS.role import RoleManager from OFS.Traversable import Traversable - +from persistent import Persistent +from plone.app.discussion import PloneAppDiscussionMessageFactory as _ from plone.app.discussion.events import CommentAddedEvent from plone.app.discussion.events import CommentRemovedEvent from plone.app.discussion.events import ReplyAddedEvent from plone.app.discussion.events import ReplyRemovedEvent - -from plone.app.discussion import PloneAppDiscussionMessageFactory as _ from plone.app.discussion.interfaces import IComment from plone.app.discussion.interfaces import IConversation from plone.app.discussion.interfaces import IDiscussionSettings - from plone.registry.interfaces import IRegistry +from smtplib import SMTPException +from zope.annotation.interfaces import IAnnotatable +from zope.component import getUtility +from zope.component import queryUtility +from zope.component.factory import Factory +from zope.event import notify +from zope.i18n import translate +from zope.i18nmessageid import Message +from zope.interface import implements -from Products.CMFCore.CMFCatalogAware import CatalogAware -from Products.CMFCore.CMFCatalogAware import WorkflowAware -from Products.CMFPlone.interfaces.controlpanel import IMailSchema - -from OFS.role import RoleManager -from AccessControl import ClassSecurityInfo -from AccessControl.SecurityManagement import getSecurityManager -from Products.CMFCore import permissions +import logging COMMENT_TITLE = _( diff --git a/plone/app/discussion/events.py b/plone/app/discussion/events.py index 804077a..2ec918b 100644 --- a/plone/app/discussion/events.py +++ b/plone/app/discussion/events.py @@ -1,12 +1,12 @@ """ Custom discussion events """ -from zope.interface import implements -from plone.app.discussion.interfaces import IComment -from plone.app.discussion.interfaces import IDiscussionEvent from plone.app.discussion.interfaces import ICommentAddedEvent from plone.app.discussion.interfaces import ICommentRemovedEvent +from plone.app.discussion.interfaces import IDiscussionEvent from plone.app.discussion.interfaces import IReplyAddedEvent from plone.app.discussion.interfaces import IReplyRemovedEvent +from zope.interface import implements + class DiscussionEvent(object): """ Custom event diff --git a/plone/app/discussion/interfaces.py b/plone/app/discussion/interfaces.py index 75c70ff..20b6afe 100644 --- a/plone/app/discussion/interfaces.py +++ b/plone/app/discussion/interfaces.py @@ -1,13 +1,11 @@ # -*- coding: utf-8 -*- """Interfaces for plone.app.discussion """ - +from plone.app.discussion import PloneAppDiscussionMessageFactory as _ +from zope import schema +from zope.component.interfaces import IObjectEvent from zope.interface import Interface from zope.interface.common.mapping import IIterableMapping -from zope.component.interfaces import IObjectEvent -from zope import schema - -from plone.app.discussion import PloneAppDiscussionMessageFactory as _ class IConversation(IIterableMapping): diff --git a/plone/app/discussion/patches.py b/plone/app/discussion/patches.py index 9491702..fd0070b 100644 --- a/plone/app/discussion/patches.py +++ b/plone/app/discussion/patches.py @@ -1,13 +1,10 @@ +from Acquisition import aq_inner +from Acquisition import aq_parent from Products.CMFCore.utils import getToolByName - -from Acquisition import aq_inner, aq_parent - -from zope.annotation.interfaces import IAnnotations - from Products.CMFPlone.utils import base_hasattr from Products.CMFPlone.utils import safe_callable - from plone.app.discussion.conversation import ANNOTATION_KEY +from zope.annotation.interfaces import IAnnotations def patchedClearFindAndRebuild(self): diff --git a/plone/app/discussion/testing.py b/plone/app/discussion/testing.py index 496a1a5..9c7c41c 100644 --- a/plone/app/discussion/testing.py +++ b/plone/app/discussion/testing.py @@ -1,3 +1,4 @@ +from Products.CMFCore.utils import getToolByName from plone.app.contenttypes.testing import PLONE_APP_CONTENTTYPES_FIXTURE from plone.app.discussion.interfaces import IDiscussionSettings from plone.app.robotframework.testing import REMOTE_LIBRARY_ROBOT_TESTING @@ -8,7 +9,6 @@ from plone.app.testing import PloneSandboxLayer from plone.app.testing import setRoles from plone.app.testing import TEST_USER_ID from plone.registry.interfaces import IRegistry -from Products.CMFCore.utils import getToolByName from zope.component import queryUtility from zope.configuration import xmlconfig diff --git a/plone/app/discussion/tests/test_catalog.py b/plone/app/discussion/tests/test_catalog.py index c468242..771e833 100644 --- a/plone/app/discussion/tests/test_catalog.py +++ b/plone/app/discussion/tests/test_catalog.py @@ -1,23 +1,16 @@ """Test the plone.app.discussion catalog indexes """ -import unittest2 as unittest +from Products.CMFCore.utils import getToolByName +from datetime import datetime +from plone.app.discussion.interfaces import IConversation +from plone.app.discussion.testing import PLONE_APP_DISCUSSION_INTEGRATION_TESTING # noqa +from plone.app.testing import setRoles +from plone.app.testing import TEST_USER_ID +from zope.annotation.interfaces import IAnnotations +from zope.component import createObject import transaction - -from datetime import datetime - -from zope.component import createObject -from zope.annotation.interfaces import IAnnotations - -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.interfaces import IConversation +import unittest2 as unittest class CatalogSetupTest(unittest.TestCase): diff --git a/plone/app/discussion/tests/test_comment.py b/plone/app/discussion/tests/test_comment.py index af97864..2674ed8 100644 --- a/plone/app/discussion/tests/test_comment.py +++ b/plone/app/discussion/tests/test_comment.py @@ -1,24 +1,18 @@ # -*- coding: utf-8 -*- -import datetime - -import logging - -import unittest2 as unittest - +from Products.CMFCore.utils import getToolByName +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 +from plone.app.discussion.testing import PLONE_APP_DISCUSSION_INTEGRATION_TESTING # noqa +from plone.app.testing import setRoles +from plone.app.testing import TEST_USER_ID from zope.component import createObject - from zope.component import getMultiAdapter -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.interfaces import IComment, IConversation, IReplies - -from plone.app.discussion.browser.comment import View +import datetime +import logging +import unittest2 as unittest logger = logging.getLogger('plone.app.discussion.tests') diff --git a/plone/app/discussion/tests/test_comments_viewlet.py b/plone/app/discussion/tests/test_comments_viewlet.py index 146b773..be04bec 100644 --- a/plone/app/discussion/tests/test_comments_viewlet.py +++ b/plone/app/discussion/tests/test_comments_viewlet.py @@ -1,46 +1,36 @@ # -*- coding: utf-8 -*- -import unittest2 as unittest -import time -from datetime import datetime - from AccessControl import Unauthorized - +from datetime import datetime from OFS.Image import Image - -from zope import interface -from zope.interface import alsoProvides -from zope.publisher.browser import TestRequest -from zope.annotation.interfaces import IAttributeAnnotatable +from Products.CMFCore.utils import getToolByName +from Products.CMFPlone.tests import dummy +from plone.app.discussion import interfaces +from plone.app.discussion.browser.comment import EditCommentForm +from plone.app.discussion.browser.comments import CommentForm +from plone.app.discussion.browser.comments import CommentsViewlet +from plone.app.discussion.interfaces import IConversation +from plone.app.discussion.interfaces import IDiscussionSettings +from plone.app.discussion.testing import PLONE_APP_DISCUSSION_INTEGRATION_TESTING # noqa +from plone.app.testing import login +from plone.app.testing import logout +from plone.app.testing import setRoles +from plone.app.testing import TEST_USER_ID +from plone.app.testing import TEST_USER_NAME +from plone.registry.interfaces import IRegistry from z3c.form.interfaces import IFormLayer - +from zope import interface +from zope.annotation.interfaces import IAttributeAnnotatable +from zope.component import createObject +from zope.component import getMultiAdapter from zope.component import provideAdapter +from zope.component import queryUtility +from zope.interface import alsoProvides +from zope.interface import Interface +from zope.publisher.browser import TestRequest from zope.publisher.interfaces.browser import IBrowserRequest -from zope.interface import Interface -from zope.component import getMultiAdapter -from zope.component import createObject, queryUtility - -from plone.registry.interfaces import IRegistry - -from Products.CMFCore.utils import getToolByName - -from Products.CMFPlone.tests import dummy - -from plone.app.testing import TEST_USER_ID, TEST_USER_NAME, setRoles -from plone.app.testing import logout -from plone.app.testing import login - - -from plone.app.discussion.browser.comments import CommentsViewlet -from plone.app.discussion.browser.comments import CommentForm -from plone.app.discussion.browser.comment import EditCommentForm -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.interfaces import IDiscussionSettings -from plone.app.discussion.interfaces import IConversation +import time +import unittest2 as unittest class TestCommentForm(unittest.TestCase): diff --git a/plone/app/discussion/tests/test_contentrules.py b/plone/app/discussion/tests/test_contentrules.py index 54001cd..51e9254 100644 --- a/plone/app/discussion/tests/test_contentrules.py +++ b/plone/app/discussion/tests/test_contentrules.py @@ -1,21 +1,19 @@ # -*- coding: utf-8 -*- - -import unittest2 as unittest -from zope.component import createObject, getAdapter -from plone.app.testing import TEST_USER_ID, setRoles - -from plone.contentrules.rule.interfaces import IRuleEventType -from plone.stringinterp.interfaces import IStringSubstitution - -from plone.app.discussion.interfaces import IConversation, IReplies from plone.app.discussion.interfaces import ICommentAddedEvent from plone.app.discussion.interfaces import ICommentRemovedEvent +from plone.app.discussion.interfaces import IConversation, IReplies from plone.app.discussion.interfaces import IReplyAddedEvent from plone.app.discussion.interfaces import IReplyRemovedEvent +from plone.app.discussion.testing import PLONE_APP_DISCUSSION_INTEGRATION_TESTING # noqa +from plone.app.testing import setRoles +from plone.app.testing import TEST_USER_ID +from plone.contentrules.rule.interfaces import IRuleEventType +from plone.stringinterp.interfaces import IStringSubstitution +from zope.component import createObject +from zope.component import getAdapter + +import unittest2 as unittest -from plone.app.discussion.testing import ( - PLONE_APP_DISCUSSION_INTEGRATION_TESTING, -) class CommentContentRulesTest(unittest.TestCase): """ Test custom comments events diff --git a/plone/app/discussion/tests/test_controlpanel.py b/plone/app/discussion/tests/test_controlpanel.py index b2ded5b..24b6e03 100644 --- a/plone/app/discussion/tests/test_controlpanel.py +++ b/plone/app/discussion/tests/test_controlpanel.py @@ -1,19 +1,15 @@ # -*- coding: utf-8 -*- -import unittest2 as unittest - +from plone.app.discussion.interfaces import IDiscussionSettings +from plone.app.discussion.testing import PLONE_APP_DISCUSSION_INTEGRATION_TESTING # noqa +from plone.app.testing import setRoles +from plone.app.testing import TEST_USER_ID +from plone.registry import Registry +from plone.registry.interfaces import IRegistry +from Products.CMFCore.utils import getToolByName from zope.component import getMultiAdapter from zope.component import queryUtility -from plone.registry import Registry -from plone.registry.interfaces import IRegistry - -from Products.CMFCore.utils import getToolByName - -from plone.app.testing import TEST_USER_ID, setRoles - -from plone.app.discussion.interfaces import IDiscussionSettings -from plone.app.discussion.testing import \ - PLONE_APP_DISCUSSION_INTEGRATION_TESTING +import unittest2 as unittest class RegistryTest(unittest.TestCase): diff --git a/plone/app/discussion/tests/test_conversation.py b/plone/app/discussion/tests/test_conversation.py index cd9480f..c99915b 100644 --- a/plone/app/discussion/tests/test_conversation.py +++ b/plone/app/discussion/tests/test_conversation.py @@ -1,29 +1,25 @@ -import unittest2 as unittest -from datetime import datetime, timedelta - -from zope import interface -from zope.component import createObject, queryUtility -from zope.annotation.interfaces import IAnnotations - -from Acquisition import aq_base, aq_parent - -from plone.app.vocabularies.types import BAD_TYPES - -from plone.registry.interfaces import IRegistry - +from Acquisition import aq_base +from Acquisition import aq_parent 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 datetime import datetime +from datetime import timedelta from plone.app.discussion import interfaces -from plone.app.discussion.interfaces import IConversation from plone.app.discussion.interfaces import IComment -from plone.app.discussion.interfaces import IReplies +from plone.app.discussion.interfaces import IConversation from plone.app.discussion.interfaces import IDiscussionSettings +from plone.app.discussion.interfaces import IReplies +from plone.app.discussion.testing import PLONE_APP_DISCUSSION_INTEGRATION_TESTING # noqa +from plone.app.testing import setRoles +from plone.app.testing import TEST_USER_ID +from plone.app.vocabularies.types import BAD_TYPES +from plone.registry.interfaces import IRegistry +from zope import interface +from zope.annotation.interfaces import IAnnotations +from zope.component import createObject +from zope.component import queryUtility + +import unittest2 as unittest + try: from plone.dexterity.interfaces import IDexterityContent diff --git a/plone/app/discussion/tests/test_events.py b/plone/app/discussion/tests/test_events.py index 840bc3a..431df14 100644 --- a/plone/app/discussion/tests/test_events.py +++ b/plone/app/discussion/tests/test_events.py @@ -1,17 +1,21 @@ # -*- coding: utf-8 -*- - -import unittest2 as unittest -from zope.component import createObject from Zope2.App import zcml +from plone.app.discussion.interfaces import IConversation +from plone.app.discussion.interfaces import IReplies +from plone.app.discussion.testing import PLONE_APP_DISCUSSION_INTEGRATION_TESTING # noqa +from plone.app.testing import setRoles +from plone.app.testing import TEST_USER_ID +from zope.component import createObject + import Products.Five -from plone.app.testing import TEST_USER_ID, setRoles -from plone.app.discussion.interfaces import IConversation, IReplies -from plone.app.discussion.testing import ( - PLONE_APP_DISCUSSION_INTEGRATION_TESTING, -) +import unittest2 as unittest + + # # Fake events registry # + + class EventsRegistry(object): """ Fake registry to be used while testing discussion events """ diff --git a/plone/app/discussion/tests/test_functional.py b/plone/app/discussion/tests/test_functional.py index 98bd51f..7eb6836 100644 --- a/plone/app/discussion/tests/test_functional.py +++ b/plone/app/discussion/tests/test_functional.py @@ -3,15 +3,12 @@ These test are only triggered when Plone 4 (and plone.testing) is installed. """ -import doctest - -import unittest2 as unittest -import pprint - +from plone.app.discussion.testing import PLONE_APP_DISCUSSION_FUNCTIONAL_TESTING # noqa from plone.testing import layered -from plone.app.discussion.testing import \ - PLONE_APP_DISCUSSION_FUNCTIONAL_TESTING +import doctest +import pprint +import unittest2 as unittest optionflags = ( diff --git a/plone/app/discussion/tests/test_indexers.py b/plone/app/discussion/tests/test_indexers.py index 650db38..d21bb42 100644 --- a/plone/app/discussion/tests/test_indexers.py +++ b/plone/app/discussion/tests/test_indexers.py @@ -1,23 +1,17 @@ """Test for the plone.app.discussion indexers """ +from DateTime import DateTime +from datetime import datetime +from plone.app.discussion import catalog +from plone.app.discussion.interfaces import IConversation +from plone.app.discussion.testing import PLONE_APP_DISCUSSION_INTEGRATION_TESTING # noqa +from plone.app.testing import setRoles +from plone.app.testing import TEST_USER_ID +from plone.indexer.delegate import DelegatingIndexerFactory +from zope.component import createObject import unittest2 as unittest -from datetime import datetime -from DateTime import DateTime - -from zope.component import createObject - -from plone.app.testing import TEST_USER_ID, setRoles - -from plone.app.discussion.testing import \ - PLONE_APP_DISCUSSION_INTEGRATION_TESTING - -from plone.app.discussion.interfaces import IConversation - -from plone.indexer.delegate import DelegatingIndexerFactory - -from plone.app.discussion import catalog LONG_TEXT = """Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, diff --git a/plone/app/discussion/tests/test_moderation_view.py b/plone/app/discussion/tests/test_moderation_view.py index 5fd1735..0d38bf5 100644 --- a/plone/app/discussion/tests/test_moderation_view.py +++ b/plone/app/discussion/tests/test_moderation_view.py @@ -1,18 +1,14 @@ # -*- coding: utf-8 -*- -import unittest - +from Products.CMFCore.utils import getToolByName +from plone.app.discussion.browser.moderation import BulkActionsView +from plone.app.discussion.browser.moderation import View +from plone.app.discussion.interfaces import IConversation +from plone.app.discussion.testing import PLONE_APP_DISCUSSION_INTEGRATION_TESTING # noqa +from plone.app.testing import setRoles +from plone.app.testing import TEST_USER_ID from zope.component import createObject -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.browser.moderation import View -from plone.app.discussion.browser.moderation import BulkActionsView -from plone.app.discussion.interfaces import IConversation +import unittest class ModerationViewTest(unittest.TestCase): diff --git a/plone/app/discussion/tests/test_notifications.py b/plone/app/discussion/tests/test_notifications.py index 7a548b1..bcbd516 100644 --- a/plone/app/discussion/tests/test_notifications.py +++ b/plone/app/discussion/tests/test_notifications.py @@ -1,25 +1,19 @@ # -*- coding: utf-8 -*- - -import unittest2 as unittest - from Acquisition import aq_base - +from Products.CMFPlone.interfaces import IMailSchema +from Products.CMFPlone.tests.utils import MockMailHost +from Products.MailHost.interfaces import IMailHost +from plone.app.discussion.interfaces import IConversation +from plone.app.discussion.testing import PLONE_APP_DISCUSSION_INTEGRATION_TESTING # noqa +from plone.app.testing import TEST_USER_ID +from plone.app.testing import setRoles +from plone.registry.interfaces import IRegistry from zope.component import createObject from zope.component import getSiteManager -from zope.component import queryUtility from zope.component import getUtility +from zope.component import queryUtility -from plone.app.testing import TEST_USER_ID, setRoles - -from Products.MailHost.interfaces import IMailHost -from Products.CMFPlone.tests.utils import MockMailHost -from Products.CMFPlone.interfaces import IMailSchema - -from plone.registry.interfaces import IRegistry - -from plone.app.discussion.interfaces import IConversation -from plone.app.discussion.testing import\ - PLONE_APP_DISCUSSION_INTEGRATION_TESTING +import unittest2 as unittest class TestUserNotificationUnit(unittest.TestCase): diff --git a/plone/app/discussion/tests/test_robot.py b/plone/app/discussion/tests/test_robot.py index 3b9eb21..80cee95 100644 --- a/plone/app/discussion/tests/test_robot.py +++ b/plone/app/discussion/tests/test_robot.py @@ -1,9 +1,10 @@ from plone.app.discussion.testing import PLONE_APP_DISCUSSION_ROBOT_TESTING from plone.app.testing import ROBOT_TEST_LEVEL from plone.testing import layered + import os -import unittest import robotsuite +import unittest def test_suite(): diff --git a/plone/app/discussion/tests/test_workflow.py b/plone/app/discussion/tests/test_workflow.py index a82316b..3659ccb 100644 --- a/plone/app/discussion/tests/test_workflow.py +++ b/plone/app/discussion/tests/test_workflow.py @@ -1,23 +1,20 @@ # -*- coding: utf-8 -*- """Test plone.app.discussion workflow and permissions. """ -import unittest2 as unittest - +from AccessControl import Unauthorized +from Products.CMFCore.permissions import View +from Products.CMFCore.utils import _checkPermission as checkPerm +from plone.app.discussion.interfaces import IConversation +from plone.app.discussion.interfaces import IDiscussionLayer +from plone.app.discussion.testing import PLONE_APP_DISCUSSION_INTEGRATION_TESTING # noqa +from plone.app.testing import login +from plone.app.testing import logout +from plone.app.testing import setRoles +from plone.app.testing import TEST_USER_ID from zope.component import createObject - from zope.interface import alsoProvides -from AccessControl import Unauthorized - -from Products.CMFCore.utils import _checkPermission as checkPerm -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.interfaces import IConversation, IDiscussionLayer +import unittest2 as unittest class WorkflowSetupTest(unittest.TestCase): diff --git a/plone/app/discussion/tool.py b/plone/app/discussion/tool.py index d7037f6..cc8e63d 100644 --- a/plone/app/discussion/tool.py +++ b/plone/app/discussion/tool.py @@ -4,15 +4,14 @@ standard portal_catalog for indexing comments. BBB support for the old portal_discussion is provided in the bbb package. """ - +from OFS.SimpleItem import SimpleItem +from Products.CMFCore.utils import UniqueObject +from Products.CMFCore.utils import getToolByName +from interfaces import IComment +from interfaces import ICommentingTool from zope import interface from zope.component import queryUtility -from interfaces import ICommentingTool, IComment - -from Products.CMFCore.utils import UniqueObject, getToolByName -from OFS.SimpleItem import SimpleItem - class CommentingTool(UniqueObject, SimpleItem): diff --git a/plone/app/discussion/upgrades.py b/plone/app/discussion/upgrades.py index 652e060..f19bd30 100644 --- a/plone/app/discussion/upgrades.py +++ b/plone/app/discussion/upgrades.py @@ -1,6 +1,7 @@ -from zope.component import getUtility -from plone.registry.interfaces import IRegistry from plone.app.discussion.interfaces import IDiscussionSettings +from plone.registry.interfaces import IRegistry +from zope.component import getUtility + default_profile = 'profile-plone.app.discussion:default' diff --git a/plone/app/discussion/vocabularies.py b/plone/app/discussion/vocabularies.py index b811dce..b158866 100644 --- a/plone/app/discussion/vocabularies.py +++ b/plone/app/discussion/vocabularies.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- - -from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm - from plone.app.discussion.interfaces import _ +from zope.schema.vocabulary import SimpleTerm +from zope.schema.vocabulary import SimpleVocabulary + HAS_CAPTCHA = False try: