From 86d7f67ad6746b560387d78cb5f487f3b3ad3285 Mon Sep 17 00:00:00 2001 From: David Batranu Date: Fri, 20 Dec 2024 19:05:28 +0200 Subject: [PATCH] Attempt to fix tests. --- .github/workflows/plone-package.yml | 1 - src/pas/plugins/eea/__init__.py | 2 +- src/pas/plugins/eea/interfaces.py | 1 + src/pas/plugins/eea/locales/update.py | 28 +++++++++---------- src/pas/plugins/eea/plugin.py | 1 + src/pas/plugins/eea/setuphandlers.py | 1 - src/pas/plugins/eea/testing.py | 12 +++++---- src/pas/plugins/eea/tests/test_setup.py | 36 ++++++++++++------------- 8 files changed, 41 insertions(+), 41 deletions(-) diff --git a/.github/workflows/plone-package.yml b/.github/workflows/plone-package.yml index 5c19cc6..71296ee 100644 --- a/.github/workflows/plone-package.yml +++ b/.github/workflows/plone-package.yml @@ -16,7 +16,6 @@ jobs: fail-fast: false matrix: plone-version: - - 'Plone52' - 'Plone60' python-version: [3.12] diff --git a/src/pas/plugins/eea/__init__.py b/src/pas/plugins/eea/__init__.py index e4783f0..d1d04c4 100644 --- a/src/pas/plugins/eea/__init__.py +++ b/src/pas/plugins/eea/__init__.py @@ -3,4 +3,4 @@ from zope.i18nmessageid import MessageFactory -_ = MessageFactory('pas.plugins.eea') +_ = MessageFactory("pas.plugins.eea") diff --git a/src/pas/plugins/eea/interfaces.py b/src/pas/plugins/eea/interfaces.py index 318daf3..606b738 100644 --- a/src/pas/plugins/eea/interfaces.py +++ b/src/pas/plugins/eea/interfaces.py @@ -5,5 +5,6 @@ DEFAULT_ID = "eea_entra" + class IPasPluginsEeaLayer(IDefaultBrowserLayer): """Marker interface that defines a browser layer.""" diff --git a/src/pas/plugins/eea/locales/update.py b/src/pas/plugins/eea/locales/update.py index 621d79c..1f09f82 100644 --- a/src/pas/plugins/eea/locales/update.py +++ b/src/pas/plugins/eea/locales/update.py @@ -1,16 +1,16 @@ # -*- coding: utf-8 -*- import os -import pkg_resources import subprocess +import pkg_resources -domain = 'pas.plugins.eea' -os.chdir(pkg_resources.resource_filename(domain, '')) -os.chdir('../../../') -target_path = 'src/pas.plugins/eea/' -locale_path = target_path + 'locales/' -i18ndude = './bin/i18ndude' +domain = "pas.plugins.eea" +os.chdir(pkg_resources.resource_filename(domain, "")) +os.chdir("../../../") +target_path = "src/pas.plugins/eea/" +locale_path = target_path + "locales/" +i18ndude = "./bin/i18ndude" # ignore node_modules files resulting in errors excludes = '"*.html *json-schema*.xml"' @@ -18,15 +18,15 @@ def locale_folder_setup(): os.chdir(locale_path) - languages = [d for d in os.listdir('.') if os.path.isdir(d)] + languages = [d for d in os.listdir(".") if os.path.isdir(d)] for lang in languages: folder = os.listdir(lang) - if 'LC_MESSAGES' in folder: + if "LC_MESSAGES" in folder: continue else: - lc_messages_path = lang + '/LC_MESSAGES/' + lc_messages_path = lang + "/LC_MESSAGES/" os.mkdir(lc_messages_path) - cmd = 'msginit --locale={0} --input={1}.pot --output={2}/LC_MESSAGES/{3}.po'.format( # NOQA: E501 + cmd = "msginit --locale={0} --input={1}.pot --output={2}/LC_MESSAGES/{3}.po".format( # NOQA: E501 lang, domain, lang, @@ -37,11 +37,11 @@ def locale_folder_setup(): shell=True, ) - os.chdir('../../../../') + os.chdir("../../../../") def _rebuild(): - cmd = '{i18ndude} rebuild-pot --pot {locale_path}/{domain}.pot --exclude {excludes} --create {domain} {target_path}'.format( # NOQA: E501 + cmd = "{i18ndude} rebuild-pot --pot {locale_path}/{domain}.pot --exclude {excludes} --create {domain} {target_path}".format( # NOQA: E501 i18ndude=i18ndude, locale_path=locale_path, domain=domain, @@ -55,7 +55,7 @@ def _rebuild(): def _sync(): - cmd = '{0} sync --pot {1}/{2}.pot {3}*/LC_MESSAGES/{4}.po'.format( + cmd = "{0} sync --pot {1}/{2}.pot {3}*/LC_MESSAGES/{4}.po".format( i18ndude, locale_path, domain, diff --git a/src/pas/plugins/eea/plugin.py b/src/pas/plugins/eea/plugin.py index a1b9caa..6de22b7 100644 --- a/src/pas/plugins/eea/plugin.py +++ b/src/pas/plugins/eea/plugin.py @@ -27,6 +27,7 @@ MS_TOKEN_CACHE: dict | None = None + def manage_addEEAEntraPlugin(context, id, title="", RESPONSE=None, **kw): """Create an instance of an EEA Plugin.""" plugin = EEAEntraPlugin(id, title, **kw) diff --git a/src/pas/plugins/eea/setuphandlers.py b/src/pas/plugins/eea/setuphandlers.py index 53c85a8..f0fd77e 100644 --- a/src/pas/plugins/eea/setuphandlers.py +++ b/src/pas/plugins/eea/setuphandlers.py @@ -2,7 +2,6 @@ from plone.base.interfaces import INonInstallable from zope.interface import implementer -from pas.plugins.authomatic.setuphandlers import post_install as authomatic_post_install from .interfaces import DEFAULT_ID from .plugin import EEAEntraPlugin diff --git a/src/pas/plugins/eea/testing.py b/src/pas/plugins/eea/testing.py index 5aa6712..5a8c195 100644 --- a/src/pas/plugins/eea/testing.py +++ b/src/pas/plugins/eea/testing.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- from plone.app.robotframework.testing import REMOTE_LIBRARY_BUNDLE_FIXTURE -from plone.app.testing import applyProfile from plone.app.testing import FunctionalTesting from plone.app.testing import IntegrationTesting from plone.app.testing import PLONE_FIXTURE from plone.app.testing import PloneSandboxLayer +from plone.app.testing import applyProfile from plone.testing import z2 import pas.plugins.eea @@ -19,13 +19,15 @@ def setUpZope(self, app, configurationContext): # The z3c.autoinclude feature is disabled in the Plone fixture base # layer. import plone.app.dexterity + self.loadZCML(package=plone.app.dexterity) import plone.restapi + self.loadZCML(package=plone.restapi) self.loadZCML(package=pas.plugins.eea) def setUpPloneSite(self, portal): - applyProfile(portal, 'pas.plugins.eea:default') + applyProfile(portal, "pas.plugins.eea:default") PAS_PLUGINS_EEA_FIXTURE = PasPluginsEeaLayer() @@ -33,13 +35,13 @@ def setUpPloneSite(self, portal): PAS_PLUGINS_EEA_INTEGRATION_TESTING = IntegrationTesting( bases=(PAS_PLUGINS_EEA_FIXTURE,), - name='PasPluginsEeaLayer:IntegrationTesting', + name="PasPluginsEeaLayer:IntegrationTesting", ) PAS_PLUGINS_EEA_FUNCTIONAL_TESTING = FunctionalTesting( bases=(PAS_PLUGINS_EEA_FIXTURE,), - name='PasPluginsEeaLayer:FunctionalTesting', + name="PasPluginsEeaLayer:FunctionalTesting", ) @@ -49,5 +51,5 @@ def setUpPloneSite(self, portal): REMOTE_LIBRARY_BUNDLE_FIXTURE, z2.ZSERVER_FIXTURE, ), - name='PasPluginsEeaLayer:AcceptanceTesting', + name="PasPluginsEeaLayer:AcceptanceTesting", ) diff --git a/src/pas/plugins/eea/tests/test_setup.py b/src/pas/plugins/eea/tests/test_setup.py index 481afcc..473a4e7 100644 --- a/src/pas/plugins/eea/tests/test_setup.py +++ b/src/pas/plugins/eea/tests/test_setup.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- """Setup tests for this package.""" -from pas.plugins.eea.testing import PAS_PLUGINS_EEA_INTEGRATION_TESTING # noqa: E501 +import unittest + from plone import api -from plone.app.testing import setRoles from plone.app.testing import TEST_USER_ID +from plone.app.testing import setRoles -import unittest - +from pas.plugins.eea.testing import PAS_PLUGINS_EEA_INTEGRATION_TESTING # noqa: E501 try: from Products.CMFPlone.utils import get_installer @@ -21,24 +21,22 @@ class TestSetup(unittest.TestCase): def setUp(self): """Custom shared utility setup for tests.""" - self.portal = self.layer['portal'] + self.portal = self.layer["portal"] if get_installer: - self.installer = get_installer(self.portal, self.layer['request']) + self.installer = get_installer(self.portal, self.layer["request"]) else: - self.installer = api.portal.get_tool('portal_quickinstaller') + self.installer = api.portal.get_tool("portal_quickinstaller") def test_product_installed(self): """Test if pas.plugins.eea is installed.""" - self.assertTrue(self.installer.is_product_installed( - 'pas.plugins.eea')) + self.assertTrue(self.installer.is_product_installed("pas.plugins.eea")) def test_browserlayer(self): """Test that IPasPluginsEeaLayer is registered.""" from pas.plugins.eea.interfaces import IPasPluginsEeaLayer from plone.browserlayer import utils - self.assertIn( - IPasPluginsEeaLayer, - utils.registered_layers()) + + self.assertIn(IPasPluginsEeaLayer, utils.registered_layers()) class TestUninstall(unittest.TestCase): @@ -46,23 +44,23 @@ class TestUninstall(unittest.TestCase): layer = PAS_PLUGINS_EEA_INTEGRATION_TESTING def setUp(self): - self.portal = self.layer['portal'] + self.portal = self.layer["portal"] if get_installer: - self.installer = get_installer(self.portal, self.layer['request']) + self.installer = get_installer(self.portal, self.layer["request"]) else: - self.installer = api.portal.get_tool('portal_quickinstaller') + 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.uninstall_product('pas.plugins.eea') + setRoles(self.portal, TEST_USER_ID, ["Manager"]) + self.installer.uninstall_product("pas.plugins.eea") setRoles(self.portal, TEST_USER_ID, roles_before) def test_product_uninstalled(self): """Test if pas.plugins.eea is cleanly uninstalled.""" - self.assertFalse(self.installer.is_product_installed( - 'pas.plugins.eea')) + self.assertFalse(self.installer.is_product_installed("pas.plugins.eea")) def test_browserlayer_removed(self): """Test that IPasPluginsEeaLayer is removed.""" from pas.plugins.eea.interfaces import IPasPluginsEeaLayer from plone.browserlayer import utils + self.assertNotIn(IPasPluginsEeaLayer, utils.registered_layers())