From cc2f48024477ec111ba251d515165ebf7eac46e9 Mon Sep 17 00:00:00 2001 From: Roman Date: Thu, 11 Apr 2024 17:16:37 +0200 Subject: [PATCH] Formatting --- setup.cfg | 13 +-- src/collective/volto/formsupport/__init__.py | 3 +- .../volto/formsupport/browser/configure.zcml | 36 ++++---- .../formsupport/browser/email_confirm_view.py | 2 +- .../volto/formsupport/captcha/configure.zcml | 88 ++++++++++--------- .../volto/formsupport/captcha/hcaptcha.py | 6 +- .../volto/formsupport/captcha/honeypot.py | 6 +- .../volto/formsupport/captcha/norobots.py | 12 +-- .../volto/formsupport/captcha/recaptcha.py | 6 +- .../volto/formsupport/captcha/vocabularies.py | 6 +- .../volto/formsupport/configure.zcml | 7 +- .../volto/formsupport/datamanager/catalog.py | 15 ++-- .../formsupport/datamanager/configure.zcml | 25 +++--- .../volto/formsupport/locales/update.py | 2 +- .../volto/formsupport/permissions.zcml | 9 +- .../volto/formsupport/restapi/configure.zcml | 5 +- .../formsupport/restapi/serializer/blocks.py | 12 +-- .../restapi/serializer/configure.zcml | 17 ++-- .../restapi/services/configure.zcml | 3 +- .../restapi/services/form_data/clear.py | 6 +- .../restapi/services/form_data/configure.zcml | 50 ++++++----- .../restapi/services/form_data/csv.py | 7 +- .../restapi/services/form_data/form_data.py | 18 ++-- .../services/submit_form/configure.zcml | 17 ++-- .../restapi/services/submit_form/post.py | 28 +++--- .../services/validation/configure.zcml | 31 +++---- .../restapi/services/validation/email.py | 5 +- .../volto/formsupport/scripts/cleansing.py | 10 ++- src/collective/volto/formsupport/testing.py | 18 ++-- .../volto/formsupport/tests/test_captcha.py | 28 +++--- .../volto/formsupport/tests/test_event.py | 21 +++-- .../volto/formsupport/tests/test_honeypot.py | 23 ++--- .../tests/test_send_action_form.py | 27 +++--- .../formsupport/tests/test_serialize_block.py | 23 ++--- .../volto/formsupport/tests/test_setup.py | 17 ++-- .../tests/test_store_action_form.py | 23 ++--- .../volto/formsupport/upgrades.zcml | 19 ++-- src/collective/volto/formsupport/utils.py | 8 +- 38 files changed, 345 insertions(+), 307 deletions(-) diff --git a/setup.cfg b/setup.cfg index 4db9721e..ca8dfa6a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,18 +6,7 @@ ignore = .gitattributes [isort] -# black compatible isort rules: -force_alphabetical_sort = True -force_single_line = True -multi_line_output=3 -include_trailing_comma=True -force_grid_wrap=0 -use_parentheses = True -lines_after_imports = 2 -line_length = 88 -not_skip = - __init__.py -skip = +profile = plone [flake8] # black compatible flake8 rules: diff --git a/src/collective/volto/formsupport/__init__.py b/src/collective/volto/formsupport/__init__.py index 248bf3c9..0ca23783 100644 --- a/src/collective/volto/formsupport/__init__.py +++ b/src/collective/volto/formsupport/__init__.py @@ -1,9 +1,8 @@ # -*- coding: utf-8 -*- """Init and utils.""" -from zope.i18nmessageid import MessageFactory - import logging +from zope.i18nmessageid import MessageFactory logger = logging.getLogger(__name__) _ = MessageFactory("collective.volto.formsupport") diff --git a/src/collective/volto/formsupport/browser/configure.zcml b/src/collective/volto/formsupport/browser/configure.zcml index 76261325..54734f8c 100644 --- a/src/collective/volto/formsupport/browser/configure.zcml +++ b/src/collective/volto/formsupport/browser/configure.zcml @@ -2,10 +2,14 @@ xmlns="http://namespaces.zope.org/zope" xmlns:browser="http://namespaces.zope.org/browser" xmlns:plone="http://namespaces.plone.org/plone" - i18n_domain="collective.volto.formsupport"> + i18n_domain="collective.volto.formsupport" + > - + - - - + + + xmlns:zcml="http://namespaces.zope.org/zcml" + > - + - + - + - - - + - + + + diff --git a/src/collective/volto/formsupport/captcha/hcaptcha.py b/src/collective/volto/formsupport/captcha/hcaptcha.py index 3d562711..e1bf3fe7 100644 --- a/src/collective/volto/formsupport/captcha/hcaptcha.py +++ b/src/collective/volto/formsupport/captcha/hcaptcha.py @@ -1,5 +1,3 @@ -from . import CaptchaSupport -from collective.volto.formsupport import _ from plone.formwidget.hcaptcha.interfaces import IHCaptchaSettings from plone.formwidget.hcaptcha.nohcaptcha import submit @@ -9,6 +7,10 @@ from zope.component import queryUtility from zope.i18n import translate +from collective.volto.formsupport import _ + +from . import CaptchaSupport + class HCaptchaSupport(CaptchaSupport): name = _("HCaptcha") diff --git a/src/collective/volto/formsupport/captcha/honeypot.py b/src/collective/volto/formsupport/captcha/honeypot.py index 9546ff09..d83dab99 100644 --- a/src/collective/volto/formsupport/captcha/honeypot.py +++ b/src/collective/volto/formsupport/captcha/honeypot.py @@ -1,11 +1,13 @@ -from . import CaptchaSupport from collective.honeypot.config import HONEYPOT_FIELD from collective.honeypot.utils import found_honeypot -from collective.volto.formsupport import _ from plone.restapi.deserializer import json_body from zExceptions import BadRequest from zope.i18n import translate +from collective.volto.formsupport import _ + +from . import CaptchaSupport + class HoneypotSupport(CaptchaSupport): name = _("Honeypot Support") diff --git a/src/collective/volto/formsupport/captcha/norobots.py b/src/collective/volto/formsupport/captcha/norobots.py index 12591241..f4c13a0e 100644 --- a/src/collective/volto/formsupport/captcha/norobots.py +++ b/src/collective/volto/formsupport/captcha/norobots.py @@ -1,15 +1,15 @@ -from . import CaptchaSupport -from collective.volto.formsupport import _ -from collective.z3cform.norobots.browser.interfaces import ( - INorobotsWidgetSettings, -) +import json + +from collective.z3cform.norobots.browser.interfaces import INorobotsWidgetSettings from plone import api from plone.registry.interfaces import IRegistry from zExceptions import BadRequest from zope.component import queryUtility from zope.i18n import translate -import json +from collective.volto.formsupport import _ + +from . import CaptchaSupport class NoRobotsSupport(CaptchaSupport): diff --git a/src/collective/volto/formsupport/captcha/recaptcha.py b/src/collective/volto/formsupport/captcha/recaptcha.py index c801ad9f..9ac17abf 100644 --- a/src/collective/volto/formsupport/captcha/recaptcha.py +++ b/src/collective/volto/formsupport/captcha/recaptcha.py @@ -1,5 +1,3 @@ -from . import CaptchaSupport -from collective.volto.formsupport import _ from plone.formwidget.recaptcha.interfaces import IReCaptchaSettings from plone.formwidget.recaptcha.norecaptcha import submit from plone.registry.interfaces import IRegistry @@ -7,6 +5,10 @@ from zope.component import queryUtility from zope.i18n import translate +from collective.volto.formsupport import _ + +from . import CaptchaSupport + class RecaptchaSupport(CaptchaSupport): name = _("Google ReCaptcha") diff --git a/src/collective/volto/formsupport/captcha/vocabularies.py b/src/collective/volto/formsupport/captcha/vocabularies.py index 8e91e53d..70b85231 100644 --- a/src/collective/volto/formsupport/captcha/vocabularies.py +++ b/src/collective/volto/formsupport/captcha/vocabularies.py @@ -1,9 +1,9 @@ -from ..interfaces import ICaptchaSupport from zope.component import getAdapters from zope.interface import provider from zope.schema.interfaces import IVocabularyFactory -from zope.schema.vocabulary import SimpleTerm -from zope.schema.vocabulary import SimpleVocabulary +from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary + +from ..interfaces import ICaptchaSupport @provider(IVocabularyFactory) diff --git a/src/collective/volto/formsupport/configure.zcml b/src/collective/volto/formsupport/configure.zcml index 36f6b34e..0a8a7c64 100644 --- a/src/collective/volto/formsupport/configure.zcml +++ b/src/collective/volto/formsupport/configure.zcml @@ -3,7 +3,8 @@ xmlns:genericsetup="http://namespaces.zope.org/genericsetup" xmlns:i18n="http://namespaces.zope.org/i18n" xmlns:plone="http://namespaces.plone.org/plone" - i18n_domain="collective.volto.formsupport"> + i18n_domain="collective.volto.formsupport" + > @@ -26,18 +27,18 @@ diff --git a/src/collective/volto/formsupport/datamanager/catalog.py b/src/collective/volto/formsupport/datamanager/catalog.py index c92317ae..9611ccfb 100644 --- a/src/collective/volto/formsupport/datamanager/catalog.py +++ b/src/collective/volto/formsupport/datamanager/catalog.py @@ -1,21 +1,20 @@ # -*- coding: utf-8 -*- -from collective.volto.formsupport import logger -from collective.volto.formsupport.interfaces import IFormDataStore -from collective.volto.formsupport.utils import get_blocks from copy import deepcopy from datetime import datetime + from plone.dexterity.interfaces import IDexterityContent from plone.restapi.deserializer import json_body from repoze.catalog.catalog import Catalog from repoze.catalog.indexes.field import CatalogFieldIndex from souper.interfaces import ICatalogFactory -from souper.soup import get_soup -from souper.soup import NodeAttributeIndexer -from souper.soup import Record +from souper.soup import NodeAttributeIndexer, Record, get_soup from zope.component import adapter -from zope.interface import implementer -from zope.interface import Interface +from zope.interface import Interface, implementer + +from collective.volto.formsupport import logger +from collective.volto.formsupport.interfaces import IFormDataStore +from collective.volto.formsupport.utils import get_blocks @implementer(ICatalogFactory) diff --git a/src/collective/volto/formsupport/datamanager/configure.zcml b/src/collective/volto/formsupport/datamanager/configure.zcml index b492ad26..e71ad0c2 100644 --- a/src/collective/volto/formsupport/datamanager/configure.zcml +++ b/src/collective/volto/formsupport/datamanager/configure.zcml @@ -1,19 +1,20 @@ + i18n_domain="collective.volto.formsupport" + > - - - - + + + + - - + + - + diff --git a/src/collective/volto/formsupport/locales/update.py b/src/collective/volto/formsupport/locales/update.py index 32febc89..93d70406 100644 --- a/src/collective/volto/formsupport/locales/update.py +++ b/src/collective/volto/formsupport/locales/update.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- import os -import pkg_resources import subprocess +import pkg_resources domain = "collective.volto.formsupport" os.chdir(pkg_resources.resource_filename(domain, "")) diff --git a/src/collective/volto/formsupport/permissions.zcml b/src/collective/volto/formsupport/permissions.zcml index 1f79c8a3..74de0f41 100644 --- a/src/collective/volto/formsupport/permissions.zcml +++ b/src/collective/volto/formsupport/permissions.zcml @@ -1,10 +1,11 @@ + xmlns="http://namespaces.zope.org/zope" + xmlns:zcml="http://namespaces.zope.org/zcml" + i18n_domain="plone" + > - + diff --git a/src/collective/volto/formsupport/restapi/configure.zcml b/src/collective/volto/formsupport/restapi/configure.zcml index da6334d6..ad138768 100644 --- a/src/collective/volto/formsupport/restapi/configure.zcml +++ b/src/collective/volto/formsupport/restapi/configure.zcml @@ -1,8 +1,9 @@ + xmlns:zcml="http://namespaces.zope.org/zcml" + > - + diff --git a/src/collective/volto/formsupport/restapi/serializer/blocks.py b/src/collective/volto/formsupport/restapi/serializer/blocks.py index 90771487..8da9bf63 100644 --- a/src/collective/volto/formsupport/restapi/serializer/blocks.py +++ b/src/collective/volto/formsupport/restapi/serializer/blocks.py @@ -1,15 +1,17 @@ # -*- coding: utf-8 -*- -from collective.volto.formsupport.interfaces import ICaptchaSupport -from collective.volto.formsupport.interfaces import ICollectiveVoltoFormsupportLayer +import os + from plone import api from plone.restapi.behaviors import IBlocks from plone.restapi.interfaces import IBlockFieldSerializationTransformer from Products.CMFPlone.interfaces import IPloneSiteRoot -from zope.component import adapter -from zope.component import getMultiAdapter +from zope.component import adapter, getMultiAdapter from zope.interface import implementer -import os +from collective.volto.formsupport.interfaces import ( + ICaptchaSupport, + ICollectiveVoltoFormsupportLayer, +) class FormSerializer(object): diff --git a/src/collective/volto/formsupport/restapi/serializer/configure.zcml b/src/collective/volto/formsupport/restapi/serializer/configure.zcml index 49e5e55b..860ca2a0 100644 --- a/src/collective/volto/formsupport/restapi/serializer/configure.zcml +++ b/src/collective/volto/formsupport/restapi/serializer/configure.zcml @@ -1,11 +1,16 @@ + i18n_domain="plone.restapi" + > + + + - - - diff --git a/src/collective/volto/formsupport/restapi/services/configure.zcml b/src/collective/volto/formsupport/restapi/services/configure.zcml index 129f4cb4..5a4cbe43 100644 --- a/src/collective/volto/formsupport/restapi/services/configure.zcml +++ b/src/collective/volto/formsupport/restapi/services/configure.zcml @@ -1,6 +1,7 @@ + xmlns:zcml="http://namespaces.zope.org/zcml" + > diff --git a/src/collective/volto/formsupport/restapi/services/form_data/clear.py b/src/collective/volto/formsupport/restapi/services/form_data/clear.py index 02b2fd90..378627ba 100644 --- a/src/collective/volto/formsupport/restapi/services/form_data/clear.py +++ b/src/collective/volto/formsupport/restapi/services/form_data/clear.py @@ -1,10 +1,12 @@ # -*- coding: utf-8 -*- -from .form_data import FormData -from collective.volto.formsupport.interfaces import IFormDataStore from plone.restapi.deserializer import json_body from plone.restapi.services import Service from zope.component import getMultiAdapter +from collective.volto.formsupport.interfaces import IFormDataStore + +from .form_data import FormData + class FormDataClear(Service): def reply(self): diff --git a/src/collective/volto/formsupport/restapi/services/form_data/configure.zcml b/src/collective/volto/formsupport/restapi/services/form_data/configure.zcml index c645b008..797866a1 100644 --- a/src/collective/volto/formsupport/restapi/services/form_data/configure.zcml +++ b/src/collective/volto/formsupport/restapi/services/form_data/configure.zcml @@ -1,34 +1,38 @@ + xmlns:zcml="http://namespaces.zope.org/zcml" + > - + method="GET" + factory=".form_data.FormDataGet" + for="plone.restapi.behaviors.IBlocks" + permission="cmf.ModifyPortalContent" + layer="collective.volto.formsupport.interfaces.ICollectiveVoltoFormsupportLayer" + name="@form-data" + /> + + method="DELETE" + factory=".clear.FormDataClear" + for="plone.restapi.behaviors.IBlocks" + permission="cmf.ModifyPortalContent" + layer="collective.volto.formsupport.interfaces.ICollectiveVoltoFormsupportLayer" + name="@form-data-clear" + /> + method="GET" + factory=".csv.FormDataExportGet" + for="plone.restapi.behaviors.IBlocks" + permission="cmf.ModifyPortalContent" + layer="collective.volto.formsupport.interfaces.ICollectiveVoltoFormsupportLayer" + name="@form-data-export" + /> diff --git a/src/collective/volto/formsupport/restapi/services/form_data/csv.py b/src/collective/volto/formsupport/restapi/services/form_data/csv.py index 6e7e4b46..bf6628a1 100644 --- a/src/collective/volto/formsupport/restapi/services/form_data/csv.py +++ b/src/collective/volto/formsupport/restapi/services/form_data/csv.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- -from collective.volto.formsupport.interfaces import IFormDataStore +import csv + +import six from plone.restapi.serializer.converters import json_compatible from plone.restapi.services import Service from six import StringIO from zope.component import getMultiAdapter -import csv -import six +from collective.volto.formsupport.interfaces import IFormDataStore SKIP_ATTRS = ["block_id", "fields_labels", "fields_order"] diff --git a/src/collective/volto/formsupport/restapi/services/form_data/form_data.py b/src/collective/volto/formsupport/restapi/services/form_data/form_data.py index f1ac6569..b5a319e1 100644 --- a/src/collective/volto/formsupport/restapi/services/form_data/form_data.py +++ b/src/collective/volto/formsupport/restapi/services/form_data/form_data.py @@ -1,21 +1,19 @@ # -*- coding: utf-8 -*- -from collective.volto.formsupport.interfaces import IFormDataStore -from collective.volto.formsupport.utils import get_blocks -from datetime import datetime -from datetime import timedelta +import json +from datetime import datetime, timedelta + +import six from plone import api from plone.memoize import view from plone.restapi.interfaces import IExpandableElement from plone.restapi.serializer.converters import json_compatible from plone.restapi.services import Service -from zope.component import adapter -from zope.component import getMultiAdapter -from zope.interface import implementer -from zope.interface import Interface +from zope.component import adapter, getMultiAdapter +from zope.interface import Interface, implementer -import json -import six +from collective.volto.formsupport.interfaces import IFormDataStore +from collective.volto.formsupport.utils import get_blocks @implementer(IExpandableElement) diff --git a/src/collective/volto/formsupport/restapi/services/submit_form/configure.zcml b/src/collective/volto/formsupport/restapi/services/submit_form/configure.zcml index 80fdc6be..8e566baa 100644 --- a/src/collective/volto/formsupport/restapi/services/submit_form/configure.zcml +++ b/src/collective/volto/formsupport/restapi/services/submit_form/configure.zcml @@ -1,15 +1,16 @@ + xmlns:zcml="http://namespaces.zope.org/zcml" + > + method="POST" + factory=".post.SubmitPost" + for="plone.restapi.behaviors.IBlocks" + permission="zope2.View" + layer="collective.volto.formsupport.interfaces.ICollectiveVoltoFormsupportLayer" + name="@submit-form" + /> diff --git a/src/collective/volto/formsupport/restapi/services/submit_form/post.py b/src/collective/volto/formsupport/restapi/services/submit_form/post.py index 34233834..c8cf2a51 100644 --- a/src/collective/volto/formsupport/restapi/services/submit_form/post.py +++ b/src/collective/volto/formsupport/restapi/services/submit_form/post.py @@ -1,8 +1,15 @@ # -*- coding: utf-8 -*- +import codecs +import logging +import math +import os from datetime import datetime from email import policy from email.message import EmailMessage +from xml.etree.ElementTree import Element, ElementTree, SubElement + +import six from plone import api from plone.protect.interfaces import IDisableCSRFProtection from plone.registry.interfaces import IRegistry @@ -10,22 +17,11 @@ from plone.restapi.services import Service from plone.schema.email import _isemail from Products.CMFPlone.interfaces.controlpanel import IMailSchema -from xml.etree.ElementTree import Element -from xml.etree.ElementTree import ElementTree -from xml.etree.ElementTree import SubElement from zExceptions import BadRequest -from zope.component import getMultiAdapter -from zope.component import getUtility +from zope.component import getMultiAdapter, getUtility from zope.event import notify from zope.i18n import translate -from zope.interface import alsoProvides -from zope.interface import implementer - -import codecs -import logging -import math -import os -import six +from zope.interface import alsoProvides, implementer from collective.volto.formsupport import _ from collective.volto.formsupport.interfaces import ( @@ -33,10 +29,7 @@ IFormDataStore, IPostEvent, ) -from collective.volto.formsupport.utils import ( - get_blocks, - validate_email_token, -) +from collective.volto.formsupport.utils import get_blocks, validate_email_token logger = logging.getLogger(__name__) CTE = os.environ.get("MAIL_CONTENT_TRANSFER_ENCODING", None) @@ -50,7 +43,6 @@ def __init__(self, context, data): class SubmitPost(Service): - def __init__(self, context, request): super(SubmitPost, self).__init__(context, request) diff --git a/src/collective/volto/formsupport/restapi/services/validation/configure.zcml b/src/collective/volto/formsupport/restapi/services/validation/configure.zcml index 17dcb1b3..3968700d 100644 --- a/src/collective/volto/formsupport/restapi/services/validation/configure.zcml +++ b/src/collective/volto/formsupport/restapi/services/validation/configure.zcml @@ -1,23 +1,24 @@ + xmlns:zcml="http://namespaces.zope.org/zcml" + > + method="POST" + factory=".email.ValidateEmailMessage" + for="*" + permission="zope2.View" + layer="collective.volto.formsupport.interfaces.ICollectiveVoltoFormsupportLayer" + name="@validate-email-message" + /> + method="POST" + factory=".email.ValidateEmailToken" + for="*" + permission="zope2.View" + layer="collective.volto.formsupport.interfaces.ICollectiveVoltoFormsupportLayer" + name="@validate-email-token" + /> diff --git a/src/collective/volto/formsupport/restapi/services/validation/email.py b/src/collective/volto/formsupport/restapi/services/validation/email.py index bf4c190b..e48c7d49 100644 --- a/src/collective/volto/formsupport/restapi/services/validation/email.py +++ b/src/collective/volto/formsupport/restapi/services/validation/email.py @@ -1,15 +1,14 @@ # -*- coding: utf-8 -*- import logging - -from email.utils import parseaddr from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText +from email.utils import parseaddr from plone import api +from plone.restapi.deserializer import json_body from plone.restapi.services import Service from zExceptions import BadRequest -from plone.restapi.deserializer import json_body from collective.volto.formsupport import _ from collective.volto.formsupport.utils import ( diff --git a/src/collective/volto/formsupport/scripts/cleansing.py b/src/collective/volto/formsupport/scripts/cleansing.py index 6f9e28e9..a8d949fb 100644 --- a/src/collective/volto/formsupport/scripts/cleansing.py +++ b/src/collective/volto/formsupport/scripts/cleansing.py @@ -1,11 +1,13 @@ # -*- coding: utf-8 -*- -from collective.volto.formsupport.interfaces import IFormDataStore -from plone import api -from zope.component import getMultiAdapter -from zope.globalrequest import getRequest import sys + import click import transaction +from plone import api +from zope.component import getMultiAdapter +from zope.globalrequest import getRequest + +from collective.volto.formsupport.interfaces import IFormDataStore from collective.volto.formsupport.restapi.services.form_data.form_data import FormData diff --git a/src/collective/volto/formsupport/testing.py b/src/collective/volto/formsupport/testing.py index a4e14086..1b9ae941 100644 --- a/src/collective/volto/formsupport/testing.py +++ b/src/collective/volto/formsupport/testing.py @@ -1,17 +1,19 @@ # -*- coding: utf-8 -*- +import collective.honeypot +import collective.MockMailHost +import plone.restapi from plone.app.contenttypes.testing import PLONE_APP_CONTENTTYPES_FIXTURE -from plone.app.testing import applyProfile -from plone.app.testing import FunctionalTesting -from plone.app.testing import IntegrationTesting -from plone.app.testing import PloneSandboxLayer -from plone.app.testing import quickInstallProduct +from plone.app.testing import ( + FunctionalTesting, + IntegrationTesting, + PloneSandboxLayer, + applyProfile, + quickInstallProduct, +) from plone.restapi.testing import PloneRestApiDXLayer from plone.testing import z2 -import collective.MockMailHost import collective.volto.formsupport -import collective.honeypot -import plone.restapi class VoltoFormsupportLayer(PloneSandboxLayer): diff --git a/src/collective/volto/formsupport/tests/test_captcha.py b/src/collective/volto/formsupport/tests/test_captcha.py index 66a36887..aacc6bf9 100644 --- a/src/collective/volto/formsupport/tests/test_captcha.py +++ b/src/collective/volto/formsupport/tests/test_captcha.py @@ -1,26 +1,28 @@ # -*- coding: utf-8 -*- -from collective.volto.formsupport.testing import ( # noqa: E501, - VOLTO_FORMSUPPORT_API_FUNCTIONAL_TESTING, -) +import json +import unittest from hashlib import md5 +from unittest.mock import Mock, patch + +import transaction +from collective.z3cform.norobots.browser.interfaces import INorobotsWidgetSettings from plone import api -from plone.app.testing import setRoles -from plone.app.testing import SITE_OWNER_NAME -from plone.app.testing import SITE_OWNER_PASSWORD -from plone.app.testing import TEST_USER_ID +from plone.app.testing import ( + SITE_OWNER_NAME, + SITE_OWNER_PASSWORD, + TEST_USER_ID, + setRoles, +) from plone.formwidget.hcaptcha.interfaces import IHCaptchaSettings from plone.formwidget.recaptcha.interfaces import IReCaptchaSettings -from collective.z3cform.norobots.browser.interfaces import INorobotsWidgetSettings from plone.registry.interfaces import IRegistry from plone.restapi.testing import RelativeSession from Products.MailHost.interfaces import IMailHost -from unittest.mock import Mock -from unittest.mock import patch from zope.component import getUtility -import json -import transaction -import unittest +from collective.volto.formsupport.testing import ( # noqa: E501, + VOLTO_FORMSUPPORT_API_FUNCTIONAL_TESTING, +) class TestCaptcha(unittest.TestCase): diff --git a/src/collective/volto/formsupport/tests/test_event.py b/src/collective/volto/formsupport/tests/test_event.py index 279903a8..11433eea 100644 --- a/src/collective/volto/formsupport/tests/test_event.py +++ b/src/collective/volto/formsupport/tests/test_event.py @@ -1,20 +1,23 @@ # -*- coding: utf-8 -*- -from collective.volto.formsupport.testing import ( # noqa: E501, - VOLTO_FORMSUPPORT_API_FUNCTIONAL_TESTING, -) +import unittest + +import transaction from plone import api -from plone.app.testing import setRoles -from plone.app.testing import SITE_OWNER_NAME -from plone.app.testing import SITE_OWNER_PASSWORD -from plone.app.testing import TEST_USER_ID +from plone.app.testing import ( + SITE_OWNER_NAME, + SITE_OWNER_PASSWORD, + TEST_USER_ID, + setRoles, +) from plone.registry.interfaces import IRegistry from plone.restapi.testing import RelativeSession from Products.MailHost.interfaces import IMailHost from zope.component import getUtility from zope.configuration import xmlconfig -import transaction -import unittest +from collective.volto.formsupport.testing import ( # noqa: E501, + VOLTO_FORMSUPPORT_API_FUNCTIONAL_TESTING, +) def event_handler(event): diff --git a/src/collective/volto/formsupport/tests/test_honeypot.py b/src/collective/volto/formsupport/tests/test_honeypot.py index 9e012904..6dda3a61 100644 --- a/src/collective/volto/formsupport/tests/test_honeypot.py +++ b/src/collective/volto/formsupport/tests/test_honeypot.py @@ -1,20 +1,23 @@ # -*- coding: utf-8 -*- -from collective.volto.formsupport.testing import ( # noqa: E501, - VOLTO_FORMSUPPORT_API_FUNCTIONAL_TESTING, -) +import json +import unittest + +import transaction from plone import api -from plone.app.testing import setRoles -from plone.app.testing import SITE_OWNER_NAME -from plone.app.testing import SITE_OWNER_PASSWORD -from plone.app.testing import TEST_USER_ID +from plone.app.testing import ( + SITE_OWNER_NAME, + SITE_OWNER_PASSWORD, + TEST_USER_ID, + setRoles, +) from plone.registry.interfaces import IRegistry from plone.restapi.testing import RelativeSession from Products.MailHost.interfaces import IMailHost from zope.component import getUtility -import transaction -import unittest -import json +from collective.volto.formsupport.testing import ( # noqa: E501, + VOLTO_FORMSUPPORT_API_FUNCTIONAL_TESTING, +) class TestHoneypot(unittest.TestCase): diff --git a/src/collective/volto/formsupport/tests/test_send_action_form.py b/src/collective/volto/formsupport/tests/test_send_action_form.py index af397735..e8109762 100644 --- a/src/collective/volto/formsupport/tests/test_send_action_form.py +++ b/src/collective/volto/formsupport/tests/test_send_action_form.py @@ -1,23 +1,26 @@ # -*- coding: utf-8 -*- -from collective.volto.formsupport.testing import ( # noqa: E501, - VOLTO_FORMSUPPORT_API_FUNCTIONAL_TESTING, -) +import base64 +import os +import unittest +import xml.etree.ElementTree as ET from email.parser import Parser + +import transaction from plone import api -from plone.app.testing import setRoles -from plone.app.testing import SITE_OWNER_NAME -from plone.app.testing import SITE_OWNER_PASSWORD -from plone.app.testing import TEST_USER_ID +from plone.app.testing import ( + SITE_OWNER_NAME, + SITE_OWNER_PASSWORD, + TEST_USER_ID, + setRoles, +) from plone.registry.interfaces import IRegistry from plone.restapi.testing import RelativeSession from Products.MailHost.interfaces import IMailHost from zope.component import getUtility -import base64 -import os -import transaction -import unittest -import xml.etree.ElementTree as ET +from collective.volto.formsupport.testing import ( # noqa: E501, + VOLTO_FORMSUPPORT_API_FUNCTIONAL_TESTING, +) class TestMailSend(unittest.TestCase): diff --git a/src/collective/volto/formsupport/tests/test_serialize_block.py b/src/collective/volto/formsupport/tests/test_serialize_block.py index b4b7c851..a3b81cb3 100644 --- a/src/collective/volto/formsupport/tests/test_serialize_block.py +++ b/src/collective/volto/formsupport/tests/test_serialize_block.py @@ -1,21 +1,24 @@ # -*- coding: utf-8 -*- -from collective.volto.formsupport.testing import ( # noqa: E501, - VOLTO_FORMSUPPORT_API_FUNCTIONAL_TESTING, -) +import os +import unittest + +import transaction from plone import api -from plone.app.testing import setRoles -from plone.app.testing import SITE_OWNER_NAME -from plone.app.testing import SITE_OWNER_PASSWORD -from plone.app.testing import TEST_USER_ID +from plone.app.testing import ( + SITE_OWNER_NAME, + SITE_OWNER_PASSWORD, + TEST_USER_ID, + setRoles, +) from plone.formwidget.hcaptcha.interfaces import IHCaptchaSettings from plone.formwidget.recaptcha.interfaces import IReCaptchaSettings from plone.registry.interfaces import IRegistry from plone.restapi.testing import RelativeSession from zope.component import getUtility -import transaction -import unittest -import os +from collective.volto.formsupport.testing import ( # noqa: E501, + VOLTO_FORMSUPPORT_API_FUNCTIONAL_TESTING, +) class TestBlockSerialization(unittest.TestCase): diff --git a/src/collective/volto/formsupport/tests/test_setup.py b/src/collective/volto/formsupport/tests/test_setup.py index 47f8617a..b77fdc59 100644 --- a/src/collective/volto/formsupport/tests/test_setup.py +++ b/src/collective/volto/formsupport/tests/test_setup.py @@ -1,14 +1,13 @@ # -*- coding: utf-8 -*- """Setup tests for this package.""" +import unittest + +from plone import api +from plone.app.testing import TEST_USER_ID, setRoles + from collective.volto.formsupport.testing import ( # noqa: E501, VOLTO_FORMSUPPORT_INTEGRATION_TESTING, ) -from plone import api -from plone.app.testing import setRoles -from plone.app.testing import TEST_USER_ID - -import unittest - try: from Products.CMFPlone.utils import get_installer @@ -42,10 +41,11 @@ def test_product_installed(self): def test_browserlayer(self): """Test that ICollectiveVoltoFormsupportLayer is registered.""" + from plone.browserlayer import utils + from collective.volto.formsupport.interfaces import ( ICollectiveVoltoFormsupportLayer, ) - from plone.browserlayer import utils self.assertIn(ICollectiveVoltoFormsupportLayer, utils.registered_layers()) @@ -80,9 +80,10 @@ def test_product_uninstalled(self): def test_browserlayer_removed(self): """Test that ICollectiveVoltoFormsupportLayer is removed.""" + from plone.browserlayer import utils + from collective.volto.formsupport.interfaces import ( ICollectiveVoltoFormsupportLayer, ) - from plone.browserlayer import utils self.assertNotIn(ICollectiveVoltoFormsupportLayer, utils.registered_layers()) diff --git a/src/collective/volto/formsupport/tests/test_store_action_form.py b/src/collective/volto/formsupport/tests/test_store_action_form.py index abc7a615..cb613bbd 100644 --- a/src/collective/volto/formsupport/tests/test_store_action_form.py +++ b/src/collective/volto/formsupport/tests/test_store_action_form.py @@ -1,21 +1,24 @@ # -*- coding: utf-8 -*- -from collective.volto.formsupport.testing import ( # noqa: E501, - VOLTO_FORMSUPPORT_API_FUNCTIONAL_TESTING, -) +import csv +import unittest from datetime import datetime from io import StringIO + +import transaction from plone import api -from plone.app.testing import setRoles -from plone.app.testing import SITE_OWNER_NAME -from plone.app.testing import SITE_OWNER_PASSWORD -from plone.app.testing import TEST_USER_ID +from plone.app.testing import ( + SITE_OWNER_NAME, + SITE_OWNER_PASSWORD, + TEST_USER_ID, + setRoles, +) from plone.restapi.testing import RelativeSession from Products.MailHost.interfaces import IMailHost from zope.component import getUtility -import csv -import transaction -import unittest +from collective.volto.formsupport.testing import ( # noqa: E501, + VOLTO_FORMSUPPORT_API_FUNCTIONAL_TESTING, +) class TestMailSend(unittest.TestCase): diff --git a/src/collective/volto/formsupport/upgrades.zcml b/src/collective/volto/formsupport/upgrades.zcml index ba39f930..5943a3f0 100644 --- a/src/collective/volto/formsupport/upgrades.zcml +++ b/src/collective/volto/formsupport/upgrades.zcml @@ -1,20 +1,23 @@ + xmlns="http://namespaces.zope.org/zope" + xmlns:genericsetup="http://namespaces.zope.org/genericsetup" + > + profile="collective.volto.formsupport:default" + source="1000" + destination="1100" + > + profile="collective.volto.formsupport:default" + source="1100" + destination="1200" + >