From 848fb912432690fe8b67ec20d80cc2f68286a96b Mon Sep 17 00:00:00 2001 From: Mauro Amico Date: Mon, 18 Sep 2023 14:04:59 +0200 Subject: [PATCH 1/2] Test plone 6 (#35) * ci: plone6 tests * test plone 6.0 * typo * coverage * black --- .coveragerc | 2 +- .github/workflows/tests.yml | 17 ++-- .gitignore | 1 + base.cfg | 1 + constraints_plone60.txt | 1 + requirements.txt | 2 +- .../volto/formsupport/captcha/hcaptcha.py | 1 + .../volto/formsupport/captcha/norobots.py | 8 +- src/collective/volto/formsupport/testing.py | 2 - .../volto/formsupport/tests/test_captcha.py | 1 - .../volto/formsupport/tests/test_event.py | 2 - .../volto/formsupport/tests/test_honeypot.py | 4 - .../formsupport/tests/test_serialize_block.py | 4 - .../volto/formsupport/tests/test_setup.py | 28 ++++-- .../tests/test_store_action_form.py | 1 - src/collective/volto/formsupport/utils.py | 8 +- test_plone52.cfg | 3 + test_plone60.cfg | 86 +++++++++++++++++++ 18 files changed, 130 insertions(+), 42 deletions(-) create mode 100644 constraints_plone60.txt create mode 100644 test_plone60.cfg diff --git a/.coveragerc b/.coveragerc index 35be63d8..acf9b175 100644 --- a/.coveragerc +++ b/.coveragerc @@ -3,7 +3,7 @@ relative_files = True [report] include = - src/collective/* + */src/collective/* omit = */test* /home/*/.buildout/eggs/* diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f0958cde..fe3ee62b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,11 +8,15 @@ jobs: strategy: max-parallel: 4 matrix: - python: ["3.9"] - plone: ["52"] - # exclude: - # - python: "3.7" - # plone: "51" + python: ["3.8", "3.9", "3.10", "3.11"] + plone: ["52", "60"] + exclude: + - python: "3.9" + plone: "52" + - python: "3.10" + plone: "52" + - python: "3.11" + plone: "52" steps: - uses: actions/checkout@v3 - name: Cache eggs @@ -36,8 +40,7 @@ jobs: bin/code-analysis - name: Run tests run: | - bin/test - # bin/test-coverage + bin/test-coverage - name: createcoverage run: | bin/createcoverage -t '--all' diff --git a/.gitignore b/.gitignore index 76dfed01..98c3eeee 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ lib64 log.html output.xml pip-selfcheck.json +.coverage report.html .vscode/ .tox/ diff --git a/base.cfg b/base.cfg index 707264be..db51faf9 100644 --- a/base.cfg +++ b/base.cfg @@ -81,6 +81,7 @@ recipe = collective.recipe.template input = inline: #!/bin/bash export TZ=UTC + set -e ${buildout:directory}/bin/coverage run bin/test $* ${buildout:directory}/bin/coverage html ${buildout:directory}/bin/coverage report -m --fail-under=90 diff --git a/constraints_plone60.txt b/constraints_plone60.txt new file mode 100644 index 00000000..005e694e --- /dev/null +++ b/constraints_plone60.txt @@ -0,0 +1 @@ +-c https://dist.plone.org/release/6.0-latest/requirements.txt diff --git a/requirements.txt b/requirements.txt index 06390bdd..8a011da0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ --c constraints.txt setuptools zc.buildout +wheel diff --git a/src/collective/volto/formsupport/captcha/hcaptcha.py b/src/collective/volto/formsupport/captcha/hcaptcha.py index b383aa52..3d562711 100644 --- a/src/collective/volto/formsupport/captcha/hcaptcha.py +++ b/src/collective/volto/formsupport/captcha/hcaptcha.py @@ -2,6 +2,7 @@ from collective.volto.formsupport import _ from plone.formwidget.hcaptcha.interfaces import IHCaptchaSettings from plone.formwidget.hcaptcha.nohcaptcha import submit + # from plone.formwidget.hcaptcha.validator import WrongCaptchaCode from plone.registry.interfaces import IRegistry from zExceptions import BadRequest diff --git a/src/collective/volto/formsupport/captcha/norobots.py b/src/collective/volto/formsupport/captcha/norobots.py index 0b5409af..12591241 100644 --- a/src/collective/volto/formsupport/captcha/norobots.py +++ b/src/collective/volto/formsupport/captcha/norobots.py @@ -18,9 +18,7 @@ class NoRobotsSupport(CaptchaSupport): def __init__(self, context, request): super().__init__(context, request) registry = queryUtility(IRegistry) - self.settings = registry.forInterface( - INorobotsWidgetSettings, check=False - ) + self.settings = registry.forInterface(INorobotsWidgetSettings, check=False) def isEnabled(self): return self.settings and self.settings.questions @@ -66,9 +64,7 @@ def verify(self, data): if not view.verify(input=value, question_id=id, id_check=id_check): raise BadRequest( translate( - _( - "The code you entered was wrong, please enter the new one." - ), + _("The code you entered was wrong, please enter the new one."), context=self.request, ) ) diff --git a/src/collective/volto/formsupport/testing.py b/src/collective/volto/formsupport/testing.py index df74c330..a4e14086 100644 --- a/src/collective/volto/formsupport/testing.py +++ b/src/collective/volto/formsupport/testing.py @@ -15,7 +15,6 @@ class VoltoFormsupportLayer(PloneSandboxLayer): - defaultBases = (PLONE_APP_CONTENTTYPES_FIXTURE,) def setUpZope(self, app, configurationContext): @@ -48,7 +47,6 @@ def setUpPloneSite(self, portal): class VoltoFormsupportRestApiLayer(PloneRestApiDXLayer): - defaultBases = (PLONE_APP_CONTENTTYPES_FIXTURE,) def setUpZope(self, app, configurationContext): diff --git a/src/collective/volto/formsupport/tests/test_captcha.py b/src/collective/volto/formsupport/tests/test_captcha.py index 829fcbb9..f2656141 100644 --- a/src/collective/volto/formsupport/tests/test_captcha.py +++ b/src/collective/volto/formsupport/tests/test_captcha.py @@ -24,7 +24,6 @@ class TestCaptcha(unittest.TestCase): - layer = VOLTO_FORMSUPPORT_API_FUNCTIONAL_TESTING def setUp(self): diff --git a/src/collective/volto/formsupport/tests/test_event.py b/src/collective/volto/formsupport/tests/test_event.py index aba1eb14..a118be18 100644 --- a/src/collective/volto/formsupport/tests/test_event.py +++ b/src/collective/volto/formsupport/tests/test_event.py @@ -24,7 +24,6 @@ def event_handler(event): class TestEvent(unittest.TestCase): - layer = VOLTO_FORMSUPPORT_API_FUNCTIONAL_TESTING def setUp(self): @@ -91,7 +90,6 @@ def submit_form(self, data): def test_trigger_event( self, ): - self.document.blocks = { "text-id": {"@type": "text"}, "form-id": { diff --git a/src/collective/volto/formsupport/tests/test_honeypot.py b/src/collective/volto/formsupport/tests/test_honeypot.py index 23561ec7..4160972d 100644 --- a/src/collective/volto/formsupport/tests/test_honeypot.py +++ b/src/collective/volto/formsupport/tests/test_honeypot.py @@ -18,7 +18,6 @@ class TestHoneypot(unittest.TestCase): - layer = VOLTO_FORMSUPPORT_API_FUNCTIONAL_TESTING def setUp(self): @@ -72,7 +71,6 @@ def submit_form(self, data): return response def test_honeypot_installed_but_field_not_in_form(self): - self.document.blocks = { "text-id": {"@type": "text"}, "form-id": { @@ -107,7 +105,6 @@ def test_honeypot_installed_but_field_not_in_form(self): ) def test_honeypot_field_in_form_empty_pass_validation(self): - self.document.blocks = { "text-id": {"@type": "text"}, "form-id": { @@ -138,7 +135,6 @@ def test_honeypot_field_in_form_empty_pass_validation(self): self.assertEqual(response.status_code, 204) def test_honeypot_field_in_form_compiled_fail_validation(self): - self.document.blocks = { "text-id": {"@type": "text"}, "form-id": { diff --git a/src/collective/volto/formsupport/tests/test_serialize_block.py b/src/collective/volto/formsupport/tests/test_serialize_block.py index c1b8baeb..b4b7c851 100644 --- a/src/collective/volto/formsupport/tests/test_serialize_block.py +++ b/src/collective/volto/formsupport/tests/test_serialize_block.py @@ -19,7 +19,6 @@ class TestBlockSerialization(unittest.TestCase): - layer = VOLTO_FORMSUPPORT_API_FUNCTIONAL_TESTING def setUp(self): @@ -74,7 +73,6 @@ def test_serializer_return_filtered_block_data_to_anon(self): class TestBlockSerializationRecaptcha(unittest.TestCase): - layer = VOLTO_FORMSUPPORT_API_FUNCTIONAL_TESTING def setUp(self): @@ -131,7 +129,6 @@ def test_serializer_with_recaptcha(self): class TestBlockSerializationHCaptcha(unittest.TestCase): - layer = VOLTO_FORMSUPPORT_API_FUNCTIONAL_TESTING def setUp(self): @@ -188,7 +185,6 @@ def test_serializer_with_hcaptcha(self): class TestBlockSerializationAttachmentsLimit(unittest.TestCase): - layer = VOLTO_FORMSUPPORT_API_FUNCTIONAL_TESTING def setUp(self): diff --git a/src/collective/volto/formsupport/tests/test_setup.py b/src/collective/volto/formsupport/tests/test_setup.py index fcf2ff68..47f8617a 100644 --- a/src/collective/volto/formsupport/tests/test_setup.py +++ b/src/collective/volto/formsupport/tests/test_setup.py @@ -31,9 +31,14 @@ def setUp(self): def test_product_installed(self): """Test if collective.volto.formsupport is installed.""" - self.assertTrue( - self.installer.isProductInstalled("collective.volto.formsupport") - ) + if hasattr(self.installer, "isProductInstalled"): + self.assertTrue( + self.installer.isProductInstalled("collective.volto.formsupport") + ) + else: # plone 6 + self.assertTrue( + self.installer.is_product_installed("collective.volto.formsupport") + ) def test_browserlayer(self): """Test that ICollectiveVoltoFormsupportLayer is registered.""" @@ -46,7 +51,6 @@ def test_browserlayer(self): class TestUninstall(unittest.TestCase): - layer = VOLTO_FORMSUPPORT_INTEGRATION_TESTING def setUp(self): @@ -57,14 +61,22 @@ def setUp(self): self.installer = api.portal.get_tool("portal_quickinstaller") roles_before = api.user.get_roles(TEST_USER_ID) setRoles(self.portal, TEST_USER_ID, ["Manager"]) - self.installer.uninstallProducts(["collective.volto.formsupport"]) + if hasattr(self.installer, "uninstallProducts"): + self.installer.uninstallProducts(["collective.volto.formsupport"]) + else: # plone6 + self.installer.uninstall_product("collective.volto.formsupport") setRoles(self.portal, TEST_USER_ID, roles_before) def test_product_uninstalled(self): """Test if collective.volto.formsupport is cleanly uninstalled.""" - self.assertFalse( - self.installer.isProductInstalled("collective.volto.formsupport") - ) + if hasattr(self.installer, "isProductInstalled"): + self.assertFalse( + self.installer.isProductInstalled("collective.volto.formsupport") + ) + else: # plone 6 + self.assertFalse( + self.installer.is_product_installed("collective.volto.formsupport") + ) def test_browserlayer_removed(self): """Test that ICollectiveVoltoFormsupportLayer is removed.""" 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 505992d0..fd0af723 100644 --- a/src/collective/volto/formsupport/tests/test_store_action_form.py +++ b/src/collective/volto/formsupport/tests/test_store_action_form.py @@ -19,7 +19,6 @@ class TestMailSend(unittest.TestCase): - layer = VOLTO_FORMSUPPORT_API_FUNCTIONAL_TESTING def setUp(self): diff --git a/src/collective/volto/formsupport/utils.py b/src/collective/volto/formsupport/utils.py index 3027f9ed..ed3f1d0a 100644 --- a/src/collective/volto/formsupport/utils.py +++ b/src/collective/volto/formsupport/utils.py @@ -6,7 +6,7 @@ def flatten_block_hierachy(blocks): - """ Given some blocks, return all contained blocks, including "subblocks" + """Given some blocks, return all contained blocks, including "subblocks" This allows embedding the form block into something like columns datastorage """ @@ -21,16 +21,14 @@ def flatten_block_hierachy(blocks): if "data" in block_value: if isinstance(block_value["data"], dict): if "blocks" in block_value["data"]: - queue.extend(list( - block_value["data"]["blocks"].items())) + queue.extend(list(block_value["data"]["blocks"].items())) if "blocks" in block_value: queue.extend(list(block_value["blocks"].items())) def get_blocks(context): - """ Returns all blocks from a context, including those coming from slots - """ + """Returns all blocks from a context, including those coming from slots""" blocks = copy.deepcopy(getattr(context, "blocks", {})) if isinstance(blocks, six.text_type): diff --git a/test_plone52.cfg b/test_plone52.cfg index 8432387a..1c1306ed 100644 --- a/test_plone52.cfg +++ b/test_plone52.cfg @@ -56,3 +56,6 @@ plone.formwidget.recaptcha = 2.3.0 # Added by buildout at 2022-06-08 10:07:55.395703 collective.z3cform.norobots = 2.0 + +# Added by buildout at 2023-09-18 12:59:01.353135 +collective.honeypot = 2.1 diff --git a/test_plone60.cfg b/test_plone60.cfg new file mode 100644 index 00000000..2f2e045e --- /dev/null +++ b/test_plone60.cfg @@ -0,0 +1,86 @@ +[buildout] + +extends = + https://raw.githubusercontent.com/collective/buildout.plonetest/master/test-6.0.x.cfg + https://raw.githubusercontent.com/collective/buildout.plonetest/master/qa.cfg + base.cfg + +update-versions-file = test_plone60.cfg + +[versions] + +# Added by buildout at 2023-09-18 11:12:41.176409 +bleach = 6.0.0 +build = 0.10.0 +collective.honeypot = 2.1 +collective.z3cform.norobots = 2.0 +coverage = 7.2.2 +createcoverage = 1.5 +flake8 = 6.1.0 +i18ndude = 5.5.0 +keyring = 23.13.1 +markdown-it-py = 2.2.0 +mccabe = 0.7.0 +mdurl = 0.1.2 +odict = 1.9.0 +pkginfo = 1.9.6 +plone.formwidget.hcaptcha = 1.0.0 +plone.formwidget.recaptcha = 2.3.0 +plone.recipe.codeanalysis = 3.0.1 +plumber = 1.7 +pycodestyle = 2.11.0 +pyflakes = 3.1.0 +pyproject-hooks = 1.0.0 +readme-renderer = 37.3 +repoze.catalog = 0.9.0 +requests-toolbelt = 0.10.1 +rfc3986 = 2.0.0 +rich = 13.3.4 +twine = 4.0.2 +zest.releaser = 7.3.0 +zope.index = 5.2.1 + +# Required by: +# plone.recipe.codeanalysis==3.0.1 +check-manifest = 0.49 + +# Required by: +# zest.releaser==7.3.0 +colorama = 0.4.6 + +# Required by: +# keyring==23.13.1 +jaraco.classes = 3.2.3 + +# Required by: +# jaraco.classes==3.2.3 +more-itertools = 9.1.0 + +# Required by: +# node.ext.zodb==1.4 +node = 1.2 + +# Required by: +# souper==1.1.1 +node.ext.zodb = 1.4 + +# Required by: +# souper.plone==1.3.1 +souper = 1.1.1 + +# Required by: +# collective.volto.formsupport==2.6.3.dev0 +souper.plone = 1.3.1 + +# Required by: +# check-manifest==0.49 +tomli = 2.0.1 + +# Required by: +# bleach==6.0.0 +webencodings = 0.5.1 + +# Required by: +# collective.honeypot==2.1 +# collective.volto.formsupport==2.6.3.dev0 +z3c.jbot = 1.1.1 From 7f781a1e46ac0a2dc1e96feda12fbd2da1a3b923 Mon Sep 17 00:00:00 2001 From: Jefferson Bledsoe Date: Mon, 25 Sep 2023 14:38:37 +0100 Subject: [PATCH 2/2] Align text in table formatting (#36) * Start align table contents * Use internal value for display if available * Revert "Use internal value for display if available" This reverts commit a572ed0be5ade539d2f205fd07ebde2f84dd389f. --- .../volto/formsupport/browser/send_mail_template_table.pt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/collective/volto/formsupport/browser/send_mail_template_table.pt b/src/collective/volto/formsupport/browser/send_mail_template_table.pt index 6965440b..ac358390 100644 --- a/src/collective/volto/formsupport/browser/send_mail_template_table.pt +++ b/src/collective/volto/formsupport/browser/send_mail_template_table.pt @@ -3,6 +3,11 @@ define="parameters python:options.get('parameters', {}); url python:options.get('url', ''); title python:options.get('title', '');"> +
Form submission data for ${title}